You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 21, 2021. It is now read-only.
Client operations, for example conn.GetW(...), simply enqueue a request on the conn.sendChan and then block for the reply. However, if the client has been shutdown via conn.Close(), subsequent operations should probably fail. Instead, they happily enqueue a request and then block forever since nothing is processing conn.sendChan after the connection is closed.
One possible fix is to simply close sendChan when the connection is closed. This will cause any subsequent operations to panic.
A nicer solution, however, would be to return an error to operations if they are attempted after close. This would require some changes to conn.loop() (or in the go routine that runs it, in Connect(...)) to store a flag indicating that the connection is dead. In conn.queueRequest(...), the code would need to do a select over conn.shouldQuit when trying to store to conn.sendChan in order to skip the request if conn.Close() has been called. To avoid a race, it would also need to check the flag to see if the connection has concurrently become dead after storing the request in sendChan and clean up if so (like by putting an error result into the request's receive channel).
Client operations, for example
conn.GetW(...), simply enqueue a request on theconn.sendChanand then block for the reply. However, if the client has been shutdown viaconn.Close(), subsequent operations should probably fail. Instead, they happily enqueue a request and then block forever since nothing is processingconn.sendChanafter the connection is closed.One possible fix is to simply close
sendChanwhen the connection is closed. This will cause any subsequent operations to panic.A nicer solution, however, would be to return an
errorto operations if they are attempted after close. This would require some changes toconn.loop()(or in the go routine that runs it, inConnect(...)) to store a flag indicating that the connection is dead. Inconn.queueRequest(...), the code would need to do a select overconn.shouldQuitwhen trying to store toconn.sendChanin order to skip the request ifconn.Close()has been called. To avoid a race, it would also need to check the flag to see if the connection has concurrently become dead after storing the request insendChanand clean up if so (like by putting an error result into the request's receive channel).