vlib: reset stop_timer_handle on expired processes 21/38621/1
authorMatthew Smith <mgsmith@netgate.com>
Tue, 4 Apr 2023 19:27:55 +0000 (19:27 +0000)
committerMatthew Smith <mgsmith@netgate.com>
Thu, 6 Apr 2023 22:07:00 +0000 (22:07 +0000)
commit9aa4ac55b0a205e333e567f87c3cc9379af2363c
treee61bf1413d5279eb881c2d0e5f143a85e1dee678
parent5294cdc79213a8703f70d9a300b0c5806c788ca4
vlib: reset stop_timer_handle on expired processes

Type: fix

The main loop populates a vector of suspended process nodes to dispatch
by calling TW (tw_timer_expire_timers_vec), which identifies expired
timers and appends the user handle for each one to the vector.

Subsequently, the vector is iterated and the process node corresponding
to each handle is dispatched. The vast majority of the time, the process
node will end up suspending itself again to wait for a new timer or
event.

Given a process node A whose timer has expired, between the point when
the timer expired and the point when A is dispatched and suspends itself
again, its stop_timer_handle contains a stale value.

If another process node B is dispatched before A is dispatched, it may
end up using the timer ID that A formerly used. If another process node
C is dispatched after B and before A and calls
vlib_process_signal_event() to signal A, the timer started by B can be
deleted by vlib_process_signal_event_helper().

After getting the vector of process node IDs for expired timers, reset
the stop_timer_handle on each of those nodes.

Change-Id: I266da438e76e1fc356016da0b9b4941efac1c28a
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/vlib/main.c