-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
don't block sendQueue.Send() if the runloop already exited. #2656
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks correct to me. One suggestion to improve the test case.
Also, the file seems to be not gofmted correctly (which is why Travis is complaining).
send_queue_test.go
Outdated
q.Run() | ||
close(done) | ||
}() | ||
q.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a PacketConn
that errors here, instead of calling close? That more closely mirrors the actual issue that you discovered, as the session only calls Close
after calls to Send
have returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marten-seemann Thanks, I updated this to have the MockConnection
trigger an error on Write
(how the queue sees that error) -- I'm not sure rigging in an actual PacketConn
would add much in this context, but let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that's actually what I meant. Should have been more precise.
This can lead to a deadlock where session.shutdown() never exits because it is blocked on a Send() but the sendQueue has exited due to a write error.
084edb0
to
3c1e597
Compare
Codecov Report
@@ Coverage Diff @@
## master #2656 +/- ##
==========================================
+ Coverage 86.42% 86.46% +0.05%
==========================================
Files 122 122
Lines 9761 9765 +4
==========================================
+ Hits 8435 8443 +8
+ Misses 990 988 -2
+ Partials 336 334 -2
Continue to review full report at Codecov.
|
This can lead to a deadlock where session.shutdown() never exits
because it is blocked on a Send() but the sendQueue has exited due to
a write error.
Fixes #2655 but needs consideration for other consequences ...