Procházet zdrojové kódy

Reload: Add atomic reload to log config

When a reload is in progress, wait until it has all finished
before re-reading all of the logging parameters

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield před 12 roky
rodič
revize
1a046793cb
1 změnil soubory, kde provedl 28 přidání a 0 odebrání
  1. 28 0
      exec/logconfig.c

+ 28 - 0
exec/logconfig.c

@@ -542,6 +542,22 @@ static void main_logging_notify(
 #endif
 {
 	const char *error_string;
+	static int reload_in_progress = 0;
+
+	/* If a full reload happens then suspend updates for individual keys until
+	 * it's all completed
+	 */
+	if (strcmp(key_name, "config.reload_in_progress") == 0) {
+		if (*(uint8_t *)new_val.data == 1) {
+			reload_in_progress = 1;
+		} else {
+			reload_in_progress = 0;
+		}
+	}
+	if (reload_in_progress) {
+		log_printf(LOGSYS_LEVEL_DEBUG, "Ignoring key change, reload in progress. %s\n", key_name);
+		return;
+	}
 
 	/*
 	 * Reload the logsys configuration
@@ -562,6 +578,12 @@ static void add_logsys_config_notification(void)
 			main_logging_notify,
 			NULL,
 			&icmap_track);
+
+	icmap_track_add("config.reload_in_progress",
+			ICMAP_TRACK_ADD | ICMAP_TRACK_MODIFY,
+			main_logging_notify,
+			NULL,
+			&icmap_track);
 }
 #else
 static void add_logsys_config_notification(void)
@@ -573,6 +595,12 @@ static void add_logsys_config_notification(void)
 			main_logging_notify,
 			NULL,
 			&cmap_track);
+
+	cmap_track_add(cmap_handle, "config.reload_in_progress",
+			CMAP_TRACK_ADD | CMAP_TRACK_MODIFY,
+			main_logging_notify,
+			NULL,
+			&cmap_track);
 }
 #endif