summaryrefslogtreecommitdiff
path: root/src/nm-logging.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-06 19:48:35 +0200
committerThomas Haller <thaller@redhat.com>2015-10-09 14:56:50 +0200
commit98e34208bdfd8adb8b0f2e500c832a418bfc8374 (patch)
tree9095529c2edb9792845ad66760c135ba1900d13f /src/nm-logging.c
parentfd87ce503c7927ba552b381b5c2d4b32fccb48dd (diff)
downloadNetworkManager-98e34208bdfd8adb8b0f2e500c832a418bfc8374.tar.gz
platform: warn about growing sysctl logging cache and clear it
When debug-logging for platform is enabled, every access to sysctl is cached (to log the last values). This cache can grow quite large if the system has a large number of interfaces (e.g. docker creating veth pairs for each container). We already used to clear the cache, when we were about to access sysctl *and* logging was disabled in the meantime. Now, when logging setup changes, immediately clear the cache. Having "nm-logging.c" call into platform code is a bit of a hack and a better design would be to have logging code emit a signal to which platform would subscribe. But that seems to involve much more code (especially, as no other users care about such a signal and because nm-logging is not a GObject). Also, log a warning when the cache grows large to inform the user about the cache and what he can do to clear it. The extra effort to clear the cache when changing logging setup is done so that we do what we tell the user: changing the logging level, will clear the cache -- right away, not some time later when the next message is logged.
Diffstat (limited to 'src/nm-logging.c')
-rw-r--r--src/nm-logging.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index e58a5de384..6476d7664f 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -40,6 +40,7 @@
#include "nm-default.h"
#include "nm-errors.h"
#include "NetworkManagerUtils.h"
+#include "nm-linux-platform.h"
static void
nm_log_handler (const gchar *log_domain,
@@ -169,6 +170,7 @@ nm_logging_setup (const char *level,
NMLogLevel new_log_level = log_level;
char **tmp, **iter;
int i;
+ gboolean had_platform_debug;
g_return_val_if_fail (!bad_domains || !*bad_domains, FALSE);
g_return_val_if_fail (!error || !*error, FALSE);
@@ -276,10 +278,20 @@ nm_logging_setup (const char *level,
g_clear_pointer (&logging_domains_to_string, g_free);
+ had_platform_debug = nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM);
+
log_level = new_log_level;
for (i = 0; i < G_N_ELEMENTS (new_logging); i++)
logging[i] = new_logging[i];
+ if ( had_platform_debug
+ && !nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) {
+ /* when debug logging is enabled, platform will cache all access to
+ * sysctl. When the user disables debug-logging, we want to clear that
+ * cache right away. */
+ _nm_linux_platform_sysctl_clear_cache ();
+ }
+
if (unrecognized)
*bad_domains = g_string_free (unrecognized, FALSE);