diff --git a/ledis/ledis.go b/ledis/ledis.go index 949452c..8893eee 100644 --- a/ledis/ledis.go +++ b/ledis/ledis.go @@ -71,7 +71,7 @@ func Open2(cfg *config.Config, flags int) (*Ledis, error) { return nil, err } - l.rc = make(chan struct{}, 8) + l.rc = make(chan struct{}, 1) l.rbatch = l.ldb.NewWriteBatch() l.wg.Add(1) diff --git a/ledis/replication.go b/ledis/replication.go index d9f737a..b68a990 100644 --- a/ledis/replication.go +++ b/ledis/replication.go @@ -70,7 +70,7 @@ func (l *Ledis) handleReplication() error { func (l *Ledis) onReplication() { defer l.wg.Done() - AsyncNotify(l.rc) + l.noticeReplication() for { select { @@ -98,10 +98,12 @@ func (l *Ledis) WaitReplication() error { } else if b { l.noticeReplication() l.rwg.Wait() + time.Sleep(100 * time.Millisecond) } else { return nil } } + return errors.New("wait replication too many times") }