bugfix for wait replication

This commit is contained in:
siddontang 2014-09-28 21:55:25 +08:00
parent 2a3fca829e
commit 5786b72eb1
1 changed files with 11 additions and 9 deletions

View File

@ -89,18 +89,20 @@ func (l *Ledis) WaitReplication() error {
} }
l.noticeReplication() l.noticeReplication()
l.rwg.Wait() l.rwg.Wait()
b, err := l.r.CommitIDBehind() for i := 0; i < 100; i++ {
if err != nil { b, err := l.r.CommitIDBehind()
return err if err != nil {
} else if b { return err
AsyncNotify(l.rc) } else if b {
l.rwg.Wait() l.noticeReplication()
l.rwg.Wait()
} else {
return nil
}
} }
return errors.New("wait replication too many times")
return nil
} }
func (l *Ledis) StoreLogsFromReader(rb io.Reader) error { func (l *Ledis) StoreLogsFromReader(rb io.Reader) error {