2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 21:07:47 +00:00

63 Commits

Author SHA1 Message Date
Ben Pfaff
ff8decf1a3 daemon: Add support for process monitoring and restart. 2010-01-15 15:29:54 -08:00
Ben Pfaff
7943cd51e7 daemon: Refactor code.
This commit should not change behavior, but it paves the way for
implementing --monitor in the following commit.
2010-01-15 15:29:52 -08:00
Ben Pfaff
55368fb836 daemon: Close standard file descriptors when daemonizing.
Before SSH terminates, it waits for the PTYs that it creates for use as
stdin, stdout, and stderr to be closed.  When any of the Open vSwitch
daemons were started in the background over an SSH session, they held
those file descriptors open and thus the SSH session hung.  This commit
fixes the problem by closing those file descriptors, allowing SSH to
terminate.
2010-01-12 16:03:35 -08:00
Ben Pfaff
b8781ff08d daemon: Don't ignore failed write to pipe.
If the write to the pipe fails here then the parent will think that the
child failed to start up, so the child should oblige it by bailing out.
2010-01-04 09:47:01 -08:00
Ben Pfaff
95440284bd daemon: Allow daemon child process to report success or failure to parent.
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-12-18 13:37:44 -08:00
Justin Pettit
18b9283b98 Clean-up compiler warnings about ignoring return values
Some systems complain when certain functions' return values are not
checked.  This commit fixes those warnings.

Creating ignore() function suggested by Ben Pfaff.
2009-12-15 00:14:32 -08:00
Ben Pfaff
eb077b264f ovsdb-server: Maintain the database lock with --detach.
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-11-16 15:20:01 -08:00
Ben Pfaff
ac718c9dbd Implement library for lockfiles and use it in cfg code.
This is useful because the upcoming configuration database also needs a
lockfile implementation.

Also adds tests.
2009-10-29 15:20:56 -07:00
Ben Pfaff
03fbffbda4 Make sure that time advances in a daemon between calls to time_refresh().
Open vSwitch uses an interval timer signal to tell it that its cached idea
of the current time has expired.  However, this didn't work in a daemon
detached from the foreground session (invoked with --detach) because a
child created with fork() does not inherit the parent's interval timer and
we did not re-set it after calling fork().

This commit fixes the problem by setting the interval timer back up after
calling fork() from daemonize().

This fix is based on code inspection (which was then verified to be correct
through testing).  It may not fix any actual problems in practice, because
time_refresh() is called every time through the poll loop, and the poll
loop typically runs more quickly than the periodic timer fires (1 ms or so
average in ovs-vswitchd, vs. 100 ms timer interval).
2009-10-15 10:43:36 -07:00
Justin Pettit
e7bd7d78b1 daemon: Remove short options from daemon library
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-06 18:04:36 -07:00
Justin Pettit
91a1e24d09 daemon: Provide option to not chdir to root
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-08-06 18:04:36 -07:00
Ben Pfaff
a14bc59fb8 Update primary code license to Apache 2.0. 2009-06-15 15:11:30 -07:00
Ben Pfaff
064af42167 Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45. 2009-07-08 13:19:16 -07:00