summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2016-02-03 13:41:34 -0800
committerBen Pfaff <blp@ovn.org>2016-02-10 13:36:04 -0800
commit063801288e2b1c98026d7faa81de9959eee678a3 (patch)
tree49a423c1b28e233555fbf2efb4a956508304c970 /lib
parent922fed065e65ad8388528976d631445f9e768f55 (diff)
downloadopenvswitch-063801288e2b1c98026d7faa81de9959eee678a3.tar.gz
vlog: Add vlog/close command.
Requested-by: P R Dinesh Requested-at: https://github.com/openvswitch/ovs/pull/94 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/vlog-unixctl.man9
-rw-r--r--lib/vlog.c24
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/vlog-unixctl.man b/lib/vlog-unixctl.man
index 7c47634fa..7372a7ef4 100644
--- a/lib/vlog-unixctl.man
+++ b/lib/vlog-unixctl.man
@@ -54,9 +54,14 @@ Lists the supported logging modules and their current levels.
.IP "\fBvlog/list-pattern\fR"
Lists logging patterns used for each destination.
.
+.IP "\fBvlog/close\fR"
+Causes \fB\*(PN\fR to close its log file, if it is open. (Use
+\fBvlog/reopen\fR to reopen it later.)
+.
.IP "\fBvlog/reopen\fR"
-Causes \fB\*(PN\fR to close and reopen its log file. (This is useful
-after rotating log files, to cause a new log file to be used.)
+Causes \fB\*(PN\fR to close its log file, if it is open, and then
+reopen it. (This is useful after rotating log files, to cause a new
+log file to be used.)
.IP
This has no effect unless \fB\*(PN\fR was invoked with the
\fB\-\-log\-file\fR option.
diff --git a/lib/vlog.c b/lib/vlog.c
index f514d65b5..49260d803 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -678,6 +678,28 @@ vlog_unixctl_reopen(struct unixctl_conn *conn, int argc OVS_UNUSED,
}
static void
+vlog_unixctl_close(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+ ovs_mutex_lock(&log_file_mutex);
+ if (log_fd >= 0) {
+ close(log_fd);
+ log_fd = -1;
+
+ async_append_destroy(log_writer);
+ log_writer = NULL;
+
+ struct vlog_module *mp;
+ LIST_FOR_EACH (mp, list, &vlog_modules) {
+ update_min_level(mp);
+ }
+ }
+ ovs_mutex_unlock(&log_file_mutex);
+
+ unixctl_command_reply(conn, NULL);
+}
+
+static void
set_all_rate_limits(bool enable)
{
struct vlog_module *mp;
@@ -771,6 +793,8 @@ vlog_init(void)
0, INT_MAX, vlog_disable_rate_limit, NULL);
unixctl_command_register("vlog/reopen", "", 0, 0,
vlog_unixctl_reopen, NULL);
+ unixctl_command_register("vlog/close", "", 0, 0,
+ vlog_unixctl_close, NULL);
ovs_rwlock_rdlock(&pattern_rwlock);
print_syslog_target_deprecation = syslog_fd >= 0;