wait replication sleep some time

This commit is contained in:
siddontang 2014-09-29 17:01:58 +08:00
parent de46e1a511
commit 98912695a4
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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")
}