http2: Curl_http2_setup needs to init stream data in all invokes

Thus function was written to avoid doing multiple connection data
initializations, which is fine, but since it also initiates stream
related data it is crucial that it doesn't skip those even if called
again for the same connection. Solved by moving the stream
initializations before the "doing-it-again" check.

Reported-by: Inho Oh
Fixes #7630
Closes #7692
This commit is contained in:
Daniel Stenberg 2021-09-10 11:39:22 +02:00
parent e41e1b2a4d
commit 3cb8a74867
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -763,6 +763,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
ncopy);
stream->nread_header_recvbuf += ncopy;
DEBUGASSERT(stream->mem);
H2BUGF(infof(data_s, "Store %zu bytes headers from stream %u at %p",
ncopy, stream_id, stream->mem));
@ -2214,6 +2215,22 @@ CURLcode Curl_http2_setup(struct Curl_easy *data,
Curl_dyn_init(&stream->header_recvbuf, DYN_H2_HEADERS);
Curl_dyn_init(&stream->trailer_recvbuf, DYN_H2_TRAILERS);
stream->upload_left = 0;
stream->upload_mem = NULL;
stream->upload_len = 0;
stream->mem = data->state.buffer;
stream->len = data->set.buffer_size;
httpc->inbuflen = 0;
httpc->nread_inbuf = 0;
httpc->pause_stream_id = 0;
httpc->drain_total = 0;
multi_connchanged(data->multi);
/* below this point only connection related inits are done, which only needs
to be done once per connection */
if((conn->handler == &Curl_handler_http2_ssl) ||
(conn->handler == &Curl_handler_http2))
return CURLE_OK; /* already done */
@ -2230,24 +2247,12 @@ CURLcode Curl_http2_setup(struct Curl_easy *data,
}
infof(data, "Using HTTP2, server supports multiplexing");
stream->upload_left = 0;
stream->upload_mem = NULL;
stream->upload_len = 0;
stream->mem = data->state.buffer;
stream->len = data->set.buffer_size;
httpc->inbuflen = 0;
httpc->nread_inbuf = 0;
httpc->pause_stream_id = 0;
httpc->drain_total = 0;
conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
conn->httpversion = 20;
conn->bundle->multiuse = BUNDLE_MULTIPLEX;
infof(data, "Connection state changed (HTTP/2 confirmed)");
multi_connchanged(data->multi);
return CURLE_OK;
}