Skip to content
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

http/3: transfer is still ongoing on quic stream when cancel the http3 stream on which connection has other http/3 streams #13569

Closed
yiweiYoung opened this issue May 9, 2024 · 4 comments
Assignees
Labels
HTTP/3 h3 or quic related

Comments

@yiweiYoung
Copy link

I did this

i make http/3 requests on easy handle, then add to multi handle. pesudo code like this

  • init multi handle
    • init easy handle1, then add to multi
  • multi poll(such as 100ms)
    • init easy handle2, then add to multi, handle2 will resue quic connection
  • multi poll(for such as 100ms)
  • remove easy handle1
  • multi poll(for such as 10s)
  • ...

I expected the following

after remove easy handle1, the http/3 stream is closed but quic stream is still opened. why?

actually, quic stream0 is still transer data. i find this from the source code at curl_ngtcp2.c

Q why quic stream is remain opened when we shutdown http/3 stream

static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data)
{
  struct cf_ngtcp2_ctx *ctx = cf->ctx;
  struct h3_stream_ctx *stream = H3_STREAM_CTX(data);

  (void)cf;
  if(stream) {
    CURL_TRC_CF(data, cf, "[%"PRId64"] easy handle is done", stream->id);
    if(ctx->h3conn && !stream->closed) {
    /* shutdown http/3 stream, but quic stream is open, why not */
      nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream->id);
      nghttp3_conn_close_stream(ctx->h3conn, stream->id,
                                NGHTTP3_H3_REQUEST_CANCELLED);
      nghttp3_conn_set_stream_user_data(ctx->h3conn, stream->id, NULL);
      ngtcp2_conn_set_stream_user_data(ctx->qconn, stream->id, NULL);
      stream->closed = TRUE;
    }

    Curl_bufq_free(&stream->sendbuf);
    Curl_h1_req_parse_free(&stream->h1);
    free(stream);
    H3_STREAM_LCTX(data) = NULL;
  }
}

...

static CURLcode cf_ngtcp2_data_event(struct Curl_cfilter *cf,
                                     struct Curl_easy *data,
                                     int event, int arg1, void *arg2)
  case CF_CTRL_DATA_DETACH:
    h3_data_done(cf, data);
    break;

curl/libcurl version

curl version: libcurl/8.7.0-DEV quictls/1.1.1s zlib/1.2.11 ngtcp2/1.4.0 nghttp3/1.2.0

operating system

Darwin B-92RGMD6R-1918.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64

@yiweiYoung yiweiYoung changed the title http/3: transfer is still ongoing on quic stream when cancel http3 on which connection has other http/3 streams http/3: transfer is still ongoing on quic stream when cancel the http3 stream on which connection has other http/3 streams May 9, 2024
@icing
Copy link
Contributor

icing commented May 9, 2024

Thanks for the report. This seems to point to a misunderstanding by us how the nghttp3+ngtcp2 APIs work here.

PR #13562 should fix this for you. If you are able to build that and verify that is works for you, that'd be great!

@bagder bagder added the HTTP/3 h3 or quic related label May 9, 2024
@icing
Copy link
Contributor

icing commented May 10, 2024

The fix has been merged into master now.

@bagder
Copy link
Member

bagder commented May 13, 2024

@yiweiYoung if you try curl from git master, does it behave better for you?

@yiweiYoung
Copy link
Author

thanks, it is OK now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP/3 h3 or quic related
Development

No branches or pull requests

3 participants