Browse Source

etcdserver: respect done channel when sleeping for snapshot backoff

Anthony Romano 10 years ago
parent
commit
c7c3bda8b9
1 changed files with 4 additions and 1 deletions
  1. 4 1
      etcdserver/server.go

+ 4 - 1
etcdserver/server.go

@@ -941,7 +941,10 @@ func (s *EtcdServer) sendMergedSnap(merged snap.Message) {
 			// If the follower still fails to catch up, it is probably just too slow
 			// If the follower still fails to catch up, it is probably just too slow
 			// to catch up. We cannot avoid the snapshot cycle anyway.
 			// to catch up. We cannot avoid the snapshot cycle anyway.
 			if ok {
 			if ok {
-				time.Sleep(releaseDelayAfterSnapshot)
+				select {
+				case <-time.After(releaseDelayAfterSnapshot):
+				case <-s.done:
+				}
 			}
 			}
 			atomic.AddInt64(&s.inflightSnapshots, -1)
 			atomic.AddInt64(&s.inflightSnapshots, -1)
 		case <-s.done:
 		case <-s.done: