Sending and receving from chans on the same goroutine is a bad idea.

This commit is contained in:
Josh Rickmar 2013-11-18 16:37:28 -05:00
parent 28087af90b
commit 474106a757

View file

@ -131,10 +131,17 @@ func (s *server) handleRPCRequest(w http.ResponseWriter, r *http.Request) {
log.Errorf("RPCS: Error getting JSON message: %v", err)
}
done := make(chan struct{})
go func() {
if _, err := w.Write(<-frontend); err != nil {
log.Warnf("RPCS: could not respond to RPC request: %v",
err)
}
close(done)
}()
ProcessFrontendMsg(frontend, body, false)
if _, err := w.Write(<-frontend); err != nil {
log.Warnf("RPCS: could not respond to RPC request: %v", err)
}
<-done
}
// frontendListenerDuplicator listens for new wallet listener channels