[ovs-dev] [PATCH] daemon: Make sure that vlog is initialized when a process daemonizes.
Ben Pfaff
blp at nicira.com
Thu Aug 12 09:49:08 PDT 2010
If a process daemonizes itself, then it should be possible to control that
process's log levels with "ovs-appctl vlog/set" and related commands. The
vlog_init() function registers those commands. But vlog_init() doesn't
normally get called until the first log message is issued. This can take a
while, especially for ovs-controller, where I first noticed the problem.
This commit fixes the problem by calling vlog_init() from
daemonize_start(), which always gets called as a process daemonizes.
---
lib/daemon.c | 4 ++++
lib/vlog.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/daemon.c b/lib/daemon.c
index 6cb553a..c8033fb 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -448,6 +448,10 @@ daemonize_start(void)
}
make_pidfile();
+
+ /* Make sure that the unixctl commands for vlog get registered in a
+ * daemon, even before the first log message. */
+ vlog_init();
}
/* If daemonization is configured, then this function notifies the parent
diff --git a/lib/vlog.c b/lib/vlog.c
index ddda266..cb0567e 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -438,7 +438,8 @@ vlog_unixctl_reopen(struct unixctl_conn *conn,
}
}
-/* Initializes the logging subsystem. */
+/* Initializes the logging subsystem and registers its unixctl server
+ * commands. */
void
vlog_init(void)
{
--
1.7.1
More information about the dev
mailing list