Praveen observed the following.
When openhpi starts there are 4 threads in the infrastructure.
Main Thread
Discovery Thread
Event Pop Thread
Event Get Thread
Depending on the plugin there are additional threads.
Main thread calls the plugin close function to close the plugin and waits for the discovery thread and event threads to complete. Plugin close function informs the other plugin threads that stop has been requested.
Ideally, the plugin discovery needs to complete before plugin closes.
Once a signal is issued (SIGTERM / SIGINT ) main thread calls oh_post_quit_event to close the infrastructure event threads and calls oh_server_request_stop to close the application.
The discovery thread runs the discovery on all the plugins once and waits for a maximum of 3 minutes before checking the stop variable to come out of the loop. By this time the main thread would have closed the handlers of the plugins. So discovery thread needs to check the stop variable before calling the discovery function of each handler and before going to wait, so that it could exit early.
In case of evtpop thread the stop could be checked before going to wait, so that it could exit too.
This will avoid the core dumps and handing threads in some of the situations.
Praveen observed the following. When openhpi starts there are 4 threads in the infrastructure. Main Thread Discovery Thread Event Pop Thread Event Get Thread Depending on the plugin there are additional threads. Main thread calls the plugin close function to close the plugin and waits for the discovery thread and event threads to complete. Plugin close function informs the other plugin threads that stop has been requested. Ideally, the plugin discovery needs to complete before plugin closes.
Once a signal is issued (SIGTERM / SIGINT ) main thread calls oh_post_quit_event to close the infrastructure event threads and calls oh_server_request_stop to close the application. The discovery thread runs the discovery on all the plugins once and waits for a maximum of 3 minutes before checking the stop variable to come out of the loop. By this time the main thread would have closed the handlers of the plugins. So discovery thread needs to check the stop variable before calling the discovery function of each handler and before going to wait, so that it could exit early. In case of evtpop thread the stop could be checked before going to wait, so that it could exit too.
This will avoid the core dumps and handing threads in some of the situations.
Reported by: dr_mohan