Merge pull request #95 from coreos/master

avoid deadlock
pull/820/head
Ben Johnson 2013-08-02 09:09:53 -07:00
commit 29ebf5c0f5
2 changed files with 9 additions and 2 deletions

View File

@ -782,7 +782,14 @@ func (s *Server) processCommand(command Command, e *event) {
resp.append = true
resp.peer = s.Name()
s.sendAsync(resp)
// this must be async
// sendAsync is not really async every time
// when the sending speed of the user is larger than
// the processing speed of the server, the buffered channel
// will be full. Then sendAsync will become sync, which will
// cause deadlock here.
// so we use a goroutine to avoid the deadlock
go s.sendAsync(resp)
}
//--------------------------------------

View File

@ -389,7 +389,7 @@ func TestServerMultiNode(t *testing.T) {
for _, name := range names {
server := newTestServer(name, transporter)
defer server.Stop()
mutex.Lock()
servers[name] = server
mutex.Unlock()