monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

signal related race conditions and deadlock


From: Martin Pala
Subject: signal related race conditions and deadlock
Date: Sat, 13 Sep 2003 21:27:47 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030908 Debian/1.4-4

Hi,

there are SIGTERM and SIGINT related problems:

------
FIRST:
------

1.) monit receives one of above mentioned signals and calls do_destroy()
2.) do_destroy() sets http engine stopped flag and returns - monit httpd then will stop in next cycle on 'while' condition
3.) monit will close all files and logs (asynchronously of monit httpd task)

Problem, is that monit httpd thread is able to log messages, while it is possible that the socket will be closed earlier.

The solution could probably be to wait for http thread termination (by joining the thread?)

-------
SECOND:
-------
During my tests it was possible to deadlock monit while running in the loop by:

while true; do monit -c /etc/monitrc validate; done

and sending it SIGTERM. It hung - gdb showed that it did validate() function as expected, entered do_destroy(), runned garbage collector and closed files but before it reached exit it received SIGTERM. It involved do_destroy() again and it blocked on log() function. Each next SIGTERM involved do_destroy() again, but blocked in the same place. I don't know what was bigger problem - whether closed files or freed memory (i suppose that it should fail on SIGSEGV because of memory, but it did not happened).

Maybe it could be solved by blocking signals in do_destroy() itself - it is called from main() if we are finalizing gracefully as well as signal handler (i don't know wheter it is possible to block signals in signal handler).


Martin












reply via email to

[Prev in Thread] Current Thread [Next in Thread]