forked from mirror/ledisdb
wait replication sleep some time
This commit is contained in:
parent
de46e1a511
commit
98912695a4
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue