Repository navigation
Conversation
|
This helps when the SIGINT is received between messages but not when a message is already being read. |
|
I'll need to take another look at how this is implemented by btcd, but I almost half wonder whether it would makes sense to not increment/decrement the rpcServer WaitGroup for this goroutine to receive the websocket client messages. If that change is made, then the goroutine that reads from wsc.allRequests (which WebsocketClientRead sends to, and closes when finished) should be switched from a for-range to a for-select to include not just that channel, but also the rpcServer quit chan. |
|
btcd does this the same way as in your PR, so this may be ok, but I'll let @davecgh comment on which design would be better. Personally I think the btcd design can still result in hangs if you time it right. edit: nvm, I'm wrong. The wait group that btcd increments for the "inHandler" is specific for the client, not the whole server. |
|
This looks correct to me. |
|
Not sure how it can be. If the server has not begun shutting down (so the select falls through to the default case) and ReadMessage is called and blocks, this can block the shutdown of the entire server until the client disconnects or sends an invalid websocket frame. |
|
Yes, as I mentioned in the earlier comment, there's still an issue when the timing is right and the server gets blocked on |
|
I removed I tried a similar workaround, i.e. remove |
|
Two things: First, that looks like a btcrpcclient hang. Second, you modified RequestHandler from a for-select, which reads from s.requests and s.quit, to a for-range that only reads from s.requests. Don't do this. It will now never close, since the s.requests channel is not closed anywhere. |
|
OK, after removing the RequestHandler from waitgroup I saw that it never received s.quit so I removed it form the for-select. I've reverted the changeset. I tried that because I was still facing a hang, here's the complete goroutine dump: https://gist.github.com/tuxcanfly/ad54fdab0a90306cf491 |
|
It's a hack but the last commit seems to help, I didn't find any hang on |
|
As discussed on IRC, there's still one failing case here, although its less frequent: |
There was a problem hiding this comment.
I just pushed a btcrpclient fix that causes requests to error when the client has already shutdown, so this check shouldn't be necessary (and isn't really right to begin with, a disconnected client could reconnect and the request would then be reissued).
There was a problem hiding this comment.
Yup, it was a hack. Removed.
|
With the latest rpcclient, most hangs seem to have been solved. Only issue I'm seeing is: which seems to be fixed by: I guess sending to the response chan was blocked because the receiver had already shutdown. |
There was a problem hiding this comment.
I would just make this an empty default case and let it fall through, then we don't lose another indent.
|
Sorry for nagging but I found at least one instance of a possible hangup. In my tests, this was rare so consider it low priority. https://gist.github.com/tuxcanfly/629e4b9db61441ffebd6 I tried out a fix by using a goroutine to fetch the response and it seems to help: |
|
Saw this again today: https://gist.github.com/tuxcanfly/397b365d03664d16f8a3 |
This is only being done for compatibility with older dcrwallet versions that refuse to decode word list seeds that are not 33 words long when entering them from the console (the gRPC API accepts seeds as simply a byte array so long as they are within the correct length range). Fixes btcsuite#108.
Updated to catch the quit signal and break out of the loop. Tested that ^C shutsdown
btcwalletas expected, with the same env in which it was hanging earlier.