openhpi2 / Open-HPI-base

Open HPI is an open source implementation of the SA Forum's Hardware Platform Interface (HPI). HPI provides an abstracted interface to managing computer hardware, typically for chassis and rack based servers
0 stars 1 forks source link

Discovery thread takes long time to terminate after SIGTERM #2574

Closed openhpi2 closed 8 years ago

openhpi2 commented 9 years ago

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

openhpi2 commented 9 years ago

An infrastructure patch is attached. Could you please review

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Original comment by: hemanthreddy

openhpi2 commented 9 years ago

Fixed in 3.6.0 trunk Revision 7623.

Original comment by: hemanthreddy