Browse Source

raft: fix comment,method name to needSnapshotAbort

And 'maybeSnapshotAbort' does not 'unset'
the pendingSnapshot. 'resetState', which is called after this
metho, is the one that unsets pendingSnapshot. So this changes
the method name.
Gyu-Ho Lee 9 years ago
parent
commit
33f7e7583b
2 changed files with 4 additions and 4 deletions
  1. 3 3
      raft/progress.go
  2. 1 1
      raft/raft.go

+ 3 - 3
raft/progress.go

@@ -167,9 +167,9 @@ func (pr *Progress) isPaused() bool {
 
 
 func (pr *Progress) snapshotFailure() { pr.PendingSnapshot = 0 }
 func (pr *Progress) snapshotFailure() { pr.PendingSnapshot = 0 }
 
 
-// maybeSnapshotAbort unsets pendingSnapshot if Match is equal or higher than
-// the pendingSnapshot
-func (pr *Progress) maybeSnapshotAbort() bool {
+// needSnapshotAbort returns true if snapshot progress's Match
+// is equal or higher than the pendingSnapshot.
+func (pr *Progress) needSnapshotAbort() bool {
 	return pr.State == ProgressStateSnapshot && pr.Match >= pr.PendingSnapshot
 	return pr.State == ProgressStateSnapshot && pr.Match >= pr.PendingSnapshot
 }
 }
 
 

+ 1 - 1
raft/raft.go

@@ -670,7 +670,7 @@ func stepLeader(r *raft, m pb.Message) {
 				switch {
 				switch {
 				case pr.State == ProgressStateProbe:
 				case pr.State == ProgressStateProbe:
 					pr.becomeReplicate()
 					pr.becomeReplicate()
-				case pr.State == ProgressStateSnapshot && pr.maybeSnapshotAbort():
+				case pr.State == ProgressStateSnapshot && pr.needSnapshotAbort():
 					r.logger.Debugf("%x snapshot aborted, resumed sending replication messages to %x [%s]", r.id, m.From, pr)
 					r.logger.Debugf("%x snapshot aborted, resumed sending replication messages to %x [%s]", r.id, m.From, pr)
 					pr.becomeProbe()
 					pr.becomeProbe()
 				case pr.State == ProgressStateReplicate:
 				case pr.State == ProgressStateReplicate: