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:
Tatsuhiro Tsujikawa 2025-10-19 13:44:37 +09:00 committed by Daniel Stenberg
parent 66e3ff5d0e
commit e0798466a8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -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,