X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fvlog.c;h=0bd9bd135892b7d26d343f24cc327d02b0b2ad6d;hb=cb22974d773942d66da42b700b8bca0db27a0920;hp=2587cdeda01e0356a79bc49c9d4d16b1c33b2fa7;hpb=4749f73d12c844b318af7f45cf45e1acac9f7c08;p=sliver-openvswitch.git diff --git a/lib/vlog.c b/lib/vlog.c index 2587cdeda..0bd9bd135 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ #include #include #include -#include "coverage.h" #include "dirs.h" #include "dynamic-string.h" #include "ofpbuf.h" @@ -41,8 +40,6 @@ VLOG_DEFINE_THIS_MODULE(vlog); -COVERAGE_DEFINE(vlog_recursive); - /* Name for each logging level. */ static const char *level_names[VLL_N_LEVELS] = { #define VLOG_LEVEL(NAME, SYSLOG_LEVEL) #NAME, @@ -483,55 +480,6 @@ vlog_unixctl_reopen(struct unixctl_conn *conn, int argc OVS_UNUSED, } } -static void -set_all_rate_limits(bool enable) -{ - struct vlog_module **mp; - - for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) { - (*mp)->honor_rate_limits = enable; - } -} - -static void -set_rate_limits(struct unixctl_conn *conn, int argc, - const char *argv[], bool enable) -{ - if (argc > 1) { - int i; - - for (i = 1; i < argc; i++) { - if (!strcasecmp(argv[i], "ANY")) { - set_all_rate_limits(enable); - } else { - struct vlog_module *module = vlog_module_from_name(argv[i]); - if (!module) { - unixctl_command_reply_error(conn, "unknown module"); - return; - } - module->honor_rate_limits = enable; - } - } - } else { - set_all_rate_limits(enable); - } - unixctl_command_reply(conn, NULL); -} - -static void -vlog_enable_rate_limit(struct unixctl_conn *conn, int argc, - const char *argv[], void *aux OVS_UNUSED) -{ - set_rate_limits(conn, argc, argv, true); -} - -static void -vlog_disable_rate_limit(struct unixctl_conn *conn, int argc, - const char *argv[], void *aux OVS_UNUSED) -{ - set_rate_limits(conn, argc, argv, false); -} - /* Initializes the logging subsystem and registers its unixctl server * commands. */ void @@ -567,10 +515,6 @@ vlog_init(void) "vlog/set", "{spec | PATTERN:facility:pattern}", 1, INT_MAX, vlog_unixctl_set, NULL); unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list, NULL); - unixctl_command_register("vlog/enable-rate-limit", "[module]...", - 0, INT_MAX, vlog_enable_rate_limit, NULL); - unixctl_command_register("vlog/disable-rate-limit", "[module]...", - 0, INT_MAX, vlog_disable_rate_limit, NULL); unixctl_command_register("vlog/reopen", "", 0, 0, vlog_unixctl_reopen, NULL); } @@ -599,20 +543,12 @@ vlog_get_levels(void) ds_put_format(&s, " ------- ------ ------\n"); for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) { - struct ds line; - - ds_init(&line); - ds_put_format(&line, "%-16s %4s %4s %4s", - vlog_get_module_name(*mp), - vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)), - vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)), - vlog_get_level_name(vlog_get_level(*mp, VLF_FILE))); - if (!(*mp)->honor_rate_limits) { - ds_put_cstr(&line, " (rate limiting disabled)"); - } - ds_put_char(&line, '\n'); - - svec_add_nocopy(&lines, ds_steal_cstr(&line)); + line = xasprintf("%-16s %4s %4s %4s\n", + vlog_get_module_name(*mp), + vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)), + vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)), + vlog_get_level_name(vlog_get_level(*mp, VLF_FILE))); + svec_add_nocopy(&lines, line); } svec_sort(&lines); @@ -890,10 +826,6 @@ bool vlog_should_drop(const struct vlog_module *module, enum vlog_level level, struct vlog_rate_limit *rl) { - if (!module->honor_rate_limits) { - return false; - } - if (!vlog_is_enabled(module, level)) { return true; } @@ -955,26 +887,13 @@ static void vlog_write_file(struct ds *s) { if (worker_is_running()) { - static bool in_worker_request = false; - if (!in_worker_request) { - in_worker_request = true; - - worker_request(s->string, s->length, - &log_fd, vlog_async_inited ? 0 : 1, - vlog_async_write_request_cb, NULL, NULL); - vlog_async_inited = true; - - in_worker_request = false; - return; - } else { - /* We've been entered recursively. This can happen if - * worker_request(), or a function that it calls, tries to log - * something. We can't call worker_request() recursively, so fall - * back to writing the log file directly. */ - COVERAGE_INC(vlog_recursive); - } + worker_request(s->string, s->length, + &log_fd, vlog_async_inited ? 0 : 1, + vlog_async_write_request_cb, NULL, NULL); + vlog_async_inited = true; + } else { + ignore(write(log_fd, s->string, s->length)); } - ignore(write(log_fd, s->string, s->length)); } static void