]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Log: Fix locking during log reconfiguration
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 25 Nov 2020 14:15:13 +0000 (15:15 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 25 Nov 2020 14:15:13 +0000 (15:15 +0100)
The log subsystem should be locked earlier, as default_log_list() may
internally manipulate with the current_log_list (if it is also a default
log list).

sysdep/unix/log.c

index 44536cc94eb85d19ad18c2d3d7aa28c42aac6572..14d18c018b2e56a6b5bc33b4c9e93e62af4df7f4 100644 (file)
@@ -382,12 +382,12 @@ log_switch(int initial, list *logs, const char *new_syslog_name)
 {
   struct log_config *l;
 
+  /* We should not manipulate with log list when other threads may use it */
+  log_lock();
+
   if (!logs || EMPTY_LIST(*logs))
     logs = default_log_list(initial, &new_syslog_name);
 
-  /* We shouldn't close the logs when other threads may use them */
-  log_lock();
-
   /* Close the logs to avoid pinning them on disk when deleted */
   if (current_log_list)
     WALK_LIST(l, *current_log_list)