aboutsummaryrefslogtreecommitdiff
path: root/lib/daemon.h
AgeCommit message (Collapse)Author
2013-04-29worker: Prevent worker from being responsible for pidfile deletion.Gurucharan Shetty
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>
2012-07-18daemon: Factor out code into new function daemonize_post_detach().Ben Pfaff
This code will have another user in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18daemon: Factor out code into new function fork_and_wait_for_startup().Ben Pfaff
This function will be useful in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-02Global replace of Nicira Networks.Raju Subramanian
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-02daemon: New function daemon_save_fd() to preserve fds across detach.Ben Pfaff
This eliminates a kluge that was duplicated in three different daemons. Signed-off-by: Ben Pfaff <blp@nicira.com>
2011-05-16Consistently write null pointer constants as NULL instead of 0.Ben Pfaff
Found with sparse.
2011-04-04daemon: Integrate checking for an existing pidfile into daemonize_start().Ben Pfaff
Until now, it has been the responsibility of an individual daemon to call die_if_already_running() at an appropriate time. A long time ago, this had to happen *before* daemonizing, because once the process daemonized itself there was no way to report failure to the process that originally started the daemon. With the introduction of daemonize_start(), this is now possible, but we haven't been taking advantage of it. Therefore, this commit integrates the die_if_already_running() call into daemonize_start() and deletes the calls to it from individual daemons.
2011-03-29daemon: Avoid redundant code in already_running().Ben Pfaff
This function substantially duplicated read_pidfile(), so reuse that code instead.
2011-02-07daemon: Define daemon options enums the same way as other option enums.Ben Pfaff
Other modules that accept options use this style and I don't see a reason for the daemon code to be different. The style used by the daemon code until now runs the risk of ending up with conflicting values accidentally, which would be confusing.
2010-01-15daemon: Add support for process monitoring and restart.Ben Pfaff
2009-12-18daemon: Allow daemon child process to report success or failure to parent.Ben Pfaff
There are conflicting pressures in startup of a daemon process: * The parent process should exit with an error code if the daemon cannot start up successfully. * Some startup actions must be performed in the child process, not in the parent. The most obvious of these are file locking, since child processes do not inherit locks, and anything that requires knowing the child process's PID (e.g. unixctl sockets). Until now, this conflict has usually been handled by giving up part of the first property, i.e. in some cases the parent process would exit successfully and the child immediately afterward exit with a failure code. This commit introduces a better approach, by allowing daemons to perform startup work in the child and only then signal the parent that they have successfully started. If the child instead exits without signaling success, the parent passes this exit code along to its own parent. This commit also modifies the daemons that can usefully take advantage of this new feature to do so.
2009-11-16ovsdb-server: Maintain the database lock with --detach.Ben Pfaff
Before this commit, "ovsdb-server --detach" would detach after it opened the database file, which meant that the child process did not hold the file lock on the database file (because a forked child process does not inherit its parents' locks). This commit fixes the problem by making ovsdb-server open the database only after it has detached. This fix, in turn, required that daemonize() not chdir to /, because this would break databases whose names are given relative to the current directory, and so this commit also changes ovsdb-server to do so later.
2009-08-06daemon: Remove short options from daemon libraryJustin Pettit
The daemon library provides a few short options, but these then take away their availability from programs that wish to use the library. Since the daemon options are generally going to be called from a script (which doesn't care how much typing is involved), we'll only provide long options.
2009-08-06daemon: Provide option to not chdir to rootJustin Pettit
By default, Open vSwitch daemons change their working directories to the root directory. This commit provides a --no-chdir option to prevent this behavior.
2009-06-15Update primary code license to Apache 2.0.Ben Pfaff
2009-07-08Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.v0.90.0Ben Pfaff