-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
closeConnection
can swallow IO exceptions and block / hang indefinitely
#103
Comments
Is this a theoretical concern or can you actually trigger this as a bug? I'm asking because I believe the code is correct, based on these two assumptions:
In addition, I think most users will have heartbeats enabled, so that would be another safeguard to prevent infinite blocking. |
I have in fact experienced However, to be clear, I do not know why Given the code you pointed me to, I am now quite perplexed. It looks like the lock should definitely be filled whenever the connection is closed. That leaves me wondering whether there's really no other way for |
After thinking about it some more, you might be right. If writeFrame fails without closing the connection, the code might deadlock. I have no idea if that could ever happen, but it's probably better to be resistant to that. I've pushed a fix: ff169bb Does the change look good to you? |
Yeah, looks good to me. Thanks for the quick response / work! |
Ok, I've pushed a new version to Hackage. Curious to see if the blocking issue persists for you. |
amqp/Network/AMQP/Internal.hs
Lines 418 to 431 in 3ddd972
closeConnection
swallows any IO exceptions it might encounter upon sending the close connection message to the server, and then waits on the server indefinitely, expecting the server to send back a connection_closed_ok message.One problem I see is that if an IO exception is encountered when sending the server the close connection message, there is no reason to expect that the server has properly received the message, and therefore no reason to expect that the server will respond with a connection_closed_ok message.
In such a case, the
MVar
contents will never become full, and the call toreadMVar
will block forever. From thereadMVar
docs:https://www.stackage.org/haddock/lts-18.22/base-4.14.3.0/Control-Concurrent-MVar.html#v:readMVar
I would propose that
closeConnection
at a minimum be altered such thatreadMVar
is not called if an IO exception is encountered.The text was updated successfully, but these errors were encountered: