mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
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.
This commit is contained in:
14
lib/daemon.c
14
lib/daemon.c
@@ -81,6 +81,13 @@ set_no_chdir(void)
|
||||
chdir_ = false;
|
||||
}
|
||||
|
||||
/* Will we chdir to "/" as part of daemonizing? */
|
||||
bool
|
||||
is_chdir_enabled(void)
|
||||
{
|
||||
return chdir_;
|
||||
}
|
||||
|
||||
/* Normally, die_if_already_running() will terminate the program with a message
|
||||
* if a locked pidfile already exists. If this function is called,
|
||||
* die_if_already_running() will merely log a warning. */
|
||||
@@ -98,6 +105,13 @@ set_detach(void)
|
||||
detach = true;
|
||||
}
|
||||
|
||||
/* Will daemonize() really detach? */
|
||||
bool
|
||||
get_detach(void)
|
||||
{
|
||||
return detach;
|
||||
}
|
||||
|
||||
/* If a pidfile has been configured and that pidfile already exists and is
|
||||
* locked by a running process, returns the pid of the running process.
|
||||
* Otherwise, returns 0. */
|
||||
|
Reference in New Issue
Block a user