mirror of
https://github.com/curl/curl.git
synced 2026-08-05 06:46:13 +03:00
ngtcp2: adopt ngtcp2_conn_get_stream_user_data if available
Adopt ngtcp2_conn_get_stream_user_data which has been available since ngtcp2 v1.17.0. This improves the time complexity of searching h3_stream_ctx from O(n) to O(1) where n is the number of stream. Closes #19132
This commit is contained in:
parent
66e3ff5d0e
commit
e0798466a8
1 changed files with 15 additions and 0 deletions
|
|
@ -300,6 +300,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
#if NGTCP2_VERSION_NUM < 0x011100
|
||||
struct cf_ngtcp2_sfind_ctx {
|
||||
curl_int64_t stream_id;
|
||||
struct h3_stream_ctx *stream;
|
||||
|
|
@ -328,6 +329,20 @@ cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, curl_int64_t stream_id)
|
|||
Curl_uint_hash_visit(&ctx->streams, cf_ngtcp2_sfind, &fctx);
|
||||
return fctx.stream;
|
||||
}
|
||||
#else
|
||||
static struct h3_stream_ctx *cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx,
|
||||
curl_int64_t stream_id)
|
||||
{
|
||||
struct Curl_easy *data =
|
||||
ngtcp2_conn_get_stream_user_data(ctx->qconn, stream_id);
|
||||
|
||||
if(!data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return H3_STREAM_CTX(ctx, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cf_ngtcp2_stream_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue