worker: Prevent worker from being responsible for pidfile deletion.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 29 Apr 2013 02:25:55 +0000 (19:25 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Mon, 29 Apr 2013 22:09:48 +0000 (15:09 -0700)
commit7ffd3f6972b41827d7b03e10dcbb0a4c20e4d919
tree488e7186435678f9c6bd67f6f64f17ea1b04c27a
parent9f27568d9f6615b486bd13324b9a607864ef8780
worker: Prevent worker from being responsible for pidfile deletion.

Currently we are creating the worker process after creation of the pidfile.
This means that the responsibility of deleting the pidfile after process
termination rests with the worker process.

When we restart openvswitch using the startup scripts, we SIGTERM the main
process and once it is cleaned up, we start ovs-vswitchd again. This results
in a race condition. The new ovs-vswitchd will create a pidfile because it is
unlocked. But, if the old worker process exits after the start of new
ovs-vswitchd, it will simply delete the pidfile underneath the new ovs-vswitchd.
This will eventually result in multiple ovs-vswitchd daemons.

This patch gives the responsibility of deleting the pidfile to the main
process.

Bug #16669.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
lib/daemon.c
lib/daemon.h
lib/worker.c