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

Add msh3 Support #8517

Closed
wants to merge 40 commits into from
Closed

Add msh3 Support #8517

wants to merge 40 commits into from

Conversation

nibanks
Copy link
Contributor

@nibanks nibanks commented Feb 26, 2022

This PR adds a new experimental, cross-platform HTTP/3 option. It leverages msh3 which is an experimental/PoC HTTP/3 library on top of msquic.

Manually tested on Linux (GitHub Codespaces) and on Windows 11 against several public HTTP/3 hosts (google.com, cloudflare.com, outlook.office.com).

@dfandrich
Copy link
Contributor

dfandrich commented Feb 26, 2022 via email

@nibanks
Copy link
Contributor Author

nibanks commented Feb 26, 2022

msquic is officially supported. msh3 is currently just a personal project of mine (~1000 LoC), with a hope of possibly getting it officially supported in the future. But per my understanding, all HTTP/3 code is considered experimental currently anyways, so there is no guarantee of support for the code yet.

lib/vquic/msh3.c Outdated Show resolved Hide resolved
@bagder bagder added the HTTP/3 h3 or quic related label Feb 26, 2022
@bagder
Copy link
Member

bagder commented Feb 26, 2022

@nibanks try make checksrc to get some complaints on code style... They can also be seen in several of the failed CI builds. example

@nibanks
Copy link
Contributor Author

nibanks commented Mar 24, 2022

You think that makes sense @nibanks ?

Yeah, it does @bagder. But at the same time, I don't want to just drop some crap on you and leave. I want to give you something that works, and can be taken up by others (if they want). I don't know how much time I will be able to dedicate in the long run to help (beyond official support for msquic and occasional work on msh3).

I've done more work on the msh3 side to onboard CI to run my test tool against 3 servers known to support (different) HTTP/3 solutions. They seem to work just fine, which makes me think the issue is my new code on the curl side.

@nibanks
Copy link
Contributor Author

nibanks commented Apr 9, 2022

@bagder things should be good now. Found/fixed the bug you reported about all-zero data size. One interesting thing I found is that the curl thread to drain receives is much slower than the callbacks from msh3. For instance, if you define DEBUG_HTTP3 in the code and run curl --http3 https://www.cloudflare.com/ -o dump you will see the msh3 code spit out logs indicating everything is downloaded instantly, but curl will slowly drain the local receive buffer we've cached, waiting for curl to drain. IMO, that doesn't need to be fixed in this PR though.

@nibanks
Copy link
Contributor Author

nibanks commented Apr 9, 2022

capture

@nibanks
Copy link
Contributor Author

nibanks commented Apr 9, 2022

I think I figured out at least part of the slow curl thread issue. I had to implement Curl_quic_data_pending to indicate I still had more data for curl (commit to come). But I'm struggling to understand the receive close path. For instance, when I run curl --http3 https://msquic.net/iisstart.png -v, at the end of the logs, I get:

...
* Curl_quic_data_pending
* msh3_stream_recv 102400
* returned 99710 bytes of data
* returned 99710 total bytes in recv
< %PNG
< →
* Curl_quic_data_pending
* msh3_getsock
* msh3_stream_recv 102400
* returned 0 total bytes in recv
* Curl_quic_data_pending
* transfer closed with 99710 bytes remaining to read
* Curl_quic_done
* Connection #0 to host msquic.net left intact
curl: (18) transfer closed with 99710 bytes remaining to read   <===== WHY?

As you can see from logs above, we are returning that data to curl: returned 99710 total bytes in recv. Why does it think it was closed with remaining bytes?

@nibanks
Copy link
Contributor Author

nibanks commented Apr 9, 2022

After trying to read through the curl code that calls h3, I still can't figure it out. I'm about as far as I can get for now without help.

@bagder
Copy link
Member

bagder commented Apr 9, 2022

I appreciate how you might run into some curl peculiarity here as the h3 layering is not always crystal clear or even totally sensible. Let me know if you get stuck for real and I can give it a shot from my end.

@bagder
Copy link
Member

bagder commented Apr 9, 2022

After trying to read through the curl code that calls h3, I still can't figure it out. I'm about as far as I can get for now without help.

Still this issue you mean?

@nibanks
Copy link
Contributor Author

nibanks commented Apr 9, 2022

Still this issue you mean?

Yes. I don't understand how I'm supposed to correctly indicate stream closure to curl. AFAICT, the code looks correct, but at least in some scenarios curl says it was terminated without all the data.

@bagder
Copy link
Member

bagder commented Apr 9, 2022

I get build errors on Linux:

Making all in lib
  CC       vauth/libcurl_la-cleartext.lo
  CC       vauth/libcurl_la-cram.lo
  CC       vauth/libcurl_la-digest.lo
  CC       vauth/libcurl_la-gsasl.lo
  CC       vauth/libcurl_la-ntlm.lo
  CC       vauth/libcurl_la-oauth2.lo
  CC       vauth/libcurl_la-spnego_gssapi.lo
In file included from ../lib/urldata.h:136,
                 from vauth/cleartext.c:32:
../lib/http.h:179:3: error: expected specifier-qualifier-list before ‘alignas’
  179 |   alignas(16) pthread_mutex_t mutex;
      |   ^~~~~~~
../lib/http.h:178:8: error: struct has no members [-Wpedantic]
  178 | struct posix_lock {
      |        ^~~~~~~~~~
../lib/http.h:181:19: error: unknown type name ‘posix_lock’
  181 | #define msh3_lock posix_lock
      |                   ^~~~~~~~~~
../lib/http.h:276:3: note: in expansion of macro ‘msh3_lock’
  276 |   msh3_lock recv_lock;
      |   ^~~~~~~~~
In file included from ../lib/urldata.h:136,
                 from vauth/ntlm.c:36:
../lib/http.h:179:3: error: expected specifier-qualifier-list before ‘alignas’
  179 |   alignas(16) pthread_mutex_t mutex;
      |   ^~~~~~~
../lib/http.h:178:8: error: struct has no members [-Wpedantic]
  178 | struct posix_lock {
      |        ^~~~~~~~~~
../lib/http.h:181:19: error: unknown type name ‘posix_lock’
  181 | #define msh3_lock posix_lock
      |                   ^~~~~~~~~~
../lib/http.h:276:3: note: in expansion of macro ‘msh3_lock’
  276 |   msh3_lock recv_lock;

@nibanks
Copy link
Contributor Author

nibanks commented Apr 10, 2022

Is this PR good to go now? Do you still want me to squash rebase first? Anything else?

@bagder
Copy link
Member

bagder commented Apr 10, 2022

I think it is good to go. I will squash it on merge myself, no need for you to do it.

@bagder bagder closed this in 37492eb Apr 10, 2022
@bagder
Copy link
Member

bagder commented Apr 10, 2022

Thanks!

@nibanks nibanks deleted the add-msh3 branch April 10, 2022 17:09
vszakats added a commit to vszakats/curl that referenced this pull request Aug 19, 2024
The original patch added the Find module and CMake option. But the logic
misses a `find_package(MSH3)` call to use that Find module leaving the
referenced variables `MSH3_INCLUDE_DIRS`, `MSH3_LIBRARIES` undefined.

Blind fix.

Follow-up to 37492eb curl#8517
vszakats added a commit that referenced this pull request Aug 20, 2024
The original patch added the Find module and CMake option. But the logic
missed a `find_package(MSH3)` call to use that Find module, leaving the
referenced `MSH3_INCLUDE_DIRS`, `MSH3_LIBRARIES` variables undefined.

Blind fix.

Follow-up to 37492eb #8517

Closes #14609
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

Successfully merging this pull request may close these issues.

6 participants