diff --git a/.github/workflows/publish-interop-client.yml b/.github/workflows/publish-interop-client.yml index 1ea464f1..eea6b602 100644 --- a/.github/workflows/publish-interop-client.yml +++ b/.github/workflows/publish-interop-client.yml @@ -22,9 +22,9 @@ on: workflow_dispatch: inputs: picoquic_ref: - description: 'picoquic branch/tag/full SHA override (default: 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2)' + description: 'picoquic branch/tag/full SHA override (default: 36f49b73d532369882d97474ac018655b6739a58)' required: false - default: '70b5fd5aafdd2d6c349ff783202ece9d778bcaf2' + default: '36f49b73d532369882d97474ac018655b6739a58' picotls_ref: description: 'picotls branch/tag/full SHA override (default: 7f0d38c1c54c920d56b4e13ceb1c2dfa2b1325e1)' required: false @@ -57,7 +57,7 @@ jobs: - name: Validate picoquic + picotls refs shell: bash env: - PICOQUIC_REF: ${{ github.event.inputs.picoquic_ref || '70b5fd5aafdd2d6c349ff783202ece9d778bcaf2' }} + PICOQUIC_REF: ${{ github.event.inputs.picoquic_ref || '36f49b73d532369882d97474ac018655b6739a58' }} PICOTLS_REF: ${{ github.event.inputs.picotls_ref || '7f0d38c1c54c920d56b4e13ceb1c2dfa2b1325e1' }} run: | set -euo pipefail @@ -70,7 +70,7 @@ jobs: - name: Fetch picoquic + picotls (recurse submodules) shell: bash env: - PICOQUIC_REF: ${{ github.event.inputs.picoquic_ref || '70b5fd5aafdd2d6c349ff783202ece9d778bcaf2' }} + PICOQUIC_REF: ${{ github.event.inputs.picoquic_ref || '36f49b73d532369882d97474ac018655b6739a58' }} PICOTLS_REF: ${{ github.event.inputs.picotls_ref || '7f0d38c1c54c920d56b4e13ceb1c2dfa2b1325e1' }} run: | set -euo pipefail diff --git a/adapters/pico_wt/include/moq/pico_wt.h b/adapters/pico_wt/include/moq/pico_wt.h index d7ae50ae..e47f5be4 100644 --- a/adapters/pico_wt/include/moq/pico_wt.h +++ b/adapters/pico_wt/include/moq/pico_wt.h @@ -184,10 +184,10 @@ MOQ_API void moq_pico_wt_conn_notify_transport_closed( * most that window. A tighter maximum follows from the caller's own * configuration, per category: peer unidirectional WT streams are bounded by * initial_max_stream_data_uni times the number of such streams picoquic lets - * the peer keep open at once (initial_max_stream_id_unidir governs + * the peer keep open at once (initial_max_streams_uni governs * concurrency, not lifetime: picoquic re-credits a stream as each completes); * peer-initiated bidirectional streams by initial_max_stream_data_bidi_remote - * and initial_max_stream_id_bidir; locally initiated bidirectional streams + * and initial_max_streams_bidi; locally initiated bidirectional streams * (request streams, whose receive half this adapter also tracks) by * initial_max_stream_data_bidi_local times however many such streams the * PEER's MAX_STREAMS allows this endpoint to open, which is not under this @@ -218,7 +218,7 @@ MOQ_API void moq_pico_wt_conn_notify_transport_closed( * stream limits while the streams it already counted stay counted, under * this adapter's receive accounting. Create refuses a connection whose * local transport parameters cannot be read, before taking anything. The - * adapter samples initial_max_stream_id_unidir at attach and fails the + * adapter samples initial_max_streams_uni at attach and fails the * connection closed (the adapter's inbound failure) when a receive sweep * finds it changed or unreadable. That check sees only a change of that one * value; it does not see other parameters or the stream-credit history diff --git a/adapters/pico_wt/pico_wt_adapter.c b/adapters/pico_wt/pico_wt_adapter.c index 31a321b1..d88996e8 100644 --- a/adapters/pico_wt/pico_wt_adapter.c +++ b/adapters/pico_wt/pico_wt_adapter.c @@ -262,7 +262,7 @@ int moq_pico_wt_conn_create(const moq_pico_wt_conn_cfg_t *cfg, c->stop_sending_count = 0; c->last_stop_sending_stream_id = UINT64_MAX; - c->tp_max_streams_uni = tp->initial_max_stream_id_unidir; + c->tp_max_streams_uni = tp->initial_max_streams_uni; /* Initialize endpoint ops. */ if (pico_wt_endpoint_init(&c->endpoint_ops, &c->endpoint_ctx, @@ -910,7 +910,7 @@ static void pw_rx_sweep(moq_pico_wt_conn_t *c, uint64_t now) if (c->cnx) { const picoquic_tp_t *tp = picoquic_get_transport_parameters(c->cnx, 1); if (tp == NULL || - tp->initial_max_stream_id_unidir != c->tp_max_streams_uni) { + tp->initial_max_streams_uni != c->tp_max_streams_uni) { moq_transport_bridge_on_transport_error( c->bridge, PICO_WT_INBOUND_FATAL_CODE, now); return; diff --git a/adapters/pico_wt/pico_wt_adapter.h b/adapters/pico_wt/pico_wt_adapter.h index 235c8757..d22600e2 100644 --- a/adapters/pico_wt/pico_wt_adapter.h +++ b/adapters/pico_wt/pico_wt_adapter.h @@ -137,7 +137,7 @@ struct moq_pico_wt_conn { bool rx_replay_complete; uint64_t rx_replay_complete_sid; - /* The peer-unidirectional stream credit (initial_max_stream_id_unidir) + /* The peer-unidirectional stream credit (initial_max_streams_uni) * this endpoint's transport parameters carried when the adapter attached, * after picowt's own adjustment (picowt_set_transport_parameters raises * it to at least 63). A later picoquic_set_transport_parameters on the diff --git a/adapters/pico_wt/tests/test_outbound_stream_credit.c b/adapters/pico_wt/tests/test_outbound_stream_credit.c index 47c3873e..05e6d8ce 100644 --- a/adapters/pico_wt/tests/test_outbound_stream_credit.c +++ b/adapters/pico_wt/tests/test_outbound_stream_credit.c @@ -370,7 +370,7 @@ static int setup(credit_pair_t *p, uint8_t discriminator) * completable DATA to trigger replenishment without closing control. * Three WT bidis cover CONNECT and two held MoQ requests. */ picoquic_tp_t tp = *picoquic_get_transport_parameters(h->test_ctx->cnx_client, 1); - tp.initial_max_stream_id_unidir = p->wt ? 9 : 3; + tp.initial_max_streams_uni = p->wt ? 9 : 3; tp.is_reset_stream_at_enabled = 1; picoquic_set_transport_parameters(h->test_ctx->cnx_client, &tp); picoquic_set_default_tp_value(h->test_ctx->qserver, diff --git a/adapters/pico_wt/tests/test_pico_wt_hold_input.c b/adapters/pico_wt/tests/test_pico_wt_hold_input.c index e7e8160d..b84613fa 100644 --- a/adapters/pico_wt/tests/test_pico_wt_hold_input.c +++ b/adapters/pico_wt/tests/test_pico_wt_hold_input.c @@ -50,7 +50,7 @@ static uint64_t g_next_bidi = 4; /* client-initiated bidi after the WT CONNEC static uint64_t g_reset_code = 0; static uint64_t g_peer_stop_code = 0; static uint64_t g_rx_window = 65535; -static uint64_t g_tp_streams_uni = 64; /* initial_max_stream_id_unidir */ +static uint64_t g_tp_streams_uni = 64; /* initial_max_streams_uni */ static uint64_t g_tp_streams_bidi = 0; static uint32_t g_client_max_events = 64; /* the fetcher session's event queue */ static picoquic_state_enum g_cnx_state = picoquic_state_ready; @@ -97,8 +97,8 @@ picoquic_tp_t const *picoquic_get_transport_parameters(picoquic_cnx_t *c, int ge tp.initial_max_stream_data_uni = g_rx_window; tp.initial_max_stream_data_bidi_remote = g_rx_window; tp.initial_max_stream_data_bidi_local = g_rx_window; - tp.initial_max_stream_id_unidir = g_tp_streams_uni; - tp.initial_max_stream_id_bidir = g_tp_streams_bidi; + tp.initial_max_streams_uni = g_tp_streams_uni; + tp.initial_max_streams_bidi = g_tp_streams_bidi; tp.is_reset_stream_at_enabled = g_reset_at_enabled; return &tp; } diff --git a/adapters/picoquic/README.md b/adapters/picoquic/README.md index 2a2dd353..dfd292f8 100644 --- a/adapters/picoquic/README.md +++ b/adapters/picoquic/README.md @@ -267,7 +267,7 @@ and `Threads::Threads`. ## Provider source baseline The pinned development picoquic source is -70b5fd5aafdd2d6c349ff783202ece9d778bcaf2 (release `v2026.10.22.70b5fd5`) +36f49b73d532369882d97474ac018655b6739a58 (release `v2026.11.12.36f49b7`) with the patches `scripts/setup_picoquic_deps.sh` applies, built against picotls 7f0d38c1c54c920d56b4e13ceb1c2dfa2b1325e1. Other source trees given through `MOQ_PICOQUIC_SOURCE_DIR` are used as they are: no version is diff --git a/adapters/picoquic/include/moq/picoquic.h b/adapters/picoquic/include/moq/picoquic.h index 9ba9bb8e..194e1f2a 100644 --- a/adapters/picoquic/include/moq/picoquic.h +++ b/adapters/picoquic/include/moq/picoquic.h @@ -55,10 +55,10 @@ * follows from the caller's own configuration, per category: peer * unidirectional streams are bounded by the window this endpoint advertised * for them (initial_max_stream_data_uni) times the number of such streams - * picoquic lets the peer keep open at once (initial_max_stream_id_unidir + * picoquic lets the peer keep open at once (initial_max_streams_uni * governs concurrency, not lifetime: picoquic re-credits a stream as each * one completes); peer-initiated bidirectional streams likewise by - * initial_max_stream_data_bidi_remote and initial_max_stream_id_bidir; + * initial_max_stream_data_bidi_remote and initial_max_streams_bidi; * locally initiated bidirectional streams (request streams, whose receive * half this adapter also tracks) by initial_max_stream_data_bidi_local times * however many such streams the PEER's MAX_STREAMS allows this endpoint to @@ -83,7 +83,7 @@ * stream limits while the streams it already counted stay counted, under * this adapter's receive accounting. Create refuses a connection whose * local transport parameters cannot be read, before taking anything. The - * adapter samples initial_max_stream_id_unidir at attach and fails the + * adapter samples initial_max_streams_uni at attach and fails the * connection closed (the transport-error path) when a service pass finds it * changed or unreadable. That check sees only a change of that one value; * it does not see other parameters or the stream-credit history before diff --git a/adapters/picoquic/moq_picoquic.c b/adapters/picoquic/moq_picoquic.c index cf874862..0585bb30 100644 --- a/adapters/picoquic/moq_picoquic.c +++ b/adapters/picoquic/moq_picoquic.c @@ -44,7 +44,7 @@ struct moq_pq_conn { size_t rx_count; size_t rx_cap; - /* The peer-unidirectional stream credit (initial_max_stream_id_unidir) + /* The peer-unidirectional stream credit (initial_max_streams_uni) * this endpoint's transport parameters carried when the adapter attached. * Attach comes after the caller's transport-parameter preparation; a * later picoquic_set_transport_parameters on the connection is outside @@ -664,7 +664,7 @@ static void pq_rx_after_service(moq_pq_conn_t *c, uint64_t now) if (c->cnx) { const picoquic_tp_t *tp = picoquic_get_transport_parameters(c->cnx, 1); if (tp == NULL || - tp->initial_max_stream_id_unidir != c->tp_max_streams_uni) { + tp->initial_max_streams_uni != c->tp_max_streams_uni) { moq_transport_bridge_on_transport_error(c->bridge, 0, now); return; } @@ -952,7 +952,7 @@ int moq_pq_conn_create(const moq_pq_conn_cfg_t *cfg, sizeof(cfg->after_callback)) c->after_callback = cfg->after_callback; - c->tp_max_streams_uni = tp->initial_max_stream_id_unidir; + c->tp_max_streams_uni = tp->initial_max_streams_uni; uint64_t queue_cap = MOQ_PQ_SEND_QUEUE_CAP_DEFAULT; if (cfg->struct_size >= offsetof(moq_pq_conn_cfg_t, send_queue_cap_bytes) + sizeof(cfg->send_queue_cap_bytes) && cfg->send_queue_cap_bytes) diff --git a/adapters/picoquic/tests/test_pq_hold_input.c b/adapters/picoquic/tests/test_pq_hold_input.c index 9c44cba5..49c52290 100644 --- a/adapters/picoquic/tests/test_pq_hold_input.c +++ b/adapters/picoquic/tests/test_pq_hold_input.c @@ -52,7 +52,7 @@ static uint64_t g_next_bidi = 0; /* client-initiated bidi: 0, 4, 8 .. */ static uint64_t g_reset_code = 0; /* code the next stream_reset event carries */ static uint64_t g_peer_stop_code = 0; static uint64_t g_rx_window = 65535; -static uint64_t g_tp_streams_uni = 64; /* initial_max_stream_id_unidir */ +static uint64_t g_tp_streams_uni = 64; /* initial_max_streams_uni */ static uint64_t g_tp_streams_bidi = 0; static uint32_t g_client_max_events = 64; /* the fetcher session's event queue */ static picoquic_state_enum g_cnx_state = picoquic_state_ready; @@ -196,8 +196,8 @@ picoquic_tp_t const *picoquic_get_transport_parameters(picoquic_cnx_t *c, int ge tp.initial_max_stream_data_uni = g_rx_window; tp.initial_max_stream_data_bidi_remote = g_rx_window; tp.initial_max_stream_data_bidi_local = g_rx_window; - tp.initial_max_stream_id_unidir = g_tp_streams_uni; - tp.initial_max_stream_id_bidir = g_tp_streams_bidi; + tp.initial_max_streams_uni = g_tp_streams_uni; + tp.initial_max_streams_bidi = g_tp_streams_bidi; return &tp; } /* Flow-control instrumentation: app-flow-control takeover and grants per stream. */ diff --git a/adapters/picoquic/tests/test_pq_provider_stream_credit.c b/adapters/picoquic/tests/test_pq_provider_stream_credit.c index 2f32e1c6..5f372b1a 100644 --- a/adapters/picoquic/tests/test_pq_provider_stream_credit.c +++ b/adapters/picoquic/tests/test_pq_provider_stream_credit.c @@ -149,7 +149,7 @@ static int setup(pair_t *p) REQUIRE(tls_api_one_sim_round(p->tls, &p->now, limit, &active) == 0); } REQUIRE(picoquic_get_cnx_state(s) == picoquic_state_ready); - REQUIRE(s->local_parameters.initial_max_stream_id_unidir == 1); + REQUIRE(s->local_parameters.initial_max_streams_uni == 1); REQUIRE(s->max_streams_unidir_local == 1); REQUIRE(s->max_streams_unidir_local_computed == 0); REQUIRE(s->is_reset_stream_at_enabled); diff --git a/adapters/picoquic/tests/test_pq_zero_rtt_refused.c b/adapters/picoquic/tests/test_pq_zero_rtt_refused.c index c96e854a..6c6ed51e 100644 --- a/adapters/picoquic/tests/test_pq_zero_rtt_refused.c +++ b/adapters/picoquic/tests/test_pq_zero_rtt_refused.c @@ -60,6 +60,18 @@ static int noop_pump(moq_pq_threaded_t *t, moq_pq_threaded_lane_t *lane, return 0; } +/* The raw client accepts every event. picoquic replaces a NULL callback with + * one that refuses every event, which would fail the handshake. */ +static int accept_all_cb(picoquic_cnx_t *cnx, uint64_t stream_id, + uint8_t *bytes, size_t length, + picoquic_call_back_event_t event, void *ctx, + void *stream_ctx) +{ + (void)cnx; (void)stream_id; (void)bytes; (void)length; (void)event; + (void)ctx; (void)stream_ctx; + return 0; +} + /* Drive one client connection to readiness, then keep pumping a short while so a * post-handshake NEW_SESSION_TICKET is received. Returns 0 when ready. */ static int drive(picoquic_quic_t *quic, picoquic_cnx_t *cnx, int fd, @@ -138,7 +150,7 @@ int main(void) snprintf(ticket_file, sizeof(ticket_file), "moq_0rtt_tickets_%d.bin", (int)getpid()); (void)unlink(ticket_file); - picoquic_quic_t *cq = picoquic_create(2, NULL, NULL, NULL, NULL, NULL, NULL, + picoquic_quic_t *cq = picoquic_create(2, NULL, NULL, NULL, NULL, accept_all_cb, NULL, NULL, NULL, NULL, now, NULL, ticket_file, NULL, 0); CHECK(cq != NULL); diff --git a/adapters/picoquic/tests/test_threaded_quiet_receive.c b/adapters/picoquic/tests/test_threaded_quiet_receive.c index a05c8cb3..2b2122de 100644 --- a/adapters/picoquic/tests/test_threaded_quiet_receive.c +++ b/adapters/picoquic/tests/test_threaded_quiet_receive.c @@ -332,7 +332,7 @@ static void test_quiet_held_deadline(void) const picoquic_tp_t *current_tp = picoquic_get_transport_parameters(cnx, 1); HOLD_REQUIRE(current_tp != NULL); picoquic_tp_t tp = *current_tp; - tp.initial_max_stream_id_unidir = BRIDGE_DEFAULT_MAX_STREAMS; + tp.initial_max_streams_uni = BRIDGE_DEFAULT_MAX_STREAMS; tp.initial_max_stream_data_uni = 1024; picoquic_set_transport_parameters(cnx, &tp); diff --git a/adapters/picoquic/tests/test_threaded_terminal_controls.c b/adapters/picoquic/tests/test_threaded_terminal_controls.c index 09110f14..226fe414 100644 --- a/adapters/picoquic/tests/test_threaded_terminal_controls.c +++ b/adapters/picoquic/tests/test_threaded_terminal_controls.c @@ -665,7 +665,7 @@ static int cli_fatal_pump(moq_pq_threaded_t *t, moq_pq_threaded_lane_t *lane, if (!cnx) return 0; picoquic_tp_t tp = *picoquic_get_transport_parameters(cnx, 1); - tp.initial_max_stream_id_unidir += 1; + tp.initial_max_streams_uni += 1; picoquic_set_transport_parameters(cnx, &tp); __atomic_store_n(&cf->tampered, 1, __ATOMIC_RELEASE); return 0; diff --git a/cmake/FindPicoquic.cmake b/cmake/FindPicoquic.cmake index 047bcf2a..ce50b872 100644 --- a/cmake/FindPicoquic.cmake +++ b/cmake/FindPicoquic.cmake @@ -892,7 +892,7 @@ if(MOQ_PICOQUIC_SOURCE_DIR) # The provider's own edges are used as declared: picoquic-log links # picoquic-core, picoquic-test links picoquic-log, and picoquic-core # needs nothing from picoquic-log. That holds for the pinned source - # baseline (picoquic 70b5fd5), whose core no longer calls the log + # baseline (picoquic 36f49b7), whose core no longer calls the log # library. Automatic accommodation of the older core/log cycle (e.g. # 55b473e2, whose core calls picoquic_set_qlog) is retired, and there # is no configure-time capability check. Consumers of such a source diff --git a/patches/picoquic/0001-use-declared-project-version.patch b/patches/picoquic/0001-use-declared-project-version.patch index ffd41d4c..c19797d9 100644 --- a/patches/picoquic/0001-use-declared-project-version.patch +++ b/patches/picoquic/0001-use-declared-project-version.patch @@ -1,6 +1,6 @@ Keep the declared project version in source archives and subproject builds. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2. +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58. The parent may not be a Git checkout, and its revision is not picoquic's. The package configuration and version files use project()'s version, and @@ -9,10 +9,10 @@ Tests: tests/cmake/PicoquicVersionMetadata.cmake (CTest picoquic_version_metadata), in archive and subproject modes. diff --git a/CMakeLists.txt b/CMakeLists.txt -index a7d2c346..b92d95fe 100644 +index 23ef4492..8de91bfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -863,14 +863,9 @@ install(FILES +@@ -876,14 +876,9 @@ install(FILES include(CMakePackageConfigHelpers) @@ -30,7 +30,7 @@ index a7d2c346..b92d95fe 100644 message(STATUS "Project version: ${PROJECT_VERSION}") if (NOT CMAKE_INSTALL_LIBDIR) -@@ -881,7 +876,7 @@ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of head +@@ -894,7 +889,7 @@ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of head set(INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/patches/picoquic/0002-deduplicate-link-libraries.patch b/patches/picoquic/0002-deduplicate-link-libraries.patch index a3279c70..a6a17bb2 100644 --- a/patches/picoquic/0002-deduplicate-link-libraries.patch +++ b/patches/picoquic/0002-deduplicate-link-libraries.patch @@ -1,6 +1,6 @@ De-duplicate libraries on link lines where the linker does not need repeats. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001. +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001. picoquic's targets list the same static archives more than once, and Apple's linker warns about each repeat. CMake 3.29 and later (policy CMP0156, set NEW when available) drop repeats @@ -9,7 +9,7 @@ Tests: adapters/picoquic's source-mode link policy check (picoquic_source_mode_link_policy). diff --git a/CMakeLists.txt b/CMakeLists.txt -index a7d2c346..37456ec2 100644 +index 8de91bfd..4971158f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,10 @@ diff --git a/patches/picoquic/0003-align-stream-reset-stop-and-credit.patch b/patches/picoquic/0003-align-stream-reset-stop-and-credit.patch index e58f3eb9..d992685b 100644 --- a/patches/picoquic/0003-align-stream-reset-stop-and-credit.patch +++ b/patches/picoquic/0003-align-stream-reset-stop-and-credit.patch @@ -1,6 +1,6 @@ Align stream reset, stop, credit and direct-receive handling with RFC 9000. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 and +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 and 0002. Eight related topics, retaining the existing regression coverage: @@ -39,6 +39,15 @@ The upstream reset_at_end acknowledged-FIN row expects the retained ALREADY_CLOSED refusal and checks context preservation without preventing its later reliable-size cases from running. +Since upstream 6152f9e6, a connection without a callback no longer queues +in-order data: picoquic replaces a NULL callback with one that refuses every +event. The direct-receive tests therefore queue a stream's data and FIN +behind a missing first byte, which their application does not need, instead +of receiving them with no callback. The queued data is kept in upstream's +cached first stream segment (83cd9728), and a queued close check is unlinked +with the stream in picoquic_stream_node_delete, which upstream (9fb927c8) now +gives the connection. + Tests (picoquic_ct): reset_at_end, stream_reset_after_fin, reset_after_fin_wire, stream_reset_prefix_retirement, reset_stream_at_reliable_size, stream_reset_at_prefix_delivery, stream_empty_frame_ack, @@ -49,10 +58,10 @@ adapters/picoquic/tests/test_pq_reset_after_fin.c and test_pq_provider_stream_credit.c. diff --git a/UnitTest1/unittest1.cpp b/UnitTest1/unittest1.cpp -index 7bccfd8b..efc6262d 100644 +index 7b584ff1..4075be2f 100644 --- a/UnitTest1/unittest1.cpp +++ b/UnitTest1/unittest1.cpp -@@ -544,6 +544,13 @@ namespace UnitTest1 +@@ -551,6 +551,13 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -66,7 +75,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(stop_sending_needs_repeat) { int ret = stop_sending_needs_repeat_test(); -@@ -551,6 +558,13 @@ namespace UnitTest1 +@@ -558,6 +565,13 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -80,7 +89,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(stream_invalid_id) { int ret = stream_invalid_id_test(); -@@ -565,6 +579,13 @@ namespace UnitTest1 +@@ -572,6 +586,13 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -94,7 +103,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(queue_multipath_blocked_frames) { int ret = queue_multipath_blocked_frames_test(); -@@ -586,6 +607,13 @@ namespace UnitTest1 +@@ -593,6 +614,13 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -108,7 +117,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(frames_format) { int ret = frames_format_test(); -@@ -607,6 +635,27 @@ namespace UnitTest1 +@@ -614,6 +642,27 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -133,10 +142,10 @@ index 7bccfd8b..efc6262d 100644 + Assert::AreEqual(ret, 0); + } + - TEST_METHOD(test_logger) + TEST_METHOD(null_callback_setters) { - int ret = logger_test(); -@@ -1645,6 +1694,20 @@ namespace UnitTest1 + int ret = null_callback_setters_test(); +@@ -1701,6 +1750,20 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -157,7 +166,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(stop_sending_loss) { int ret = stop_sending_loss_test(); -@@ -3698,6 +3761,18 @@ namespace UnitTest1 +@@ -3794,6 +3857,18 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -176,7 +185,7 @@ index 7bccfd8b..efc6262d 100644 TEST_METHOD(queue_network_input) { int ret = queue_network_input_test(); -@@ -3722,6 +3797,12 @@ namespace UnitTest1 +@@ -3818,6 +3893,12 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -190,7 +199,7 @@ index 7bccfd8b..efc6262d 100644 int ret = address_discovery_test(); diff --git a/picoquic/frames.c b/picoquic/frames.c -index 1bf1106a..b3dcb41b 100644 +index ade0f64a..9e5c8142 100644 --- a/picoquic/frames.c +++ b/picoquic/frames.c @@ -97,7 +97,10 @@ int picoquic_is_stream_acked(picoquic_stream_head_t* stream) @@ -211,7 +220,7 @@ index 1bf1106a..b3dcb41b 100644 { - picoquic_update_max_stream_ID_local(cnx, stream); - - if (cnx->callback_fn != NULL && !stream->reset_signalled) { + if (!stream->reset_signalled) { /* Once the FIN was delivered, the stream is in the terminal "Data Read" state (RFC 9000 3.2): do not signal the reset. */ if (!stream->is_discarded && !stream->fin_signalled) { @@ -301,6 +302,8 @@ void picoquic_signal_stream_reset(picoquic_cnx_t* cnx, picoquic_stream_head_t* s @@ -253,7 +262,7 @@ index 1bf1106a..b3dcb41b 100644 } } return ret; -@@ -1256,18 +1267,41 @@ static void picoquic_stream_data_chunk_callback(picoquic_cnx_t* cnx, picoquic_st +@@ -1260,18 +1271,41 @@ static void picoquic_stream_data_chunk_callback(picoquic_cnx_t* cnx, picoquic_st { picoquic_call_back_event_t fin_now = picoquic_callback_stream_data; int call_back_needed = data_length > 0; @@ -297,15 +306,15 @@ index 1bf1106a..b3dcb41b 100644 } if (call_back_needed && !stream->stop_sending_requested && !stream->is_discarded && -@@ -1284,18 +1318,27 @@ void picoquic_stream_data_callback(picoquic_cnx_t* cnx, picoquic_stream_head_t* +@@ -1288,17 +1322,26 @@ void picoquic_stream_data_callback(picoquic_cnx_t* cnx, picoquic_stream_head_t* { picoquic_stream_data_node_t* data; -- while ((data = (picoquic_stream_data_node_t*)picosplay_first(&stream->stream_data_tree)) != NULL && data->offset <= stream->consumed_offset) { +- while ((data = stream->first_stream_data) != NULL && data->offset <= stream->consumed_offset) { + /* Once the stream is marked direct receive, picoquic_mark_direct_receive_stream + * has passed the rest of the queue to the direct receive callback. */ + while (stream->direct_receive_fn == NULL && -+ (data = (picoquic_stream_data_node_t*)picosplay_first(&stream->stream_data_tree)) != NULL && data->offset <= stream->consumed_offset) { ++ (data = stream->first_stream_data) != NULL && data->offset <= stream->consumed_offset) { size_t start = (size_t)(stream->consumed_offset - data->offset); if (data->length >= start) { size_t data_length = data->length - start; @@ -315,8 +324,7 @@ index 1bf1106a..b3dcb41b 100644 picoquic_stream_data_chunk_callback(cnx, stream, data->bytes + start, data_length); + data->is_being_delivered = 0; } - picosplay_delete_hint(&stream->stream_data_tree, &data->stream_data_node); - cnx->nb_stream_data_nodes--; + picoquic_remove_stream_data_node(cnx, stream, data); } - /* handle the case where the fin frame does not carry any data */ @@ -328,7 +336,7 @@ index 1bf1106a..b3dcb41b 100644 } static int add_chunk_node(picoquic_quic_t * quic, picosplay_tree_t* tree, uint64_t offset, -@@ -1435,7 +1478,6 @@ static int picoquic_stream_network_input(picoquic_cnx_t* cnx, uint64_t stream_id +@@ -1438,7 +1481,6 @@ static int picoquic_stream_network_input(picoquic_cnx_t* cnx, uint64_t stream_id stream->fin_received = 1; should_notify = 1; cnx->latest_receive_time = current_time; @@ -336,7 +344,7 @@ index 1bf1106a..b3dcb41b 100644 } if (new_fin_offset > stream->fin_offset) { -@@ -1450,12 +1492,11 @@ static int picoquic_stream_network_input(picoquic_cnx_t* cnx, uint64_t stream_id +@@ -1453,12 +1495,11 @@ static int picoquic_stream_network_input(picoquic_cnx_t* cnx, uint64_t stream_id if (ret == 0) { if (stream->direct_receive_fn != NULL) { @@ -353,7 +361,7 @@ index 1bf1106a..b3dcb41b 100644 uint64_t err = (ret >= PICOQUIC_ERROR_CLASS) ? PICOQUIC_TRANSPORT_INTERNAL_ERROR : (uint64_t)ret; ret = picoquic_connection_error(cnx, err, 0); } -@@ -3624,8 +3665,13 @@ int picoquic_process_ack_of_stream_frame(picoquic_cnx_t* cnx, uint8_t* bytes, +@@ -3615,8 +3656,13 @@ int picoquic_process_ack_of_stream_frame(picoquic_cnx_t* cnx, uint8_t* bytes, /* record the ack range for the stream */ stream = picoquic_find_stream(cnx, stream_id); if (stream != NULL) { @@ -369,7 +377,7 @@ index 1bf1106a..b3dcb41b 100644 picoquic_delete_stream_if_closed(cnx, stream); } -@@ -4662,12 +4708,32 @@ uint8_t * picoquic_format_max_streams_frame_if_needed(picoquic_cnx_t* cnx, +@@ -4663,12 +4709,32 @@ uint8_t * picoquic_format_max_streams_frame_if_needed(picoquic_cnx_t* cnx, return bytes; } @@ -405,10 +413,10 @@ index 1bf1106a..b3dcb41b 100644 if (stream->fin_sent || stream->reset_sent) { diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index 00477235..bf6f0e0e 100644 +index 424fdecb..713b053c 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -1476,6 +1476,13 @@ void picoquic_notify_destination_unreachable_by_cnxid(picoquic_quic_t* quic, pic +@@ -1473,6 +1473,13 @@ void picoquic_notify_destination_unreachable_by_cnxid(picoquic_quic_t* quic, pic * * If stream data was queued at the time the picoquic_mark_direct_receive_stream * function is called, the callback will be activated immediately. @@ -423,10 +431,10 @@ index 00477235..bf6f0e0e 100644 * The callback function shall return: * - 0 if the data was processed normally. diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h -index 12804694..0634832b 100644 +index bbaee5c4..f2d2b054 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h -@@ -317,6 +317,7 @@ typedef struct st_picoquic_stream_data_node_t { +@@ -314,6 +314,7 @@ typedef struct st_picoquic_stream_data_node_t { uint64_t offset; /* Stream offset of the first octet in "bytes" */ size_t length; /* Number of octets in "bytes" */ const uint8_t* bytes; @@ -434,7 +442,7 @@ index 12804694..0634832b 100644 uint8_t data[PICOQUIC_MAX_PACKET_SIZE]; } picoquic_stream_data_node_t; -@@ -782,6 +783,9 @@ typedef struct st_picoquic_stream_head_t { +@@ -779,6 +780,9 @@ typedef struct st_picoquic_stream_head_t { void * app_stream_ctx; picoquic_stream_direct_receive_fn direct_receive_fn; /* direct receive function, if not NULL */ void* direct_receive_ctx; /* direct receive context */ @@ -444,7 +452,7 @@ index 12804694..0634832b 100644 picoquic_sack_list_t sack_list; /* Track which parts of the stream were acknowledged by the peer */ /* Stream priority -- lowest is most urgent. * The stream priority should only be modified through the `picoquic_set_stream_priority` API. -@@ -810,6 +814,8 @@ typedef struct st_picoquic_stream_head_t { +@@ -807,6 +811,8 @@ typedef struct st_picoquic_stream_head_t { unsigned int is_discarded : 1; /* There should be no more callback for that stream, the application has discarded it */ unsigned int use_app_flow_control : 1; /* Do not automatically increment the flow control window, wait for app calls. */ unsigned int is_not_coalesced : 1; /* do not mix data for this stream with data from other stream in same packet */ @@ -453,7 +461,7 @@ index 12804694..0634832b 100644 } picoquic_stream_head_t; #define IS_CLIENT_STREAM_ID(id) (unsigned int)(((id) & 1) == 0) -@@ -1499,6 +1505,11 @@ typedef struct st_picoquic_cnx_t { +@@ -1504,6 +1510,11 @@ typedef struct st_picoquic_cnx_t { /* Management of streams */ picosplay_tree_t stream_tree; uint64_t nb_stream_data_nodes; /* Sum of stream_data_tree.size over all data streams */ @@ -465,7 +473,7 @@ index 12804694..0634832b 100644 picoquic_output_stream_t output_streams; uint64_t high_priority_stream_id; uint64_t next_stream_id[4]; -@@ -1980,6 +1991,10 @@ uint8_t* picoquic_format_reset_stream_frame(picoquic_stream_head_t* stream, +@@ -2002,6 +2013,10 @@ uint8_t* picoquic_format_reset_stream_frame(picoquic_stream_head_t* stream, uint8_t* picoquic_format_reset_stream_at_frame(picoquic_stream_head_t* stream, uint8_t* bytes, uint8_t* bytes_max, int* more_data, int* is_pure_ack); void picoquic_update_max_stream_ID_local(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream); @@ -477,10 +485,10 @@ index 12804694..0634832b 100644 /* Handling of retransmission of frames. * When a packet is deemed lost, the code looks at the frames that it contained and diff --git a/picoquic/sender.c b/picoquic/sender.c -index b3c065da..0167a9c3 100644 +index 3c929f29..bedd032e 100644 --- a/picoquic/sender.c +++ b/picoquic/sender.c -@@ -3617,6 +3617,9 @@ int picoquic_prepare_packet_ex(picoquic_cnx_t* cnx, +@@ -3630,6 +3630,9 @@ int picoquic_prepare_packet_ex(picoquic_cnx_t* cnx, uint64_t next_wake_time; int ret; PICOQUIC_THREAD_CHECK(cnx->quic); @@ -490,7 +498,7 @@ index b3c065da..0167a9c3 100644 ret = picoquic_handle_send_timers(cnx, current_time, &next_wake_time); *send_length = 0; -@@ -3832,6 +3835,11 @@ int picoquic_prepare_packet_ex(picoquic_cnx_t* cnx, +@@ -3845,6 +3848,11 @@ int picoquic_prepare_packet_ex(picoquic_cnx_t* cnx, ret = picoquic_program_app_wake_time(cnx, &next_wake_time); } @@ -503,10 +511,10 @@ index b3c065da..0167a9c3 100644 return ret; diff --git a/picoquic/streams.c b/picoquic/streams.c -index b85a8897..088c3d4d 100644 +index 8ec8e35e..033fa70a 100644 --- a/picoquic/streams.c +++ b/picoquic/streams.c -@@ -89,6 +89,7 @@ picoquic_stream_data_node_t* picoquic_stream_data_node_alloc(picoquic_quic_t* qu +@@ -102,6 +102,7 @@ picoquic_stream_data_node_t* picoquic_stream_data_node_alloc(picoquic_quic_t* qu quic->p_first_data_node = stream_data->next_stream_data; stream_data->next_stream_data = NULL; stream_data->bytes = NULL; @@ -514,18 +522,18 @@ index b85a8897..088c3d4d 100644 quic->nb_data_nodes_in_pool--; } -@@ -130,6 +131,10 @@ void picoquic_clear_stream(picoquic_stream_head_t* stream) - if (stream->is_output_stream) { - picoquic_remove_output_stream(stream->cnx, stream); - } +@@ -154,6 +155,10 @@ static void picoquic_stream_node_delete(void* tree, picosplay_node_t* node) + /* Only application streams are counted and scheduled for output. */ + cnx->nb_stream_data_nodes -= (uint64_t)stream->stream_data_tree.size; + picoquic_remove_output_stream(cnx, stream); + if (stream->is_close_check_queued) { + /* Only application streams are queued; the embedded TLS streams never are. */ -+ picoquic_dequeue_stream_close_check(stream->cnx, stream); ++ picoquic_dequeue_stream_close_check(cnx, stream); + } - picosplay_empty_tree(&stream->stream_data_tree); - picoquic_sack_list_free(&stream->sack_list); - } -@@ -455,21 +460,30 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, + picoquic_clear_stream(stream); + + free(stream); +@@ -467,21 +472,30 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, if (reliable_size > 0 && !cnx->is_reset_stream_at_enabled) { ret = PICOQUIC_ERROR_ILLEGAL_TRANSPORT_EXTENSION; } @@ -560,7 +568,7 @@ index b85a8897..088c3d4d 100644 stream->reliable_size = reliable_size; stream->local_error = local_stream_error; stream->reset_requested = 1; -@@ -530,18 +544,23 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, +@@ -542,18 +556,23 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream = NULL; PICOQUIC_THREAD_CHECK(cnx->quic); @@ -591,7 +599,7 @@ index b85a8897..088c3d4d 100644 uint8_t buffer[128]; uint8_t* bytes; int more_data = 0; -@@ -958,6 +977,80 @@ void picoquic_delete_stream(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream) +@@ -969,6 +988,80 @@ void picoquic_delete_stream(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream) picosplay_delete(&cnx->stream_tree, stream); } @@ -661,7 +669,7 @@ index b85a8897..088c3d4d 100644 +/* First queued node of the stream whose bytes are not with an application callback. */ +static picoquic_stream_data_node_t* picoquic_first_undelivered_stream_data(picoquic_stream_head_t* stream) +{ -+ picoquic_stream_data_node_t* data = (picoquic_stream_data_node_t*)picosplay_first(&stream->stream_data_tree); ++ picoquic_stream_data_node_t* data = stream->first_stream_data; + + while (data != NULL && data->is_being_delivered) { + data = (picoquic_stream_data_node_t*)picosplay_next(&data->stream_data_node); @@ -672,7 +680,7 @@ index b85a8897..088c3d4d 100644 int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, picoquic_stream_direct_receive_fn direct_receive_fn, void* direct_receive_ctx) { int ret = 0; -@@ -975,11 +1068,21 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, +@@ -986,11 +1079,21 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, /* This is illegal! */ ret = PICOQUIC_ERROR_NO_CALLBACK_PROVIDED; } @@ -688,7 +696,7 @@ index b85a8897..088c3d4d 100644 stream->direct_receive_fn = direct_receive_fn; stream->direct_receive_ctx = direct_receive_ctx; - /* If there is pending data, pass it. */ -- while ((data = (picoquic_stream_data_node_t*)picosplay_first(&stream->stream_data_tree)) != NULL) { +- while ((data = stream->first_stream_data) != NULL) { + /* If there is pending data, pass it. A node whose bytes are already + * with an application callback stays with the loop that passed them: + * that loop deletes it when the callback returns. */ @@ -696,7 +704,7 @@ index b85a8897..088c3d4d 100644 size_t length = data->length; uint64_t offset = data->offset; -@@ -995,7 +1098,12 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, +@@ -1006,7 +1109,12 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, } if (length > 0) { @@ -710,7 +718,7 @@ index b85a8897..088c3d4d 100644 } if (ret == 0) { -@@ -1012,7 +1120,15 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, +@@ -1022,7 +1130,15 @@ int picoquic_mark_direct_receive_stream(picoquic_cnx_t* cnx, uint64_t stream_id, /* If there is a fin offset, pass it. */ if (ret == 0 && stream->fin_received && !stream->fin_signalled) { uint8_t fin_bytes[8]; @@ -728,10 +736,10 @@ index b85a8897..088c3d4d 100644 } diff --git a/picoquic_t/picoquic_t.c b/picoquic_t/picoquic_t.c -index 9c9cb9e4..6ab43d96 100644 +index cc21be7f..f77dd44c 100644 --- a/picoquic_t/picoquic_t.c +++ b/picoquic_t/picoquic_t.c -@@ -186,15 +186,22 @@ static const picoquic_test_def_t test_table[] = { +@@ -187,16 +187,23 @@ static const picoquic_test_def_t test_table[] = { { "frames_ackof_error", frames_ackof_error_test }, { "reset_stream_at_needs_repeat", reset_stream_at_needs_repeat_test }, { "process_ack_of_reset_stream_at", process_ack_of_reset_stream_at_test }, @@ -748,13 +756,14 @@ index 9c9cb9e4..6ab43d96 100644 { "frames_format", frames_format_test }, { "flow_control_check_stream_offset", flow_control_check_stream_offset_test }, { "signal_stream_reset", signal_stream_reset_test }, + { "null_callback_setters", null_callback_setters_test }, + { "stream_credit_receive_complete", stream_credit_receive_complete_test }, + { "stream_direct_receive_handover", stream_direct_receive_handover_test }, + { "stream_reset_at_prefix_delivery", stream_reset_at_prefix_delivery_test }, { "logger", logger_test }, { "binlog", binlog_test }, { "binlog_compare_mismatch", binlog_compare_mismatch_test }, -@@ -355,6 +362,8 @@ static const picoquic_test_def_t test_table[] = { +@@ -364,6 +371,8 @@ static const picoquic_test_def_t test_table[] = { { "zero_rtt", zero_rtt_test }, { "zero_rtt_loss", zero_rtt_loss_test }, { "stop_sending", stop_sending_test }, @@ -763,7 +772,7 @@ index 9c9cb9e4..6ab43d96 100644 { "stop_sending_loss", stop_sending_loss_test }, { "discard_stream", discard_stream_test }, { "unidir", unidir_test }, -@@ -667,10 +676,13 @@ static const picoquic_test_def_t test_table[] = { +@@ -682,10 +691,13 @@ static const picoquic_test_def_t test_table[] = { { "scone_prepare_format_failure", scone_prepare_format_failure_test }, { "scone_report_guards", scone_report_guards_test }, { "stream_ack", stream_ack_test }, @@ -778,7 +787,7 @@ index 9c9cb9e4..6ab43d96 100644 { "af_undef", af_undef_test }, { "app_limit_cc", app_limit_cc_test }, diff --git a/picoquictest/edge_cases.c b/picoquictest/edge_cases.c -index 01c0aadf..1f27458a 100644 +index 0d0afee9..3d11594e 100644 --- a/picoquictest/edge_cases.c +++ b/picoquictest/edge_cases.c @@ -1392,6 +1392,7 @@ int reset_at_end_test(void) @@ -812,10 +821,10 @@ index 01c0aadf..1f27458a 100644 /* Reset stream at, with a reliable size equal to or below the last offset. */ if (ret == 0 && (ret = reset_at_end_prepare(cnx, 16, 0)) == 0 && diff --git a/picoquictest/picoquictest.h b/picoquictest/picoquictest.h -index c20c01d5..a1e110d9 100644 +index a07d7652..a8186add 100644 --- a/picoquictest/picoquictest.h +++ b/picoquictest/picoquictest.h -@@ -168,6 +168,7 @@ int ticket_key_rotation_test(void); +@@ -175,6 +175,7 @@ int ticket_key_rotation_test(void); int zero_rtt_test(void); int zero_rtt_loss_test(void); int stop_sending_test(void); @@ -823,7 +832,7 @@ index c20c01d5..a1e110d9 100644 int stop_sending_loss_test(void); int discard_stream_test(void); int unidir_test(void); -@@ -234,15 +235,23 @@ int observed_address_ack_after_path_deleted_test(void); +@@ -242,16 +243,24 @@ int observed_address_ack_after_path_deleted_test(void); int frames_ackof_error_test(void); int reset_stream_at_needs_repeat_test(void); int process_ack_of_reset_stream_at_test(void); @@ -841,13 +850,14 @@ index c20c01d5..a1e110d9 100644 int frames_format_test(void); int flow_control_check_stream_offset_test(void); int signal_stream_reset_test(void); + int null_callback_setters_test(void); +int stream_credit_receive_complete_test(void); +int stream_direct_receive_handover_test(void); +int stream_reset_at_prefix_delivery_test(void); int stress_test(void); int cnx_stress_unit_test(void); int cnx_stress_do_test(uint64_t duration, int nb_clients, int do_report); -@@ -580,6 +589,8 @@ int scone_format_packet_too_small_test(void); +@@ -592,6 +601,8 @@ int scone_format_packet_too_small_test(void); int scone_prepare_format_failure_test(void); int scone_report_guards_test(void); int stream_ack_test(void); @@ -856,7 +866,7 @@ index c20c01d5..a1e110d9 100644 int queue_network_input_test(void); int fastcc_test(void); int fastcc_jitter_test(void); -@@ -639,6 +650,7 @@ int connection_drop_test(void); +@@ -655,6 +666,7 @@ int connection_drop_test(void); int pacing_update_test(void); int quality_update_test(void); int direct_receive_test(void); @@ -865,10 +875,10 @@ index c20c01d5..a1e110d9 100644 int af_undef_test(void); int app_limit_cc_test(void); diff --git a/picoquictest/skip_frame_test.c b/picoquictest/skip_frame_test.c -index 003e83aa..e037435d 100644 +index c925d7d4..827cff77 100644 --- a/picoquictest/skip_frame_test.c +++ b/picoquictest/skip_frame_test.c -@@ -1899,6 +1899,91 @@ int process_ack_of_reset_stream_at_test(void) +@@ -1907,6 +1907,91 @@ int process_ack_of_reset_stream_at_test(void) return ret; } @@ -898,7 +908,7 @@ index 003e83aa..e037435d 100644 +{ + int ret = 0; + uint64_t simulated_time = 0; -+ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, ++ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, + NULL, NULL, NULL, NULL, simulated_time, + &simulated_time, NULL, NULL, 0); + struct sockaddr_in saddr = { 0 }; @@ -960,7 +970,7 @@ index 003e83aa..e037435d 100644 int picoquic_check_stop_sending_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes, size_t bytes_size, int* no_need_to_repeat); /* picoquic_check_stop_sending_needs_repeat has a "stream closed by peer" branch, reached -@@ -2083,6 +2168,282 @@ picoquic_cnx_t * frames_format_test_get_cnx(picoquic_quic_t * qclient, struct so +@@ -2091,6 +2176,282 @@ picoquic_cnx_t * frames_format_test_get_cnx(picoquic_quic_t * qclient, struct so return cnx; } @@ -1243,7 +1253,7 @@ index 003e83aa..e037435d 100644 /* Several public stream-mutation APIs share the same "stream not found" error path: * picoquic_find_stream returns NULL, and the function returns PICOQUIC_ERROR_INVALID_STREAM_ID * without touching anything else. None of them were ever exercised with a stream_id that -@@ -2200,6 +2561,241 @@ int stream_never_called_apis_test(void) +@@ -2208,6 +2569,241 @@ int stream_never_called_apis_test(void) return ret; } @@ -1485,7 +1495,16 @@ index 003e83aa..e037435d 100644 /* picoquic_queue_paths_blocked_frame and picoquic_queue_path_cid_blocked_frame are not * called from any production code path yet -- the trigger logic for when to send these * multipath frames is a separate design question. Exercise them directly here so the -@@ -2451,9 +3047,157 @@ int picoquic_flow_control_check_stream_offset(picoquic_cnx_t* cnx, picoquic_stre +@@ -2284,7 +2880,7 @@ int quicctx_never_called_apis_test(void) + { + int ret = 0; + uint64_t simulated_time = 0; +- picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, ++ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, simulated_time, + &simulated_time, NULL, NULL, 0); + struct sockaddr_in saddr = { 0 }; +@@ -2459,7 +3055,155 @@ int picoquic_flow_control_check_stream_offset(picoquic_cnx_t* cnx, picoquic_stre uint64_t new_fin_offset); void picoquic_signal_stream_reset(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream); @@ -1501,8 +1520,7 @@ index 003e83aa..e037435d 100644 +static int reset_prefix_test_cb(picoquic_cnx_t* UNUSED(cnx), uint64_t UNUSED(stream_id), + uint8_t* UNUSED(bytes), size_t UNUSED(length), + picoquic_call_back_event_t UNUSED(fin_or_event), void* UNUSED(callback_ctx), void* UNUSED(v_stream_ctx)) - { -- int ret = 0; ++{ + return 0; +} + @@ -1640,18 +1658,18 @@ index 003e83aa..e037435d 100644 +} + +int frames_format_test(void) -+{ -+ int ret = 0; + { + int ret = 0; uint8_t buffer[PICOQUIC_MAX_PACKET_SIZE]; - uint8_t data[] = { 0xaa, 0xaa }; - uint8_t* bytes = NULL; -@@ -2563,229 +3307,1396 @@ int frames_format_test(void) - return ret; - } - --/* picoquic never sends past a limit its peer advertised, so a picoquic-to-picoquic exchange -- * never reaches either violation branch below -- exercise both directly instead. */ --int flow_control_check_stream_offset_test(void) +@@ -2567,214 +3311,1383 @@ int frames_format_test(void) + if (qclient != NULL) { + picoquic_free(qclient); + } +- ++ ++ return ret; ++} ++ +/* picoquic never sends past a limit its peer advertised, so a picoquic-to-picoquic exchange + * never reaches either violation branch below -- exercise both directly instead. */ +int flow_control_check_stream_offset_test(void) @@ -1659,7 +1677,7 @@ index 003e83aa..e037435d 100644 + int ret = 0; + uint64_t simulated_time = 0; + uint8_t data[] = { 0xaa, 0xaa }; -+ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, ++ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, + NULL, NULL, NULL, NULL, simulated_time, + &simulated_time, NULL, NULL, 0); + struct sockaddr_in saddr = { 0 }; @@ -1921,15 +1939,15 @@ index 003e83aa..e037435d 100644 + return ret; +} + -+/* picoquic_signal_stream_reset has branches no other test reaches: no callback registered, a -+ * redundant second signal on an already-signalled stream, offset_received not exceeding the -+ * unconsumed delta, and the callback returning an error -- exercise all four directly. */ ++/* picoquic_signal_stream_reset has branches no other test reaches: a redundant second signal ++ * on an already-signalled stream, offset_received not exceeding the unconsumed delta, and the ++ * callback returning an error -- exercise all three directly. */ +int signal_stream_reset_test(void) +{ + int ret = 0; + uint64_t simulated_time = 0; + uint8_t data[] = { 0xaa, 0xaa, 0xaa, 0xaa }; -+ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, ++ picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, + NULL, NULL, NULL, NULL, simulated_time, + &simulated_time, NULL, NULL, 0); + struct sockaddr_in saddr = { 0 }; @@ -1974,25 +1992,6 @@ index 003e83aa..e037435d 100644 + } + + if (ret == 0) { -+ /* Nothing happens at all if the connection has no callback registered. */ -+ picoquic_add_to_stream(cnx, 4, data, sizeof(data), 0); -+ stream = picoquic_find_stream(cnx, 4); -+ if (stream == NULL) { -+ ret = -1; -+ } -+ else { -+ picoquic_stream_data_cb_fn saved_cb = cnx->callback_fn; -+ cnx->callback_fn = NULL; -+ signal_stream_reset_test_nb_reset_calls = 0; -+ picoquic_signal_stream_reset(cnx, stream); -+ cnx->callback_fn = saved_cb; -+ if (stream->reset_signalled || signal_stream_reset_test_nb_reset_calls != 0) { -+ ret = -1; -+ } -+ } -+ } -+ -+ if (ret == 0) { + /* offset_received not greater than the unconsumed delta: it must be left unchanged. */ + picoquic_add_to_stream(cnx, 8, data, sizeof(data), 0); + stream = picoquic_find_stream(cnx, 8); @@ -2480,7 +2479,7 @@ index 003e83aa..e037435d 100644 + int is_pure_ack = 1; + uint64_t max_streams = 0; + -+ cnx->local_parameters.initial_max_stream_id_unidir = 2; ++ cnx->local_parameters.initial_max_streams_uni = 2; + cnx->max_streams_unidir_local = 2; + + if (stream_credit_test_stream(cnx, 3, 0, 4, 0, simulated_time) != 0 || @@ -2626,32 +2625,55 @@ index 003e83aa..e037435d 100644 + ret = STREAM_HANDOVER_TEST_REFUSAL; + } + } -+ return ret; -+} -+ + return ret; + } + +-/* picoquic never sends past a limit its peer advertised, so a picoquic-to-picoquic exchange +- * never reaches either violation branch below -- exercise both directly instead. */ +-int flow_control_check_stream_offset_test(void) +/* The replacement direct receive callback: same completion rule, own counts. */ +static int stream_handover_test_direct_fn2(picoquic_cnx_t* UNUSED(cnx), uint64_t UNUSED(stream_id), int fin, + const uint8_t* UNUSED(bytes), uint64_t offset, size_t length, void* direct_receive_ctx) -+{ + { + stream_handover_test_ctx_t* ctx; -+ int ret = 0; -+ + int ret = 0; +- uint64_t simulated_time = 0; +- uint8_t data[] = { 0xaa, 0xaa }; +- picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, +- NULL, NULL, NULL, NULL, simulated_time, +- &simulated_time, NULL, NULL, 0); +- struct sockaddr_in saddr = { 0 }; +- picoquic_cnx_t* cnx = NULL; +- picoquic_stream_head_t* stream = NULL; + +- if (qclient == NULL) { +- ret = -1; + if (*(uint32_t*)direct_receive_ctx == STREAM_HANDOVER_TEST_SECOND_MAGIC) { + ctx = ((stream_handover_test_second_t*)direct_receive_ctx)->main; -+ } -+ else { + } + else { +- cnx = frames_format_test_get_cnx(qclient, (struct sockaddr*)&saddr, picoquic_epoch_1rtt, simulated_time, 0); +- if (cnx == NULL) { +- ret = -1; +- } + /* Called with the first callback's context: the replacement context was not installed. */ + ctx = (stream_handover_test_ctx_t*)direct_receive_ctx; + ctx->direct2_wrong_ctx++; -+ } -+ + } + +- if (ret == 0) { +- picoquic_add_to_stream(cnx, 0, data, 2, 0); +- stream = picoquic_find_stream(cnx, 0); +- if (stream == NULL) { +- ret = -1; +- } + ctx->direct2_calls++; + ctx->direct2_bytes += length; + if (fin) { + ctx->direct2_fins++; + ctx->direct_fin_received = 1; + ctx->direct_final_size = offset + length; -+ } + } + if (offset <= ctx->direct_next_offset && offset + length > ctx->direct_next_offset) { + ctx->direct_next_offset = offset + length; + } @@ -2660,13 +2682,22 @@ index 003e83aa..e037435d 100644 + } + return ret; +} -+ + +- if (ret == 0) { +- /* Baseline: within both limits, so the offset is accepted and accounting is updated. */ +- stream->maxdata_local = 1000; +- stream->fin_offset = 0; +- cnx->maxdata_local = 1000; +- cnx->offset_received = 0; +static int stream_handover_test_cb(picoquic_cnx_t* cnx, uint64_t stream_id, + uint8_t* UNUSED(bytes), size_t length, + picoquic_call_back_event_t fin_or_event, void* callback_ctx, void* UNUSED(v_stream_ctx)) +{ + stream_handover_test_ctx_t* ctx = (stream_handover_test_ctx_t*)callback_ctx; -+ + +- if (picoquic_flow_control_check_stream_offset(cnx, stream, 100) != 0 || +- stream->fin_offset != 100 || cnx->offset_received != 100) { +- ret = -1; + if (stream_id == ctx->stream_id && + (fin_or_event == picoquic_callback_stream_data || fin_or_event == picoquic_callback_stream_fin)) { + ctx->ordinary_data_calls++; @@ -2678,18 +2709,25 @@ index 003e83aa..e037435d 100644 + /* The direct receive callback continues after the bytes delivered so far. */ + ctx->direct_next_offset = ctx->ordinary_bytes; + ctx->mark_ret = picoquic_mark_direct_receive_stream(cnx, stream_id, stream_handover_test_direct_fn, ctx); -+ } -+ } + } + } + return 0; +} -+ + +- if (ret == 0) { +- /* Per-stream limit exceeded: new_fin_offset > stream->maxdata_local. */ +- stream->maxdata_local = 500; +- cnx->cnx_state = picoquic_state_ready; +- cnx->local_error = 0; +/* Every node in the free list appears once. A node recycled twice links to + * itself, so the walk does not end within the recorded count. */ +static int stream_handover_test_pool_ok(picoquic_quic_t* quic) +{ + int nb_nodes = 0; + picoquic_stream_data_node_t* node = quic->p_first_data_node; -+ + +- if (picoquic_flow_control_check_stream_offset(cnx, stream, 2000) != PICOQUIC_ERROR_DETECTED || +- cnx->local_error != PICOQUIC_TRANSPORT_FLOW_CONTROL_ERROR) { + while (node != NULL && nb_nodes <= quic->nb_data_nodes_in_pool) { + nb_nodes++; + node = node->next_stream_data; @@ -2721,26 +2759,14 @@ index 003e83aa..e037435d 100644 +} stream_handover_test_case_t; + +static int stream_handover_test_one(stream_handover_test_case_t const* tc) - { - int ret = 0; - uint64_t simulated_time = 0; -- uint8_t data[] = { 0xaa, 0xaa }; -- picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, -- NULL, NULL, NULL, NULL, simulated_time, -- &simulated_time, NULL, NULL, 0); - struct sockaddr_in saddr = { 0 }; ++{ ++ int ret = 0; ++ uint64_t simulated_time = 0; ++ struct sockaddr_in saddr = { 0 }; + stream_handover_test_ctx_t ctx = { 0 }; + picoquic_quic_t* quic = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, simulated_time, &simulated_time, NULL, NULL, 0); - picoquic_cnx_t* cnx = NULL; -- picoquic_stream_head_t* stream = NULL; -- -- if (qclient == NULL) { -- ret = -1; -- } -- else { -- cnx = frames_format_test_get_cnx(qclient, (struct sockaddr*)&saddr, picoquic_epoch_1rtt, simulated_time, 0); -- if (cnx == NULL) { ++ picoquic_cnx_t* cnx = NULL; + int pool_ok = 0; + + if (quic == NULL || @@ -2769,60 +2795,33 @@ index 003e83aa..e037435d 100644 } if (ret == 0) { -- picoquic_add_to_stream(cnx, 0, data, 2, 0); -- stream = picoquic_find_stream(cnx, 0); -- if (stream == NULL) { +- /* Under the per-stream limit but over the connection-wide limit -- the overflow-safe subtraction arm. */ +- stream->maxdata_local = 1000000; +- stream->fin_offset = 100; +- cnx->maxdata_local = 200; +- cnx->offset_received = 150; +- cnx->cnx_state = picoquic_state_ready; +- cnx->local_error = 0; +- +- if (picoquic_flow_control_check_stream_offset(cnx, stream, 250) != PICOQUIC_ERROR_DETECTED || +- cnx->local_error != PICOQUIC_TRANSPORT_FLOW_CONTROL_ERROR) { + if (ctx.ordinary_data_calls != tc->ordinary_data_calls || ctx.ordinary_bytes != tc->ordinary_bytes || + ctx.ordinary_fins != tc->ordinary_fins) { + DBG_PRINTF("Stream handover, %s: ordinary callback got %d calls, %" PRIu64 " bytes, %d FIN\n", + tc->name, ctx.ordinary_data_calls, ctx.ordinary_bytes, ctx.ordinary_fins); - ret = -1; - } -- } -- -- if (ret == 0) { -- /* Baseline: within both limits, so the offset is accepted and accounting is updated. */ -- stream->maxdata_local = 1000; -- stream->fin_offset = 0; -- cnx->maxdata_local = 1000; -- cnx->offset_received = 0; -- -- if (picoquic_flow_control_check_stream_offset(cnx, stream, 100) != 0 || -- stream->fin_offset != 100 || cnx->offset_received != 100) { ++ ret = -1; ++ } + if (ctx.direct_calls != tc->direct_calls || ctx.direct_bytes != tc->direct_bytes || + ctx.direct_fins != tc->direct_fins) { + DBG_PRINTF("Stream handover, %s: direct callback got %d calls, %" PRIu64 " bytes, %d FIN\n", + tc->name, ctx.direct_calls, ctx.direct_bytes, ctx.direct_fins); - ret = -1; - } -- } -- -- if (ret == 0) { -- /* Per-stream limit exceeded: new_fin_offset > stream->maxdata_local. */ -- stream->maxdata_local = 500; -- cnx->cnx_state = picoquic_state_ready; -- cnx->local_error = 0; -- -- if (picoquic_flow_control_check_stream_offset(cnx, stream, 2000) != PICOQUIC_ERROR_DETECTED || -- cnx->local_error != PICOQUIC_TRANSPORT_FLOW_CONTROL_ERROR) { ++ ret = -1; ++ } + if (tc->mark_on_data_call != 0 && + ctx.mark_ret != ((tc->direct_refuses) ? STREAM_HANDOVER_TEST_REFUSAL : 0)) { + DBG_PRINTF("Stream handover, %s: mark returned 0x%x\n", tc->name, ctx.mark_ret); - ret = -1; - } -- } -- -- if (ret == 0) { -- /* Under the per-stream limit but over the connection-wide limit -- the overflow-safe subtraction arm. */ -- stream->maxdata_local = 1000000; -- stream->fin_offset = 100; -- cnx->maxdata_local = 200; -- cnx->offset_received = 150; -- cnx->cnx_state = picoquic_state_ready; -- cnx->local_error = 0; -- -- if (picoquic_flow_control_check_stream_offset(cnx, stream, 250) != PICOQUIC_ERROR_DETECTED || -- cnx->local_error != PICOQUIC_TRANSPORT_FLOW_CONTROL_ERROR) { ++ ret = -1; ++ } + if (cnx->max_streams_unidir_local_computed != (uint64_t)tc->counted) { + DBG_PRINTF("Stream handover, %s: counted %" PRIu64 ", expected %d\n", tc->name, + cnx->max_streams_unidir_local_computed, tc->counted); @@ -2898,9 +2897,9 @@ index 003e83aa..e037435d 100644 return ret; } --/* picoquic_signal_stream_reset has branches no other test reaches: no callback registered, a -- * redundant second signal on an already-signalled stream, offset_received not exceeding the -- * unconsumed delta, and the callback returning an error -- exercise all four directly. */ +-/* picoquic_signal_stream_reset has branches no other test reaches: a redundant second signal +- * on an already-signalled stream, offset_received not exceeding the unconsumed delta, and the +- * callback returning an error -- exercise all three directly. */ -int signal_stream_reset_test(void) +/* A stream completed by a marking outside any callback is queued for a close + * check; deleting the connection before any preparation unlinks it, and the @@ -2910,7 +2909,7 @@ index 003e83aa..e037435d 100644 int ret = 0; uint64_t simulated_time = 0; - uint8_t data[] = { 0xaa, 0xaa, 0xaa, 0xaa }; -- picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, +- picoquic_quic_t* qclient = picoquic_create(8, NULL, NULL, NULL, NULL, picoquic_test_permissive_callback, - NULL, NULL, NULL, NULL, simulated_time, - &simulated_time, NULL, NULL, 0); struct sockaddr_in saddr = { 0 }; @@ -2928,18 +2927,20 @@ index 003e83aa..e037435d 100644 + } + return -1; + } -+ /* Without a callback, the data and the FIN stay queued. */ ++ /* The first byte is missing, so the rest of the data and the FIN stay ++ * queued. The application needs the stream only from that byte on. */ + ctx.stream_id = 3; + ctx.magic = STREAM_HANDOVER_TEST_MAIN_MAGIC; + ctx.second.magic = STREAM_HANDOVER_TEST_SECOND_MAGIC; + ctx.second.main = &ctx; -+ if (stream_credit_test_stream(cnx, 3, 0, 4, 1, simulated_time) != 0) { ++ ctx.direct_next_offset = 1; ++ picoquic_set_callback(cnx, stream_handover_test_cb, &ctx); ++ if (stream_credit_test_stream(cnx, 3, 1, 3, 1, simulated_time) != 0) { ret = -1; } else { - cnx = frames_format_test_get_cnx(qclient, (struct sockaddr*)&saddr, picoquic_epoch_1rtt, simulated_time, 0); - if (cnx == NULL) { -+ picoquic_set_callback(cnx, stream_handover_test_cb, &ctx); + if (picoquic_mark_direct_receive_stream(cnx, 3, stream_handover_test_direct_fn, &ctx) != 0 || + ctx.direct_fins != 1 || cnx->nb_close_checks != 1 || picoquic_find_stream(cnx, 3) == NULL) { + DBG_PRINTF("Stream handover, teardown with a queued stream: %d FIN, %" PRIu64 " queued\n", @@ -2984,23 +2985,20 @@ index 003e83aa..e037435d 100644 +} - if (ret == 0) { -- /* Nothing happens at all if the connection has no callback registered. */ -- picoquic_add_to_stream(cnx, 4, data, sizeof(data), 0); -- stream = picoquic_find_stream(cnx, 4); +- /* offset_received not greater than the unconsumed delta: it must be left unchanged. */ +- picoquic_add_to_stream(cnx, 8, data, sizeof(data), 0); +- stream = picoquic_find_stream(cnx, 8); - if (stream == NULL) { - ret = -1; - } - else { -- picoquic_stream_data_cb_fn saved_cb = cnx->callback_fn; -- cnx->callback_fn = NULL; +- stream->consumed_offset = 100; +- stream->fin_offset = 500; +- cnx->offset_received = 300; /* <= delta (400), so no decrement should happen */ - signal_stream_reset_test_nb_reset_calls = 0; - picoquic_signal_stream_reset(cnx, stream); -- cnx->callback_fn = saved_cb; -- if (stream->reset_signalled || signal_stream_reset_test_nb_reset_calls != 0) { -- ret = -1; -- } -- } -- } +- if (cnx->offset_received != 300 || !stream->reset_signalled || +- signal_stream_reset_test_nb_reset_calls != 1) { +/* A direct receive callback replaces itself while the stream is being passed + * to it. The rest of the stream, and the FIN, reach the new callback once; + * the result of the call that replaced the callback, completion or refusal, @@ -3034,22 +3032,7 @@ index 003e83aa..e037435d 100644 + picoquic_quic_t* quic = picoquic_create(8, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, simulated_time, &simulated_time, NULL, NULL, 0); + picoquic_cnx_t* cnx = NULL; - -- if (ret == 0) { -- /* offset_received not greater than the unconsumed delta: it must be left unchanged. */ -- picoquic_add_to_stream(cnx, 8, data, sizeof(data), 0); -- stream = picoquic_find_stream(cnx, 8); -- if (stream == NULL) { -- ret = -1; -- } -- else { -- stream->consumed_offset = 100; -- stream->fin_offset = 500; -- cnx->offset_received = 300; /* <= delta (400), so no decrement should happen */ -- signal_stream_reset_test_nb_reset_calls = 0; -- picoquic_signal_stream_reset(cnx, stream); -- if (cnx->offset_received != 300 || !stream->reset_signalled || -- signal_stream_reset_test_nb_reset_calls != 1) { ++ + if (quic == NULL || + (cnx = frames_format_test_get_cnx(quic, (struct sockaddr*)&saddr, picoquic_epoch_1rtt, simulated_time, 0)) == NULL) { + if (quic != NULL) { @@ -3209,7 +3192,7 @@ index 003e83aa..e037435d 100644 return ret; } -@@ -5338,3 +7249,75 @@ int stream_ack_test(void) +@@ -5409,3 +7322,75 @@ int stream_ack_test(void) return ret; } @@ -3286,10 +3269,10 @@ index 003e83aa..e037435d 100644 + return ret; +} diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c -index 2ff052e1..56734184 100644 +index 9e1f19ed..07ac2766 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c -@@ -5188,6 +5188,272 @@ int discard_stream_test(void) +@@ -5242,6 +5242,272 @@ int discard_stream_test(void) return ret; } @@ -3562,18 +3545,20 @@ index 2ff052e1..56734184 100644 /* * MTU discovery tests. Perform a moderate transmission. * Verify that MTU was properly set to expected value, -@@ -12383,6 +12649,529 @@ int direct_receive_test(void) +@@ -12438,6 +12704,546 @@ int direct_receive_test(void) return ret; } +/* A stream whose receive half completes while the application marks it as + * direct receive is retired at the next packet preparation, through either + * public preparation API, without another incoming packet. Each scenario -+ * runs on its own connection. The client has no callback while the peer's -+ * data arrives, so the data and the FIN are still queued when the stream is -+ * marked. */ ++ * runs on its own connection. The first byte of the peer's data is missing, ++ * so the rest of the data and the FIN are still queued when the stream is ++ * marked; the application needs the stream only from that missing byte on. */ + +#define CLOSE_CHECK_TEST_MAX_STREAM_ID 16 ++/* The application needs each stream from this offset: the byte before it is missing. */ ++#define CLOSE_CHECK_TEST_FIRST_OFFSET 1 + +typedef struct st_close_check_test_ctx_t { + uint64_t released[CLOSE_CHECK_TEST_MAX_STREAM_ID]; @@ -3601,6 +3586,9 @@ index 2ff052e1..56734184 100644 + int ret = 0; + + if (stream_id < CLOSE_CHECK_TEST_MAX_STREAM_ID) { ++ if (ctx->next_offset[stream_id] < CLOSE_CHECK_TEST_FIRST_OFFSET) { ++ ctx->next_offset[stream_id] = CLOSE_CHECK_TEST_FIRST_OFFSET; ++ } + if (fin) { + ctx->fin_received[stream_id] = 1; + ctx->final_size[stream_id] = offset + length; @@ -3670,30 +3658,42 @@ index 2ff052e1..56734184 100644 + return ret; +} + -+/* The server sends length bytes on stream_id, with or without FIN, while the -+ * client has no callback: the client queues them without delivering them. */ ++/* The peer's STREAM frame for bytes CLOSE_CHECK_TEST_FIRST_OFFSET to length of ++ * stream_id, with or without FIN, reaches the client, while the frame for the ++ * bytes before it does not: the client queues the data without delivering it. ++ * The frame is passed to the client directly, so that no repeat of the missing ++ * bytes follows. A peer bidirectional stream is opened on the server, which ++ * then accepts the client's data on it. */ +static int close_check_test_queue_peer_data(picoquic_test_tls_api_ctx_t* test_ctx, uint64_t* simulated_time, + uint64_t stream_id, size_t length, int fin) +{ -+ uint8_t data[256]; ++ uint8_t buffer[512]; ++ uint8_t* bytes = buffer; ++ uint8_t* bytes_max = buffer + sizeof(buffer); ++ uint8_t frame_type = (uint8_t)(picoquic_frame_type_stream_range_min | 0x04 | 0x02 | ((fin) ? 0x01 : 0)); ++ size_t data_length = length - CLOSE_CHECK_TEST_FIRST_OFFSET; ++ picoquic_cnx_t* cnx = test_ctx->cnx_client; ++ picoquic_stream_head_t* stream; + int ret = 0; -+ int is_queued = 0; + -+ memset(data, 0x5a, sizeof(data)); -+ picoquic_set_callback(test_ctx->cnx_client, NULL, NULL); -+ if (length > sizeof(data) || picoquic_add_to_stream(test_ctx->cnx_server, stream_id, data, length, fin) != 0) { ++ if (length <= CLOSE_CHECK_TEST_FIRST_OFFSET || ++ (IS_BIDIR_STREAM_ID(stream_id) && picoquic_set_app_stream_ctx(test_ctx->cnx_server, stream_id, NULL) != 0) || ++ (bytes = picoquic_frames_uint8_encode(bytes, bytes_max, frame_type)) == NULL || ++ (bytes = picoquic_frames_varint_encode(bytes, bytes_max, stream_id)) == NULL || ++ (bytes = picoquic_frames_varint_encode(bytes, bytes_max, CLOSE_CHECK_TEST_FIRST_OFFSET)) == NULL || ++ (bytes = picoquic_frames_varint_encode(bytes, bytes_max, data_length)) == NULL || ++ data_length > (size_t)(bytes_max - bytes)) { + ret = -1; + } -+ for (int i = 0; ret == 0 && !is_queued && i < 200; i++) { -+ int was_active = 0; -+ picoquic_stream_head_t* stream; -+ -+ ret = tls_api_one_sim_round(test_ctx, simulated_time, 0, &was_active); -+ stream = picoquic_find_stream(test_ctx->cnx_client, stream_id); -+ is_queued = (stream != NULL && stream->fin_offset == length && (!fin || stream->fin_received) && -+ stream->consumed_offset == 0 && stream->stream_data_tree.size > 0); ++ else { ++ memset(bytes, 0x5a, data_length); ++ bytes += data_length; ++ ret = picoquic_decode_frames(cnx, cnx->path[0], buffer, bytes - buffer, NULL, picoquic_epoch_1rtt, ++ NULL, NULL, 0, 0, NULL, *simulated_time); + } -+ if (ret == 0 && !is_queued) { ++ stream = picoquic_find_stream(cnx, stream_id); ++ if (ret != 0 || cnx->local_error != 0 || stream == NULL || stream->fin_offset != length || ++ (fin && !stream->fin_received) || stream->consumed_offset != 0 || stream->stream_data_tree.size == 0) { + DBG_PRINTF("Close check, data for stream %" PRIu64 " not queued on the client\n", stream_id); + ret = -1; + } diff --git a/patches/picoquic/0004-stateless-reset-lookup.patch b/patches/picoquic/0004-stateless-reset-lookup.patch index 1da34de6..a37ad367 100644 --- a/patches/picoquic/0004-stateless-reset-lookup.patch +++ b/patches/picoquic/0004-stateless-reset-lookup.patch @@ -1,6 +1,6 @@ Look up a stateless reset without processing the datagram. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0003. RFC 9000 Section 10.3.1 has an endpoint compare a datagram's last 16 bytes @@ -20,7 +20,9 @@ current_time, &detection) performs only that comparison, against the match. The comparison is constant time on every platform. - The registered pair is refreshed whenever the default path's first tuple changes, including the path-0 replacement when a multipath path is - abandoned, so the lookup finds the token in use. + abandoned, so the lookup finds the token in use. Upstream promotes a + verified or NAT-rebound tuple through picoquic_promote_tuple_to_default, + which re-registers it. Ordinary ingress keeps its convention: picoquic_incoming_stateless_reset applies the same reset and returns PICOQUIC_ERROR_AEAD_CHECK. @@ -30,10 +32,10 @@ stateless_reset_detect_rotated and stateless_reset_detect_abandon. In LibMoQ: the threaded_lane_group_reset_* rows. diff --git a/UnitTest1/unittest1.cpp b/UnitTest1/unittest1.cpp -index d5ad9bbc..22cdd2f8 100644 +index 4075be2f..cf018450 100644 --- a/UnitTest1/unittest1.cpp +++ b/UnitTest1/unittest1.cpp -@@ -1360,6 +1360,48 @@ namespace UnitTest1 +@@ -1448,6 +1448,48 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -82,23 +84,11 @@ index d5ad9bbc..22cdd2f8 100644 TEST_METHOD(immediate_close) { int ret = immediate_close_test(); -diff --git a/picoquic/frames.c b/picoquic/frames.c -index 7017c855..a4634b28 100644 ---- a/picoquic/frames.c -+++ b/picoquic/frames.c -@@ -5069,6 +5069,7 @@ const uint8_t* picoquic_decode_path_response_frame(picoquic_cnx_t* cnx, const ui - picoquic_log_app_message(cnx, "Migration to server preferred address successful on path %" PRIu64, path_x->unique_path_id); - } - picoquic_reset_path_mtu(path_x); -+ picoquic_register_net_secret_for_path(cnx, path_x); - } - if (cnx->are_path_callbacks_enabled && cnx->callback_fn != NULL && - cnx->callback_fn(cnx, path_x->unique_path_id, NULL, 0, picoquic_callback_path_available, diff --git a/picoquic/packet.c b/picoquic/packet.c -index 17addf71..eb2a4f1b 100644 +index 436e2097..8dea0d8e 100644 --- a/picoquic/packet.c +++ b/picoquic/packet.c -@@ -1823,22 +1823,71 @@ int picoquic_incoming_client_handshake( +@@ -1823,20 +1823,71 @@ int picoquic_incoming_client_handshake( /* * Processing of stateless reset packet. @@ -119,11 +109,12 @@ index 17addf71..eb2a4f1b 100644 if (cnx->cnx_state <= picoquic_state_ready) { cnx->remote_error = PICOQUIC_ERROR_STATELESS_RESET; } -+ cnx->cnx_state = picoquic_state_disconnected; - if (cnx->callback_fn) { - (void)(cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_stateless_reset, cnx->callback_ctx, NULL); - } +- (void)(cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_stateless_reset, cnx->callback_ctx, NULL); - picoquic_connection_disconnect(cnx); ++ cnx->cnx_state = picoquic_state_disconnected; ++ if (cnx->callback_fn) { ++ (void)(cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_stateless_reset, cnx->callback_ctx, NULL); ++ } + if (cnx->callback_fn) { + (void)(cnx->callback_fn)(cnx, 0, NULL, 0, picoquic_callback_close, cnx->callback_ctx, NULL); + } @@ -174,7 +165,7 @@ index 17addf71..eb2a4f1b 100644 * Processing of 0-RTT packet */ diff --git a/picoquic/paths.c b/picoquic/paths.c -index b42142ee..1f86b361 100644 +index 04fc653d..1e84b305 100644 --- a/picoquic/paths.c +++ b/picoquic/paths.c @@ -79,6 +79,7 @@ void picoquic_set_tuple_challenge_failed(picoquic_path_t* path_x, picoquic_tuple @@ -185,11 +176,19 @@ index b42142ee..1f86b361 100644 } /* picoquic_check_tuple_challenge_expired: +@@ -905,6 +906,7 @@ void picoquic_promote_tuple_to_default( + picoquic_log_app_message(path_x->cnx, "Migration to server preferred address successful on path %" PRIu64, path_x->unique_path_id); + } + picoquic_reset_path_mtu(path_x); ++ picoquic_register_net_secret_for_path(path_x->cnx, path_x); + if (is_new_address) { + picoquic_reset_path_congestion(path_x->cnx, path_x, current_time); + } diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index 83a408c8..65148739 100644 +index 713b053c..1fd8d543 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -1402,6 +1402,44 @@ int picoquic_incoming_packet_ex( +@@ -1400,6 +1400,44 @@ int picoquic_incoming_packet_ex( picoquic_cnx_t** first_cnx, uint64_t current_time); @@ -235,10 +234,10 @@ index 83a408c8..65148739 100644 * next packet that will be set over the network. The API for that is * picoquic_prepare_next_packet", which operates on a "quic context". diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h -index 55b6766d..75c4a143 100644 +index f2d2b054..5994572e 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h -@@ -1613,6 +1613,7 @@ int picoquic_register_cnx_id(picoquic_quic_t* quic, picoquic_cnx_t* cnx, picoqui +@@ -1628,6 +1628,7 @@ int picoquic_register_cnx_id(picoquic_quic_t* quic, picoquic_cnx_t* cnx, picoqui /* Register or update default address and reset secret */ int picoquic_register_net_secret(picoquic_cnx_t* cnx); @@ -247,7 +246,7 @@ index 55b6766d..75c4a143 100644 /* Registration of initial connection ID and peer IP */ int picoquic_register_net_icid(picoquic_cnx_t* cnx); diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c -index 6de0f739..3aaf7e1f 100644 +index 11196215..da2462b8 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c @@ -363,11 +363,8 @@ static int picoquic_net_secret_compare(const void* key1, const void* key2) @@ -263,7 +262,7 @@ index 6de0f739..3aaf7e1f 100644 } return ret; } -@@ -1410,6 +1407,20 @@ int picoquic_register_net_secret(picoquic_cnx_t* cnx) +@@ -1435,6 +1432,20 @@ int picoquic_register_net_secret(picoquic_cnx_t* cnx) return ret; } @@ -284,7 +283,7 @@ index 6de0f739..3aaf7e1f 100644 void picoquic_init_transport_parameters(picoquic_tp_t* tp) { memset(tp, 0, sizeof(picoquic_tp_t)); -@@ -1857,6 +1868,7 @@ void picoquic_unchain_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple) +@@ -1868,6 +1879,7 @@ void picoquic_unchain_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple) void picoquic_delete_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple, int is_deleting_path) { @@ -292,7 +291,7 @@ index 6de0f739..3aaf7e1f 100644 /* TODO: dereference local CID, retire remote CID ??? */ /* Dereference the remote CID */ if (tuple->p_remote_cnxid != NULL) { -@@ -1864,6 +1876,10 @@ void picoquic_delete_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple, int +@@ -1875,6 +1887,10 @@ void picoquic_delete_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple, int } /* Remove from chain to the path */ picoquic_unchain_tuple(path_x, tuple); @@ -303,7 +302,7 @@ index 6de0f739..3aaf7e1f 100644 /* And finally free */ free(tuple); } -@@ -1874,6 +1890,7 @@ void picoquic_set_first_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple) +@@ -1885,6 +1901,7 @@ void picoquic_set_first_tuple(picoquic_path_t* path_x, picoquic_tuple_t* tuple) picoquic_unchain_tuple(path_x, tuple); path_x->first_tuple = tuple; tuple->next_tuple = old_first; @@ -311,7 +310,7 @@ index 6de0f739..3aaf7e1f 100644 } /* Set default interface -- to call just after creating a connection context */ -@@ -2185,6 +2202,8 @@ void picoquic_demote_path(picoquic_cnx_t* cnx, int path_index, uint64_t current_ +@@ -2210,6 +2227,8 @@ void picoquic_demote_path(picoquic_cnx_t* cnx, int path_index, uint64_t current_ cnx->path[0] = cnx->path[alt_path0]; cnx->path[alt_path0] = path_x; path_index = alt_path0; @@ -321,10 +320,10 @@ index 6de0f739..3aaf7e1f 100644 else { can_demote = 0; diff --git a/picoquic_t/picoquic_t.c b/picoquic_t/picoquic_t.c -index c65a0618..21a7fba3 100644 +index f77dd44c..a76c85d3 100644 --- a/picoquic_t/picoquic_t.c +++ b/picoquic_t/picoquic_t.c -@@ -313,6 +313,12 @@ static const picoquic_test_def_t test_table[] = { +@@ -327,6 +327,12 @@ static const picoquic_test_def_t test_table[] = { { "stateless_reset_bad", stateless_reset_bad_test }, { "stateless_reset_client", stateless_reset_client_test }, { "stateless_reset_handshake", stateless_reset_handshake_test }, @@ -338,10 +337,10 @@ index c65a0618..21a7fba3 100644 { "tls_api_very_long_stream", tls_api_very_long_stream_test }, { "tls_api_very_long_max", tls_api_very_long_max_test }, diff --git a/picoquictest/multipath_test.c b/picoquictest/multipath_test.c -index 9ba2c170..de1aade1 100644 +index b2c0e135..b75088e7 100644 --- a/picoquictest/multipath_test.c +++ b/picoquictest/multipath_test.c -@@ -2704,3 +2704,247 @@ int multipath_cid_retire_test(void) +@@ -3500,3 +3500,247 @@ int multipath_idle_rotation_test(void) * * TODO: break that into parts that can be verified! */ @@ -590,10 +589,10 @@ index 9ba2c170..de1aade1 100644 + return (ret_old == 0 && ret_new == 0 && ret_other == 0) ? 0 : -1; +} diff --git a/picoquictest/picoquictest.h b/picoquictest/picoquictest.h -index 820b651d..192a2ae9 100644 +index a8186add..e8b4b4ce 100644 --- a/picoquictest/picoquictest.h +++ b/picoquictest/picoquictest.h -@@ -114,6 +114,12 @@ int stateless_reset_test(void); +@@ -119,6 +119,12 @@ int stateless_reset_test(void); int stateless_reset_bad_test(void); int stateless_reset_client_test(void); int stateless_reset_handshake_test(void); @@ -607,10 +606,10 @@ index 820b651d..192a2ae9 100644 int sim_link_test(void); int tls_api_very_long_stream_test(void); diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c -index 49945d44..90db7ef4 100644 +index 07ac2766..e8b50f62 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c -@@ -3683,6 +3683,378 @@ int stateless_reset_handshake_test(void) +@@ -3737,6 +3737,378 @@ int stateless_reset_handshake_test(void) return ret; } diff --git a/patches/picoquic/0005-own-application-close-reason.patch b/patches/picoquic/0005-own-application-close-reason.patch index da9e218e..53bebb37 100644 --- a/patches/picoquic/0005-own-application-close-reason.patch +++ b/patches/picoquic/0005-own-application-close-reason.patch @@ -1,6 +1,6 @@ Retain accepted application-close reasons for the entire connection lifetime. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0004. Allocation failure leaves the connection unchanged. The capability macro @@ -9,10 +9,10 @@ external providers. Tests: adapters/picoquic/tests/test_pq_close_reason{,_oom}.c. diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index 65148739..4a11b966 100644 +index 1fd8d543..753d00d5 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -1040,6 +1040,10 @@ int picoquic_start_client_cnx(picoquic_cnx_t* cnx); +@@ -1038,6 +1038,10 @@ int picoquic_start_client_cnx(picoquic_cnx_t* cnx); */ int picoquic_close(picoquic_cnx_t* cnx, uint64_t application_reason_code); @@ -24,10 +24,10 @@ index 65148739..4a11b966 100644 void picoquic_close_immediate(picoquic_cnx_t* cnx); diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h -index 75c4a143..54c474e5 100644 +index 5994572e..615fc4c4 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h -@@ -1375,6 +1375,7 @@ typedef struct st_picoquic_cnx_t { +@@ -1386,6 +1386,7 @@ typedef struct st_picoquic_cnx_t { uint64_t application_error; uint64_t local_error; char const * local_error_reason; @@ -36,10 +36,10 @@ index 75c4a143..54c474e5 100644 uint64_t remote_error; uint64_t offending_frame_type; diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c -index 3aaf7e1f..2c84a945 100644 +index da2462b8..bfc6a1bc 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c -@@ -4955,6 +4955,9 @@ void picoquic_delete_cnx(picoquic_cnx_t* cnx) +@@ -5108,6 +5108,9 @@ void picoquic_delete_cnx(picoquic_cnx_t* cnx) picoquic_unregister_net_icid(cnx); picoquic_unregister_net_secret(cnx); @@ -50,10 +50,10 @@ index 3aaf7e1f..2c84a945 100644 } } diff --git a/picoquic/sender.c b/picoquic/sender.c -index bfaba67d..6545ae01 100644 +index bedd032e..67f2f5cc 100644 --- a/picoquic/sender.c +++ b/picoquic/sender.c -@@ -3861,6 +3861,18 @@ int picoquic_close(picoquic_cnx_t* cnx, uint64_t application_reason_code) +@@ -3879,6 +3879,18 @@ int picoquic_close(picoquic_cnx_t* cnx, uint64_t application_reason_code) int picoquic_close_ex(picoquic_cnx_t* cnx, uint64_t application_reason_code, char const* error_reason) { int ret = 0; @@ -72,7 +72,7 @@ index bfaba67d..6545ae01 100644 uint64_t current_time = picoquic_get_quic_time(cnx->quic); if (cnx->cnx_state == picoquic_state_ready || -@@ -3876,7 +3888,9 @@ int picoquic_close_ex(picoquic_cnx_t* cnx, uint64_t application_reason_code, cha +@@ -3894,7 +3906,9 @@ int picoquic_close_ex(picoquic_cnx_t* cnx, uint64_t application_reason_code, cha } if (ret == 0) { diff --git a/patches/picoquic/0006-stream-terminal-observation.patch b/patches/picoquic/0006-stream-terminal-observation.patch index 00261226..4b6eca5c 100644 --- a/patches/picoquic/0006-stream-terminal-observation.patch +++ b/patches/picoquic/0006-stream-terminal-observation.patch @@ -1,6 +1,6 @@ Observe exact STOP and opted-in local UNI byte+FIN ACK. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0005. Preserve callback values; append a successful send-commit event. Observation @@ -26,10 +26,10 @@ Tests: adapters/picoquic/tests/test_pq_terminal.c in LibMoQ, with separate constructed-state and deterministic native packet rows. diff --git a/picohttp/h3zero_common.c b/picohttp/h3zero_common.c -index 05443f80..9adc9f04 100644 +index eb05f42d..dd73fe6c 100644 --- a/picohttp/h3zero_common.c +++ b/picohttp/h3zero_common.c -@@ -2066,6 +2066,22 @@ int h3zero_callback(picoquic_cnx_t* cnx, +@@ -2084,6 +2084,22 @@ int h3zero_callback(picoquic_cnx_t* cnx, } } break; @@ -53,15 +53,15 @@ index 05443f80..9adc9f04 100644 case picoquic_callback_close: /* Received connection close */ case picoquic_callback_application_close: /* Received application close */ diff --git a/picohttp/h3zero_common.h b/picohttp/h3zero_common.h -index 0fcfe31b..aad842c7 100644 +index adc3a271..f8094bf0 100644 --- a/picohttp/h3zero_common.h +++ b/picohttp/h3zero_common.h -@@ -51,7 +51,11 @@ extern "C" { - picohttp_callback_stop_sending, /* Peer asking to reset the stream. */ +@@ -52,7 +52,11 @@ extern "C" { picohttp_callback_deregister, /* Context has been deregistered */ picohttp_callback_free, -- picohttp_callback_drain /* Peer initiated graceful WebTransport drain. */ -+ picohttp_callback_drain, /* Peer initiated graceful WebTransport drain. */ + picohttp_callback_drain, /* Peer initiated graceful WebTransport drain. */ +- picohttp_callback_app_wakeup /* Wake up time set by the application has expired. */ ++ picohttp_callback_app_wakeup, /* Wake up time set by the application has expired. */ + /* Opted-in local UNI: bytes+FIN acknowledged, before free. The path + * callback may delete this stream, but must defer deleting the H3 + * context or recursively driving packet processing until return. */ @@ -70,7 +70,7 @@ index 0fcfe31b..aad842c7 100644 struct st_h3zero_callback_ctx_t; diff --git a/picoquic/frames.c b/picoquic/frames.c -index a4634b28..1874a247 100644 +index 9e5c8142..2b58985f 100644 --- a/picoquic/frames.c +++ b/picoquic/frames.c @@ -96,11 +96,13 @@ int picoquic_is_stream_acked(picoquic_stream_head_t* stream) @@ -112,7 +112,7 @@ index a4634b28..1874a247 100644 /* Notify application that the stream is fully retired and any * per-stream app context tied to this stream_id can be freed. * Fired only if the app took ownership (non-NULL ctx). Return -@@ -1134,11 +1149,13 @@ const uint8_t* picoquic_decode_stop_sending_frame(picoquic_cnx_t* cnx, const uin +@@ -1139,11 +1154,13 @@ const uint8_t* picoquic_decode_stop_sending_frame(picoquic_cnx_t* cnx, const uin picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_STREAM_STATE_ERROR, picoquic_frame_type_stop_sending); bytes = NULL; @@ -122,12 +122,12 @@ index a4634b28..1874a247 100644 stream->stop_sending_received = 1; stream->remote_stop_error = error_code; - if (cnx->callback_fn != NULL && !stream->stop_sending_signalled) { + if (!stream->stop_sending_signalled) { + stream->stop_sending_signalled = 1; if (!stream->is_discarded) { if (cnx->callback_fn(cnx, stream->stream_id, NULL, 0, picoquic_callback_stop_sending, cnx->callback_ctx, stream->app_stream_ctx) != 0) { picoquic_log_app_message(cnx, "Stop sending callback on stream %" PRIu64 " returns error 0x%x", -@@ -1147,7 +1164,6 @@ const uint8_t* picoquic_decode_stop_sending_frame(picoquic_cnx_t* cnx, const uin +@@ -1152,7 +1169,6 @@ const uint8_t* picoquic_decode_stop_sending_frame(picoquic_cnx_t* cnx, const uin picoquic_frame_type_stop_sending); } } @@ -136,10 +136,10 @@ index a4634b28..1874a247 100644 } else { /* The stream is already finished. Should just ignore the frame */ diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index 4a11b966..aa29f5a0 100644 +index 753d00d5..5f8e8843 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -425,7 +425,8 @@ typedef enum { +@@ -427,7 +427,8 @@ typedef enum { picoquic_callback_stream_released, /* Stream fully retired: bytes=NULL, len=0, * stream_ctx = the app_stream_ctx the app set; * picoquic will not call back with this stream_ctx again. */ @@ -149,7 +149,7 @@ index 4a11b966..aa29f5a0 100644 } picoquic_call_back_event_t; typedef struct st_picoquic_tp_preferred_address_t { -@@ -1852,6 +1853,30 @@ uint64_t picoquic_get_application_error(picoquic_cnx_t* cnx); +@@ -1860,6 +1861,30 @@ char const* picoquic_get_remote_error_reason(picoquic_cnx_t* cnx); /* Returns the remote error for the given stream. */ uint64_t picoquic_get_remote_stream_error(picoquic_cnx_t* cnx, uint64_t stream_id); @@ -181,10 +181,10 @@ index 4a11b966..aa29f5a0 100644 uint64_t picoquic_get_data_received(picoquic_cnx_t * cnx); diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h -index 54c474e5..c5a81396 100644 +index 615fc4c4..9e2025c7 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h -@@ -815,6 +815,8 @@ typedef struct st_picoquic_stream_head_t { +@@ -813,6 +813,8 @@ typedef struct st_picoquic_stream_head_t { unsigned int is_not_coalesced : 1; /* do not mix data for this stream with data from other stream in same packet */ unsigned int is_close_check_queued : 1; /* The stream is in the connection's close check queue */ unsigned int is_direct_callback_active : 1; /* A direct receive callback of this stream is running */ @@ -194,10 +194,10 @@ index 54c474e5..c5a81396 100644 #define IS_CLIENT_STREAM_ID(id) (unsigned int)(((id) & 1) == 0) diff --git a/picoquic/streams.c b/picoquic/streams.c -index d1dc8e08..9e687675 100644 +index 033fa70a..984bb741 100644 --- a/picoquic/streams.c +++ b/picoquic/streams.c -@@ -450,6 +450,43 @@ static int picoquic_queue_reset_stream_frame(picoquic_cnx_t* cnx, picoquic_strea +@@ -462,6 +462,43 @@ static int picoquic_queue_reset_stream_frame(picoquic_cnx_t* cnx, picoquic_strea return ret; } @@ -241,7 +241,7 @@ index d1dc8e08..9e687675 100644 int picoquic_reset_stream_at(picoquic_cnx_t* cnx, uint64_t stream_id, uint64_t local_stream_error, uint64_t reliable_size) { -@@ -487,6 +524,10 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, +@@ -497,6 +534,10 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, /* Only an accepted reset releases the application context. */ stream->app_stream_ctx = NULL; stream->reliable_size = reliable_size; diff --git a/patches/picoquic/0007-per-thread-public-random.patch b/patches/picoquic/0007-per-thread-public-random.patch index e1ed6d94..82724485 100644 --- a/patches/picoquic/0007-per-thread-public-random.patch +++ b/patches/picoquic/0007-per-thread-public-random.patch @@ -1,6 +1,6 @@ Keep the public random generator's state per thread -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0006. picoquic_public_random_64() and the functions built on it draw from one @@ -39,7 +39,7 @@ draw is provisional and a later provider upgrades it exactly once. A half-created worker pair settles through a barrier abort rather than hanging. diff --git a/UnitTest1/unittest1.cpp b/UnitTest1/unittest1.cpp -index 22cdd2f8..a6d214ef 100644 +index cf018450..4d02d59b 100644 --- a/UnitTest1/unittest1.cpp +++ b/UnitTest1/unittest1.cpp @@ -188,6 +188,13 @@ namespace UnitTest1 @@ -57,10 +57,10 @@ index 22cdd2f8..a6d214ef 100644 { int ret = util_is_path_sane_test(); diff --git a/picoquic/tls_api.c b/picoquic/tls_api.c -index 217f8bd6..754a5c2d 100644 +index 52c2d40b..dfce63e6 100644 --- a/picoquic/tls_api.c +++ b/picoquic/tls_api.c -@@ -1022,49 +1022,112 @@ uint64_t picoquic_crypto_uniform_random(picoquic_quic_t* quic, uint64_t rnd_max) +@@ -985,49 +985,112 @@ uint64_t picoquic_crypto_uniform_random(picoquic_quic_t* quic, uint64_t rnd_max) * generator. The 16 rounds of the xorshift process give a pretty good hash, but * that can probably be broken by linear analysis. Or at least we have no proof * that it cannot be broken. @@ -191,7 +191,7 @@ index 217f8bd6..754a5c2d 100644 } -@@ -1074,7 +1137,7 @@ void picoquic_public_random_seed(picoquic_quic_t* quic) +@@ -1037,7 +1100,7 @@ void picoquic_public_random_seed(picoquic_quic_t* quic) picoquic_crypto_random(quic, &seed, sizeof(seed)); picoquic_public_random_seed_64(seed[0], 0); @@ -201,7 +201,7 @@ index 217f8bd6..754a5c2d 100644 void picoquic_public_random(void* buf, size_t len) diff --git a/picoquic_t/picoquic_t.c b/picoquic_t/picoquic_t.c -index 21a7fba3..68cc9118 100644 +index a76c85d3..001054ca 100644 --- a/picoquic_t/picoquic_t.c +++ b/picoquic_t/picoquic_t.c @@ -125,6 +125,7 @@ static const picoquic_test_def_t test_table[] = { @@ -213,7 +213,7 @@ index 21a7fba3..68cc9118 100644 { "set_addr_port", util_set_addr_port_test }, { "picohash", picohash_test }, diff --git a/picoquictest/picoquictest.h b/picoquictest/picoquictest.h -index 192a2ae9..fc7791b5 100644 +index e8b4b4ce..13ba9aa4 100644 --- a/picoquictest/picoquictest.h +++ b/picoquictest/picoquictest.h @@ -46,6 +46,7 @@ int util_uint8_to_str_test(void); diff --git a/patches/picoquic/0008-classify-terminal-stream-reset-and-stop.patch b/patches/picoquic/0008-classify-terminal-stream-reset-and-stop.patch index 81b3cdd1..6f0b7cae 100644 --- a/patches/picoquic/0008-classify-terminal-stream-reset-and-stop.patch +++ b/patches/picoquic/0008-classify-terminal-stream-reset-and-stop.patch @@ -1,6 +1,6 @@ Classify a reset or stop of a terminal or unknown stream by the ID's state. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0007. 0003 supplies the direction checks and refuses a stop before its context @@ -27,10 +27,10 @@ Tests: adapters/picoquic/tests/test_pq_stop_release.c (reset and stop contract rows) and test_pq_hold_input.c (call order, bounded). diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index a70d08a4..10d10bac 100644 +index 5f8e8843..7a2c29e8 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -1709,6 +1709,17 @@ int picoquic_add_to_stream_with_ctx(picoquic_cnx_t * cnx, uint64_t stream_id, co +@@ -1706,6 +1706,17 @@ int picoquic_add_to_stream_with_ctx(picoquic_cnx_t * cnx, uint64_t stream_id, co * the stream is invalid, e.g., if attempting to reset a stream that was not * yet created. */ @@ -49,10 +49,10 @@ index a70d08a4..10d10bac 100644 uint64_t stream_id, uint64_t local_stream_error); int picoquic_reset_stream_at(picoquic_cnx_t* cnx, diff --git a/picoquic/streams.c b/picoquic/streams.c -index 5bc13867..91a8f799 100644 +index 984bb741..19e5254d 100644 --- a/picoquic/streams.c +++ b/picoquic/streams.c -@@ -497,8 +497,10 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, +@@ -509,8 +509,10 @@ int picoquic_reset_stream_at(picoquic_cnx_t* cnx, if (reliable_size > 0 && !cnx->is_reset_stream_at_enabled) { ret = PICOQUIC_ERROR_ILLEGAL_TRANSPORT_EXTENSION; } @@ -65,7 +65,7 @@ index 5bc13867..91a8f799 100644 * the peer closes the connection on a RESET_STREAM for its send-only * stream (RFC 9000 Section 19.4). */ ret = PICOQUIC_ERROR_INVALID_STREAM_ID; -@@ -585,17 +587,27 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, +@@ -597,17 +599,27 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, picoquic_stream_head_t* stream = NULL; PICOQUIC_THREAD_CHECK(cnx->quic); diff --git a/patches/picoquic/0009-stateless-reset-ingress.patch b/patches/picoquic/0009-stateless-reset-ingress.patch index 93a1d68c..c1d778f5 100644 --- a/patches/picoquic/0009-stateless-reset-ingress.patch +++ b/patches/picoquic/0009-stateless-reset-ingress.patch @@ -1,6 +1,6 @@ Detect stateless resets behind another connection's ID; allow not sending them. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0008. - A packet associated with a connection by its leading bytes but not @@ -24,10 +24,10 @@ through picoquic_incoming_packet. In LibMoQ: adapters/picoquic/tests/test_pq_stateless_reset_contract.c. diff --git a/UnitTest1/unittest1.cpp b/UnitTest1/unittest1.cpp -index a6d214ef..68bf66cc 100644 +index 4d02d59b..918a5336 100644 --- a/UnitTest1/unittest1.cpp +++ b/UnitTest1/unittest1.cpp -@@ -1367,6 +1367,27 @@ namespace UnitTest1 +@@ -1455,6 +1455,27 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -56,7 +56,7 @@ index a6d214ef..68bf66cc 100644 { int ret = stateless_reset_detect_test(); diff --git a/picoquic/packet.c b/picoquic/packet.c -index eb2a4f1b..1c5d5ecb 100644 +index 8dea0d8e..adb6ea94 100644 --- a/picoquic/packet.c +++ b/picoquic/packet.c @@ -833,11 +833,32 @@ int picoquic_parse_header_and_decrypt( @@ -104,10 +104,10 @@ index eb2a4f1b..1c5d5ecb 100644 picoquic_stateless_packet_t* sp = picoquic_create_stateless_packet(quic); if (sp != NULL) { diff --git a/picoquic/picoquic.h b/picoquic/picoquic.h -index 19215218..486c1e2d 100644 +index 7a2c29e8..06a4ff7e 100644 --- a/picoquic/picoquic.h +++ b/picoquic/picoquic.h -@@ -998,6 +998,14 @@ void picoquic_set_default_callback(picoquic_quic_t * quic, picoquic_stream_data_ +@@ -996,6 +996,14 @@ void picoquic_set_default_callback(picoquic_quic_t * quic, picoquic_stream_data_ */ void picoquic_set_default_stateless_reset_min_interval(picoquic_quic_t* quic, uint64_t min_interval_usec); @@ -123,10 +123,10 @@ index 19215218..486c1e2d 100644 * If that number is too high, the maximum number of open files will be hit * at random places in the code. A small value means that some connections may diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h -index c5a81396..ea258b0b 100644 +index 9e2025c7..a161da61 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h -@@ -572,6 +572,7 @@ typedef struct st_picoquic_quic_t { +@@ -571,6 +571,7 @@ typedef struct st_picoquic_quic_t { uint64_t cwin_max; /* max value of cwin per connection */ /* Flags */ unsigned int check_token : 1; @@ -135,10 +135,10 @@ index c5a81396..ea258b0b 100644 unsigned int provide_token : 1; unsigned int unconditional_cnx_id : 1; diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c -index 2c84a945..1e502969 100644 +index bfc6a1bc..801ef6c4 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c -@@ -4542,6 +4542,12 @@ void picoquic_set_default_stateless_reset_min_interval(picoquic_quic_t* quic, ui +@@ -4697,6 +4697,12 @@ void picoquic_set_default_stateless_reset_min_interval(picoquic_quic_t* quic, ui quic->stateless_reset_min_interval = min_interval_usec; } @@ -152,10 +152,10 @@ index 2c84a945..1e502969 100644 picoquic_stream_data_cb_fn callback_fn, void* callback_ctx) { diff --git a/picoquic_t/picoquic_t.c b/picoquic_t/picoquic_t.c -index 68cc9118..a43d12fa 100644 +index 001054ca..a248b70e 100644 --- a/picoquic_t/picoquic_t.c +++ b/picoquic_t/picoquic_t.c -@@ -314,6 +314,9 @@ static const picoquic_test_def_t test_table[] = { +@@ -328,6 +328,9 @@ static const picoquic_test_def_t test_table[] = { { "stateless_reset_bad", stateless_reset_bad_test }, { "stateless_reset_client", stateless_reset_client_test }, { "stateless_reset_handshake", stateless_reset_handshake_test }, @@ -166,10 +166,10 @@ index 68cc9118..a43d12fa 100644 { "stateless_reset_detect_callback", stateless_reset_detect_callback_test }, { "stateless_reset_detect_vn", stateless_reset_detect_vn_test }, diff --git a/picoquictest/picoquictest.h b/picoquictest/picoquictest.h -index fc7791b5..59e05516 100644 +index 13ba9aa4..ccea89bb 100644 --- a/picoquictest/picoquictest.h +++ b/picoquictest/picoquictest.h -@@ -115,6 +115,9 @@ int stateless_reset_test(void); +@@ -120,6 +120,9 @@ int stateless_reset_test(void); int stateless_reset_bad_test(void); int stateless_reset_client_test(void); int stateless_reset_handshake_test(void); @@ -180,10 +180,10 @@ index fc7791b5..59e05516 100644 int stateless_reset_detect_callback_test(void); int stateless_reset_detect_vn_test(void); diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c -index 90db7ef4..9c99827b 100644 +index e8b50f62..4f927cce 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c -@@ -3622,6 +3622,289 @@ int stateless_reset_client_test(void) +@@ -3676,6 +3676,289 @@ int stateless_reset_client_test(void) } diff --git a/patches/picoquic/0010-refuse-stop-after-direct-receive.patch b/patches/picoquic/0010-refuse-stop-after-direct-receive.patch index ca283c6d..75e2caec 100644 --- a/patches/picoquic/0010-refuse-stop-after-direct-receive.patch +++ b/patches/picoquic/0010-refuse-stop-after-direct-receive.patch @@ -1,6 +1,6 @@ Refuse STOP_SENDING for a receive half completed through direct receive. -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0009. Direct receive marks a completed receive half with fin_received and @@ -16,10 +16,10 @@ bidirectional completed streams through both preparation APIs and an incomplete control. diff --git a/picoquic/streams.c b/picoquic/streams.c -index 8e9a25f3..7eefc623 100644 +index 19e5254d..fbeb3744 100644 --- a/picoquic/streams.c +++ b/picoquic/streams.c -@@ -610,11 +610,12 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, +@@ -615,11 +615,12 @@ int picoquic_stop_sending(picoquic_cnx_t* cnx, PICOQUIC_ERROR_STREAM_ALREADY_CLOSED : PICOQUIC_ERROR_INVALID_STREAM_ID; } else if (stream->reset_received || @@ -36,10 +36,10 @@ index 8e9a25f3..7eefc623 100644 } else { diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c -index 9c99827b..bfbe4055 100644 +index 4f927cce..10711fa7 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c -@@ -13043,6 +13043,144 @@ static int close_check_test_teardown_pending(void) +@@ -13867,6 +13867,144 @@ static int close_check_test_teardown_pending(void) return ret; } @@ -184,7 +184,7 @@ index 9c99827b..bfbe4055 100644 int direct_receive_close_check_test(void) { int ret = 0; -@@ -13072,6 +13210,18 @@ int direct_receive_close_check_test(void) +@@ -13896,6 +14034,18 @@ int direct_receive_close_check_test(void) if (close_check_test_teardown_pending() != 0) { ret = -1; } diff --git a/patches/picoquic/0011-serialize-crypto-provider-initialization.patch b/patches/picoquic/0011-serialize-crypto-provider-initialization.patch index 01da1d57..69358226 100644 --- a/patches/picoquic/0011-serialize-crypto-provider-initialization.patch +++ b/patches/picoquic/0011-serialize-crypto-provider-initialization.patch @@ -1,6 +1,6 @@ Serialize loading, unloading and resetting the crypto providers -Applies to picoquic 70b5fd5aafdd2d6c349ff783202ece9d778bcaf2, after 0001 to +Applies to picoquic 36f49b73d532369882d97474ac018655b6739a58, after 0001 to 0010. picoquic_create() loads the crypto providers on first use through @@ -25,7 +25,7 @@ unchanged. The lock does not make an unload or a reset safe while a context exists or is being created: those still require that no other picoquic call is in progress. -Upstream: the 2026-11-02 release (v2026.11.02.b9893f2) still loads the +Upstream: the 2026-11-12 release (v2026.11.12.36f49b7) still loads the providers without synchronization. Test: tls_api_concurrent_init (tls_api_test.c) unloads the providers and @@ -38,10 +38,10 @@ under ThreadSanitizer it reports the races; with the lock it passes and ThreadSanitizer reports none. diff --git a/UnitTest1/unittest1.cpp b/UnitTest1/unittest1.cpp -index e17d6bb..c87a8ee 100644 +index 918a5336..8e7050ed 100644 --- a/UnitTest1/unittest1.cpp +++ b/UnitTest1/unittest1.cpp -@@ -1294,6 +1294,13 @@ namespace UnitTest1 +@@ -1350,6 +1350,13 @@ namespace UnitTest1 Assert::AreEqual(ret, 0); } @@ -56,10 +56,10 @@ index e17d6bb..c87a8ee 100644 { int ret = tls_api_remove_ticket_test(); diff --git a/picoquic/tls_api.c b/picoquic/tls_api.c -index 754a5c2..2fae2b2 100644 +index dfce63e6..cde23c4e 100644 --- a/picoquic/tls_api.c +++ b/picoquic/tls_api.c -@@ -178,6 +178,23 @@ void picoquic_ptls_minicrypto_load(int unload); +@@ -169,6 +169,23 @@ void picoquic_ptls_minicrypto_load(int unload); static uint64_t tls_api_init_flags = 0; static int tls_api_is_init = 0; @@ -83,7 +83,7 @@ index 754a5c2..2fae2b2 100644 /* Initialization of providers. The latest registration wins. * This implies an initialization order from least desirable * to most desirable. -@@ -266,26 +283,31 @@ void picoquic_tls_api_log_versions(picoquic_cnx_t * cnx) +@@ -242,26 +259,31 @@ void picoquic_tls_api_log_versions(picoquic_cnx_t * cnx) void picoquic_tls_api_init(void) { @@ -116,7 +116,7 @@ index 754a5c2..2fae2b2 100644 if (tls_api_is_init) { tls_api_is_init = 0; picoquic_tls_api_init_providers(2); -@@ -294,6 +316,7 @@ void picoquic_tls_api_reset(uint64_t init_flags) +@@ -270,6 +292,7 @@ void picoquic_tls_api_reset(uint64_t init_flags) tls_api_init_flags = init_flags; picoquic_tls_api_init_providers(0); tls_api_is_init = 1; @@ -125,10 +125,10 @@ index 754a5c2..2fae2b2 100644 /* Registration of ciphersuites. * This API is called by crypto providers to register available cipher suites. diff --git a/picoquic_t/picoquic_t.c b/picoquic_t/picoquic_t.c -index 2ba7a0b..93e94f2 100644 +index a248b70e..53f3afa7 100644 --- a/picoquic_t/picoquic_t.c +++ b/picoquic_t/picoquic_t.c -@@ -304,6 +304,7 @@ static const picoquic_test_def_t test_table[] = { +@@ -313,6 +313,7 @@ static const picoquic_test_def_t test_table[] = { { "tls_x25519", tls_x25519_test }, { "tls_x25519mlkem", tls_x25519mlkem_test }, { "tls_api_dispose_certificate_verifier", tls_api_dispose_certificate_verifier_test }, @@ -137,10 +137,10 @@ index 2ba7a0b..93e94f2 100644 { "tls_api_null_arg_checks", tls_api_null_arg_checks_test }, { "tls_api_server_decrypt_short_token", tls_api_server_decrypt_short_token_test }, diff --git a/picoquictest/picoquictest.h b/picoquictest/picoquictest.h -index c97f105..d252294 100644 +index ccea89bb..67882afa 100644 --- a/picoquictest/picoquictest.h +++ b/picoquictest/picoquictest.h -@@ -100,6 +100,7 @@ int tls_api_alpn_test(void); +@@ -105,6 +105,7 @@ int tls_api_alpn_test(void); int tls_x25519_test(void); int tls_x25519mlkem_test(void); int tls_api_dispose_certificate_verifier_test(void); @@ -149,7 +149,7 @@ index c97f105..d252294 100644 int tls_api_null_arg_checks_test(void); int tls_api_server_decrypt_short_token_test(void); diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c -index f7524fd..338ec90 100644 +index 10711fa7..fdd9fe46 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c @@ -32,6 +32,7 @@ @@ -160,13 +160,10 @@ index f7524fd..338ec90 100644 #include "picoquic_binlog.h" #include "csv.h" #include "qlog.h" -@@ -17050,4 +17051,139 @@ int tls_api_verify_retry_protection_short_test(void) - } - - return ret; --} -\ No newline at end of file -+} +@@ -17356,3 +17357,138 @@ int wrong_source_addr_retry_test(void) + { + return wrong_source_addr_test(wrong_addr_retry); + } + +/* Concurrent first use of the crypto providers. + * @@ -179,14 +176,14 @@ index f7524fd..338ec90 100644 +#define TLS_API_CONCURRENT_THREADS 8 + +typedef struct st_tls_api_providers_t { -+ struct st_picoquic_cipher_suites_t cipher_suites[PICOQUIC_CIPHER_SUITES_NB_MAX + 1]; ++ ptls_cipher_suite_t* cipher_suites[PICOQUIC_CIPHER_SUITES_NB_MAX + 1]; + ptls_key_exchange_algorithm_t* key_exchanges[PICOQUIC_KEY_EXCHANGES_NB_MAX + 1]; + picoquic_crypto_random_provider_t random_provider; +} tls_api_providers_t; + +static void tls_api_providers_read(tls_api_providers_t* p) +{ -+ memcpy(p->cipher_suites, picoquic_cipher_suites, sizeof(p->cipher_suites)); ++ memcpy(p->cipher_suites, (void*)picoquic_cipher_suites, sizeof(p->cipher_suites)); + memcpy(p->key_exchanges, (void*)picoquic_key_exchanges, sizeof(p->key_exchanges)); + p->random_provider = picoquic_crypto_random_provider_fn; +} diff --git a/patches/picoquic/README.md b/patches/picoquic/README.md index acf7026a..f7a9588a 100644 --- a/patches/picoquic/README.md +++ b/patches/picoquic/README.md @@ -1,8 +1,8 @@ # Temporary Picoquic Development Patches Owner: LibMoQ maintainers. Base: -[`70b5fd5aafdd2d6c349ff783202ece9d778bcaf2`](https://github.com/private-octopus/picoquic/commit/70b5fd5aafdd2d6c349ff783202ece9d778bcaf2), -released as `v2026.10.22.70b5fd5`. Apply the ordered `series` through +[`36f49b73d532369882d97474ac018655b6739a58`](https://github.com/private-octopus/picoquic/commit/36f49b73d532369882d97474ac018655b6739a58), +released as `v2026.11.12.36f49b7`. Apply the ordered `series` through `scripts/provider_patches.sh` or `scripts/setup_picoquic_deps.sh`. Picotls keeps its separate pin and series. @@ -27,6 +27,14 @@ the feature it protects. Source applicability alone is not runtime qualification - Upstream's suppression of a reset callback after delivered FIN is retained. The reset-after-FIN wire regression already permits that behavior while checking the received reset's final size and error code. +- [Upstream PR2369](https://github.com/private-octopus/picoquic/pull/2369) + (in the selected release) keeps an ACK_FREQUENCY request at or above the + peer's min_ack_delay. No downstream patch implements it; upstream's + `ackfrq_min_delay` test covers it. +- Upstream 6152f9e6 replaces a NULL connection callback with one that refuses + every event, so in-order data is no longer queued for a connection without + a callback. The 0003/0010 direct-receive tests queue data behind a missing + first byte instead; their assertions are unchanged. ## Remaining Removal Conditions diff --git a/scripts/setup_picoquic_deps.sh b/scripts/setup_picoquic_deps.sh index 5a27b86f..c93e65ec 100755 --- a/scripts/setup_picoquic_deps.sh +++ b/scripts/setup_picoquic_deps.sh @@ -72,7 +72,7 @@ set -euo pipefail # -- Pinned, known-good dependency commits ----------------------------- PICOQUIC_REPO="${PICOQUIC_REPO:-https://github.com/private-octopus/picoquic}" -PICOQUIC_REF="${PICOQUIC_REF:-70b5fd5aafdd2d6c349ff783202ece9d778bcaf2}" +PICOQUIC_REF="${PICOQUIC_REF:-36f49b73d532369882d97474ac018655b6739a58}" PICOTLS_REPO="${PICOTLS_REPO:-https://github.com/h2o/picotls.git}" PICOTLS_REF="${PICOTLS_REF:-7f0d38c1c54c920d56b4e13ceb1c2dfa2b1325e1}"