private-octopus / picoquic

Minimal implementation of the QUIC protocol
MIT License
561 stars 165 forks source link

Set context for stream data callback #1429

Closed huitema closed 1 year ago

huitema commented 1 year ago

The stream data callback is triggered in picoquic_stream_data_chunk_callback as:

cnx->callback_fn(cnx, stream->stream_id, (uint8_t *)bytes, data_length, fin_now,
        cnx->callback_ctx, stream->app_stream_ctx)

There are multiple ways to set the callback parameter app_stream_ctx for writing streams, but there are no ways to do that for read only streams -- the call to picoquic_set_app_stream_ctx only works if the stream is writeable.

There is an easy fix, allow that for any existing stream.

huitema commented 1 year ago

Actually, the call to picoquic_set_app_stream_ctx will succeed if the stream is already created. Will try to use that call for receiving data on unidirectional stream.

huitema commented 1 year ago

Closing. After testing, the APi just works.