mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-27 03:46:03 -04:00
Enforce isc_work enqueue loop affinity
Add a REQUIRE(isc_loop() == loop) assertion to isc_work_enqueue()
to strictly enforce that work is enqueued from the loop it is
assigned to. This loudly prohibits cross-thread queue manipulation
before it inevitably turns into a concurrency debugging nightmare.
(cherry picked from commit f1311d2d19)
This commit is contained in:
parent
fdd3b36ba3
commit
d4b96af062
2 changed files with 3 additions and 7 deletions
|
|
@ -58,6 +58,7 @@ isc_work_enqueue(isc_loop_t *loop, isc_work_cb work_cb,
|
|||
int r;
|
||||
|
||||
REQUIRE(VALID_LOOP(loop));
|
||||
REQUIRE(isc_loop() == loop);
|
||||
REQUIRE(work_cb != NULL);
|
||||
REQUIRE(after_work_cb != NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,13 +56,8 @@ after_work_cb(void *arg) {
|
|||
}
|
||||
|
||||
static void
|
||||
work_enqueue_cb(void *arg) {
|
||||
UNUSED(arg);
|
||||
uint32_t tid = isc_loopmgr_nloops(loopmgr) - 1;
|
||||
|
||||
isc_loop_t *loop = isc_loop_get(loopmgr, tid);
|
||||
|
||||
isc_work_enqueue(loop, work_cb, after_work_cb, loopmgr);
|
||||
work_enqueue_cb(void *arg ISC_ATTR_UNUSED) {
|
||||
isc_work_enqueue(isc_loop(), work_cb, after_work_cb, NULL);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_work_enqueue) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue