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 23:51:38 +0000 (16:51 -0700)
commitaee9c99288e600e5b8cf6abe4ea1596c0cd29a63
treeaabb7858518b1024bd196040153edf6c2b9a2aa6
parent25cc6b29523b113e2aa775c4abe01828a1d47fb9
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