-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
ensure hijackedConn implements CloseWrite function #36517
Conversation
ignore powerpc failure, unrelated and debugging. |
Automatic merge from submit-queue. UPSTREAM: <carry>: ensure hijackedConn implements CloseWrite function moby/moby#36516 moby/moby#36517
@runcom @thaJeztah ping |
LGTM ping @cpuguy83 |
Thanks! Is is possible to have a test for this? |
PowerPC failures are not related |
nit: perhaps would be good to have the description of #36516 in the commit-message |
It would be good to only implement CloseWrite if the underlying conn does. |
Also we should think about removing this, I think? |
209657e
to
80ecc25
Compare
Codecov Report
@@ Coverage Diff @@
## master #36517 +/- ##
=========================================
Coverage ? 35.13%
=========================================
Files ? 613
Lines ? 45639
Branches ? 0
=========================================
Hits ? 16036
Misses ? 27462
Partials ? 2141 |
Repushed adding a type assertion and improving the commit message. Beyond the type assertion I can't see a straightforward test case for this? |
client/hijack.go
Outdated
// Conn. | ||
var _ types.CloseWriter = &hijackedConn{} | ||
|
||
func (c *hijackedConn) CloseWrite() error { |
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.
It seems we need two types and decide which one to use based on if the underlying conn supports CloseWrite
, otherwise the caller will end up doing something like:
cw, ok := hijack.(types.CloseWriter)
if ok {
return cw.CloseWrite
}
return hijack.Close()
Which would lead to a leaked fd.
Moved back to code-review per #36517 (comment), or could that change be done in a follow-up, @cpuguy83 ? |
It'd be best to handle it here rather than in a follow-up. |
…lying connection does. If this isn't done, then a container listening on stdin won't receive an EOF when the client closes the stream at their end. Signed-off-by: Jim Minter <[email protected]>
80ecc25
to
3798392
Compare
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.
LGTM
// If there is buffered content, wrap the connection | ||
c = &hijackedConn{c, br} | ||
// If there is buffered content, wrap the connection. We return an | ||
// object that implements CloseWrite iff the underlying connection |
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.
Minor nit, s/iff/if/.
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.
I actually meant iff, as in "if and only if" :)
@runcom still LGTY? |
Yup! |
test-failing is unrelated |
Just to note that in a couple of other places we have something like this instead: Lines 26 to 33 in c3b3be5
and this: Lines 133 to 139 in c3b3be5
Looking at this, I have two conflicting thoughts:
So, should we instead change the above two places to a hack similar to the one in this PR? update: improve wording |
@kolyshkin I think so. But we probably don't need as complicated fix. For |
We don't need |
CloseWrite whenever its underlying connection does. If this isn't done, then a container listening on stdin won't receive an EOF when the client closes the stream at their end. moby/moby#36516 moby/moby#36517
…rite function moby#36516 moby#36517 Origin-commit: 99ac39cbfbec9459f085b9f6cf786945b9e00867
Fixes #36516