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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
l.rc = make(chan struct{}, 8)
|
l.rc = make(chan struct{}, 1)
|
||||||
l.rbatch = l.ldb.NewWriteBatch()
|
l.rbatch = l.ldb.NewWriteBatch()
|
||||||
|
|
||||||
l.wg.Add(1)
|
l.wg.Add(1)
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (l *Ledis) handleReplication() error {
|
||||||
func (l *Ledis) onReplication() {
|
func (l *Ledis) onReplication() {
|
||||||
defer l.wg.Done()
|
defer l.wg.Done()
|
||||||
|
|
||||||
AsyncNotify(l.rc)
|
l.noticeReplication()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -98,10 +98,12 @@ func (l *Ledis) WaitReplication() error {
|
||||||
} else if b {
|
} else if b {
|
||||||
l.noticeReplication()
|
l.noticeReplication()
|
||||||
l.rwg.Wait()
|
l.rwg.Wait()
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("wait replication too many times")
|
return errors.New("wait replication too many times")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue