Sending and receving from chans on the same goroutine is a bad idea.
This commit is contained in:
parent
28087af90b
commit
474106a757
1 changed files with 10 additions and 3 deletions
13
sockets.go
13
sockets.go
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue