Skip to content

Commit

Permalink
Fix #449. Make heartbeats use a new buffered channel for the response…
Browse files Browse the repository at this point in the history
… for each reqeust
  • Loading branch information
pauldix committed Apr 17, 2014
1 parent 2b85296 commit a37be46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cluster/cluster_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,15 @@ func (self *ClusterServer) heartbeat() {
self.heartbeatStarted = false
}()

responseChan := make(chan *protocol.Response, 1)
heartbeatRequest := &protocol.Request{
Type: &HEARTBEAT_TYPE,
Database: protocol.String(""),
}
for {
// this chan is buffered and in the loop on purpose. This is so
// that if reading a heartbeat times out, and the heartbeat then comes through
// later, it will be dumped into this chan and not block the protobuf client reader.
responseChan := make(chan *protocol.Response, 1)
heartbeatRequest.Id = nil
self.MakeRequest(heartbeatRequest, responseChan)
err := self.getHeartbeatResponse(responseChan)
Expand Down

0 comments on commit a37be46

Please sign in to comment.