Consider to use CANCEL error code when closing streams with GOAWAY
For clients, CANCEL is more appropriate for both incoming/outgoing streams. For servers, CANCEL is appropriate for its pushed stream (outgoing), but REFUSED_STREAM is more appropriate for incoming stream.
This commit is contained in:
parent
b918f9650a
commit
b95a3c4b28
|
@ -2200,16 +2200,19 @@ static int session_close_stream_on_goaway(nghttp2_session *session,
|
||||||
nghttp2_stream *stream, *next_stream;
|
nghttp2_stream *stream, *next_stream;
|
||||||
nghttp2_close_stream_on_goaway_arg arg = {session, NULL, last_stream_id,
|
nghttp2_close_stream_on_goaway_arg arg = {session, NULL, last_stream_id,
|
||||||
incoming};
|
incoming};
|
||||||
|
uint32_t error_code;
|
||||||
|
|
||||||
rv = nghttp2_map_each(&session->streams, find_stream_on_goaway_func, &arg);
|
rv = nghttp2_map_each(&session->streams, find_stream_on_goaway_func, &arg);
|
||||||
assert(rv == 0);
|
assert(rv == 0);
|
||||||
|
|
||||||
|
error_code =
|
||||||
|
session->server && incoming ? NGHTTP2_REFUSED_STREAM : NGHTTP2_CANCEL;
|
||||||
|
|
||||||
stream = arg.head;
|
stream = arg.head;
|
||||||
while (stream) {
|
while (stream) {
|
||||||
next_stream = stream->closed_next;
|
next_stream = stream->closed_next;
|
||||||
stream->closed_next = NULL;
|
stream->closed_next = NULL;
|
||||||
rv = nghttp2_session_close_stream(session, stream->stream_id,
|
rv = nghttp2_session_close_stream(session, stream->stream_id, error_code);
|
||||||
NGHTTP2_REFUSED_STREAM);
|
|
||||||
|
|
||||||
/* stream may be deleted here */
|
/* stream may be deleted here */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue