Unlink the timer event before trying to purge it

as far as I can determine the order of operations is not important.

    *** CID 351372:  Concurrent data access violations  (ATOMICITY)
    /lib/isc/timer.c: 227 in timer_purge()
    221     		LOCK(&timer->lock);
    222     		if (!purged) {
    223     			/*
    224     			 * The event has already been executed, but not
    225     			 * yet destroyed.
    226     			 */
    >>>     CID 351372:  Concurrent data access violations  (ATOMICITY)
    >>>     Using an unreliable value of "event" inside the second locked section. If the data that "event" depends on was changed by another thread, this use might be incorrect.
    227     			timerevent_unlink(timer, event);
    228     		}
    229     	}
    230     }
    231
    232     void
This commit is contained in:
Mark Andrews
2022-04-06 15:52:24 +10:00
parent 6d94ac9f96
commit 98718b3b4b

View File

@@ -215,17 +215,10 @@ timer_purge(isc_timer_t *timer) {
isc_timerevent_t *event = NULL;
while ((event = ISC_LIST_HEAD(timer->active)) != NULL) {
timerevent_unlink(timer, event);
UNLOCK(&timer->lock);
bool purged = isc_task_purgeevent(timer->task,
(isc_event_t *)event);
(void)isc_task_purgeevent(timer->task, (isc_event_t *)event);
LOCK(&timer->lock);
if (!purged) {
/*
* The event has already been executed, but not
* yet destroyed.
*/
timerevent_unlink(timer, event);
}
}
}