Skip to content

Commit

Permalink
Merge pull request #61 from coreos/master
Browse files Browse the repository at this point in the history
Fix two problems
  • Loading branch information
benbjohnson committed Jul 8, 2013
2 parents 271a734 + 9efa791 commit 1157ef0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,16 @@ func (l *Log) getEntryResult(entry *LogEntry, clear bool) (interface{}, error) {
// If a result exists for the entry then return it with its error.
if entry.Index > 0 && entry.Index <= uint64(len(l.results)) {
if result := l.results[entry.Index-1]; result != nil {

// keep the records before remove it
returnValue, err := result.returnValue, result.err

// Remove reference to result if it's being cleared after retrieval.
if clear {
result.returnValue = nil
}

return result.returnValue, result.err
return returnValue, err
}
}

Expand Down
12 changes: 11 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,17 @@ func (s *Server) processAppendEntriesResponse(resp *AppendEntriesResponse) {
s.debugln("commit index ", commitIndex)
for i := committedIndex; i < commitIndex; i++ {
if entry := s.log.getEntry(i + 1); entry != nil {
entry.commit <- true
// if the leader is a new one and the entry came from the
// old leader, the commit channel will be nil and no go routine
// is waiting from this channel
// if we try to send to it, the new leader will get stuck
if entry.commit != nil {
select {
case entry.commit <- true:
default:
panic("server unable to send signal to commit channel")
}
}
}
}
}
Expand Down

0 comments on commit 1157ef0

Please sign in to comment.