From 6db2c0a111336a24199c0acf4e02635c97f4ff2b Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Wed, 4 Oct 2017 23:03:44 -0500 Subject: [PATCH] Adjust rx-event test to exercise cancel/fire race We currently do not properly handle the case where a thread runs rxevent_Cancel() in parallel with the event-handler thread attempting to fire that event, but the test suite only picked up on this issue in a handful of the Debian automated builds (somewhat less-resourced ones, perhaps). Modify the event scheduling algorithm in the test so as to create a larger chunk of events scheduled to fire "right away" and thereby exercise the race condition more often when we proceed to cancel a quarter of events "right away". Reviewed-on: https://gerrit.openafs.org/12755 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk (cherry picked from commit bdb509fb1d8e0fdca05dffecdbcbf60a95ea502e) Change-Id: I27cebed3c2c3daff10b8d3f5f6f949e667791a72 Reviewed-on: https://gerrit.openafs.org/12774 Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- tests/rx/event-t.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/rx/event-t.c b/tests/rx/event-t.c index 2812fa5bd..c99024654 100644 --- a/tests/rx/event-t.c +++ b/tests/rx/event-t.c @@ -124,10 +124,14 @@ main(void) ok(pthread_create(&handler, NULL, eventHandler, NULL) == 0, "Created handler thread"); - /* Add 1000 random events to fire over the next 3 seconds */ + /* Add 1000 random events to fire over the next 3 seconds, but front-loaded + * a bit so that we can exercise the cancel/fire race path. */ for (counter = 0; counter < NUMEVENTS; counter++) { - when = random() % 3000; + when = random() % 4000; + /* Put 1/4 of events "right away" so we cancel them as they fire */ + if (when >= 3000) + when = random() % 5; clock_GetTime(&now); eventTime = now; clock_Addmsec(&eventTime, when); -- 2.39.5