Closed cachalots closed 2 years ago
How do you know the coroutine leaks? The problem you are trying to solve is: After writing, the coroutine might leak if an error returns. But, if there's any error related to the connection (for example, connection closed), then, we'll receive that same error on the readLoop coroutine, and that will close all the channels. Right?
Correct me if you think I am wrong.
For example, connection closed, if response fr length > 128 (sc.writer length), serverConn.handleEndRequest will block at sc.writer <- fr
, causing serverConn.handleStreams's read loop to be blocked and the channel will not be released properly.
That's right. Thanks for your PR!
If the client closes the connection directly without catching the error, the writer's channel will block and the goroutine will leak.