rpcclient: correctly handle request channel closure
wsReader() closes c.done first and then goes over the list of c.respChannels. Technically this means that any of the two can be taken in this select. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
ab64f7cfe4
commit
08b273266b
1 changed files with 4 additions and 1 deletions
|
@ -638,7 +638,10 @@ func (c *WSClient) makeWsRequest(r *neorpc.Request) (*neorpc.Response, error) {
|
|||
select {
|
||||
case <-c.done:
|
||||
return nil, errors.New("connection lost while waiting for the response")
|
||||
case resp := <-ch:
|
||||
case resp, ok := <-ch:
|
||||
if !ok {
|
||||
return nil, errors.New("connection lost while waiting for the response")
|
||||
}
|
||||
c.unregisterRespChannel(r.ID)
|
||||
return resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue