From 98912695a43a6f2216fed57291f4afedf1256eef Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 29 Sep 2014 17:01:58 +0800 Subject: [PATCH] wait replication sleep some time --- ledis/ledis.go | 2 +- ledis/replication.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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") }