From 15f9f81b5a8398fefca023e90d8d1c168ecef620 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 30 Oct 2026 23:11:41 +0100 Subject: Introduce a fast path assuming that a tcp connection's payload already has arrived at accept time --- tests/t_event.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/t_event.c b/tests/t_event.c index ad3948f..706a285 100644 --- a/tests/t_event.c +++ b/tests/t_event.c @@ -241,6 +241,28 @@ static void case_close_takes_it_out(void) { pair_close(); } +/* A descriptor can be taken on before anybody waits for anything on it: the + full scrape parks a connection while a worker thread builds the reply. The + mechanisms disagree about what registering nothing means, so what is + checked is that asking for a filter afterwards still works. */ +static void case_add_nothing_then_ask(void) { + test_case("a descriptor added with no interest can be given some later"); + pair_open(); + CHECK(sv[0] != -1); + CHECK_INT(event_add(sv[0], 0, 7), 0); + CHECK_INT((int)write(sv[1], "x", 1), 1); + CHECK_INT(wait_for(sv[0], EVENT_IN, 200, NULL), 0); + + CHECK_INT(event_modify(sv[0], EVENT_IN, 7), 0); + { + uint32_t generation = 0; + CHECK_INT(wait_for(sv[0], EVENT_IN, 500, &generation), 1); + CHECK_INT((int)generation, 7); + } + event_del(sv[0]); + pair_close(); +} + void test_event(void) { CHECK_INT(event_init(), 0); CHECK(event_mechanism() != NULL); @@ -254,6 +276,7 @@ void test_event(void) { case_timeout(); case_unknown_descriptor(); case_close_takes_it_out(); + case_add_nothing_then_ask(); event_deinit(); } -- cgit v1.3