-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Added a GOAWAY frame send on client transport shutdown #4248
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.
Please check the test failures; I suspect they are real errors.
// The HTTP/2 spec mentions that a GOAWAY frame should be sent before a connection close. If this close() function | ||
// ever starts to take in an HTTP/2 error code the peer will be able to get more information about the reason | ||
// behind the connection close. | ||
if err := t.framer.fr.WriteGoAway(math.MaxUint32, http2.ErrCodeNo, []byte{}); err != nil { |
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.
If writing the GOAWAY fails, we still need to close the conn and do the other cleanup below, like adding an error to any streams that are still open.
// The HTTP/2 spec mentions that a GOAWAY frame should be sent before a connection close. If this close() function | ||
// ever starts to take in an HTTP/2 error code the peer will be able to get more information about the reason | ||
// behind the connection close. | ||
if err := t.framer.fr.WriteGoAway(math.MaxUint32, http2.ErrCodeNo, []byte{}); err != nil { |
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's possible we want to do some refactoring here. I think I was expecting we'd pass an error
to http2Client.Close
, and that would dictate the code used here -- OR, pass the code in directly. Anywhere we already send a GOAWAY, we could delete that and rely on this to do it instead. Or we need a way to call Close
to indicate a GOAWAY was already sent, and so Close
should not send another one.
Closing this PR now. Let's get back to this when it's ready. |
Fixes issue #460. The data of the GOAWAY frame is that of a peer attempting a graceful shutdown according to the HTTP/2 spec (ErrCodeNo, Stream ID of 2 ^ 32 - 1). Eventually, seen by Doug's comment in #4190, it is desirable to pass an error into http2_client.close(), which will end up in the GOAWAY frame, but for now any GOAWAY frame sent is better than none.