I'm looking at the _init_event() and _fini_event() functions and
comparing with _init_fini_event() functions. What's the purpose of
having the _init_fini_event() function? All it does it enqueue events
that call either the _init_event() or _fini_event() function.
The last thing we do in graceful_shutdown() is enqueue a SHUTDOWN
event. But because of the chain of events, some of the events don't run.
What happens currently on graceful_shutdown (taking enms as an example,
locations and ncus are similar):
1. call nwamd_fini_enms().
2. call nwamd_enm_init_fini_event() which enqueues a FINI event for
each enm
[ ... wait in event queue ...]
3. call nwamd_enm_fini_event() which enqueues a DISABLE event
[ ... wait in event queue ...]
4. call nwamd_enm_action() which calls nwamd_enm_disable_event().
Now, in that one event queue, the SHUTDOWN event may be before the FINI
or DISABLE event depending on thread timing, which renders those events
useless.
I propose that nwamd_fini_enms() enqueue a FINI event for each enm.
These FINI events and the ones for location and ncus are followed by the
SHUTDOWN event in the event queue.
Then when nwamd_enm_fini_event() is called, it synchronously calls
nwamd_enm_disable_event() and frees state. (locations and ncus are similar)
This makes sure that when the SHUTDOWN event is dequeued, all other
shutting down actions are already complete.
Comments?
Am I missing the point of the _init_fini_event() functions?
Thanks,
Anurag