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

How to get notified when there are data need send to quic from nghttp3? #322

Closed
taikulawo opened this issue Feb 19, 2025 · 4 comments
Closed

Comments

@taikulawo
Copy link

taikulawo commented Feb 19, 2025

We have build a nghttp3 rust library with tokio(an async runtime) support. #281
But I want to optimize reduce unnecessary call to nghttp3_conn_writev_stream

Current, nghttp3_conn_writev_stream need be called almost everywhere to check if there are some data to send

  1. poll new raw data from quic, write to nghttp3, call nghttp3_conn_writev_stream check whether need to send back to quic.
  2. when send request, we call nghttp3_conn_submit_request, then call nghttp3_conn_writev_stream to check.
  3. timer fired, call nghttp3_conn_writev_stream

Does there has a callback to notify us:

please, I(nghttp3) has some data to send, here are, please send to quic right now

int http_need_send_data_callback(nghttp3_conn *conn, int64_t stream_id, const uint8_t *data,
                   size_t datalen, void *user_data, void *stream_user_data) 

Or does we have nice method to get notified when need to poll from nghttp3 then send to quic?

@tatsuhiro-t
Copy link
Member

There is no such method. You only need to call nghttp3_conn_writev_stream after you input some data to nghttp3 (e.g., after submit something, or read some thing with nghttp3_conn_read_stream).

@taikulawo
Copy link
Author

taikulawo commented Feb 20, 2025

Current, we share nghttp3_conn across threads by using Arc<Mutex<Nghttp3Connection>>. Http3RequestStream maybe in another thread. Since I don't sure what the stream_id will nghttp3_conn_writev_stream returned.

I have to forward all nghttp3_conn_writev_stream return value to separate task-A. find quic stream related to that stream_id from hashmap, then send to quic stream.

There have some way to simplify implementation
If I submit data to nghttp3 with stream_id == 3, Does the next call nghttp3_conn_writev_stream will 100% return stream_id == 3 not other stream_id?

If it does, will make my implementation more easy.

@tatsuhiro-t
Copy link
Member

If I submit data to nghttp3 with stream_id == 3, Does the next call nghttp3_conn_writev_stream will 100% return stream_id == 3 not other stream_id?

No. Depending on the priorities and many variables, you cannot predict any particular stream is returned unless you are using single stream.

@taikulawo
Copy link
Author

Got it, thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants