]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Log: Fixed race condition in reconfigure while BFD is running
authorMaria Matejka <mq@ucw.cz>
Tue, 30 Jul 2019 10:11:49 +0000 (12:11 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 30 Jul 2019 10:26:37 +0000 (12:26 +0200)
sysdep/unix/log.c

index 45f442e709c79735694dbd1cd60d9cf331c49367..18894f98834416e32b3eb5b1a617f10964d9b066 100644 (file)
@@ -372,6 +372,9 @@ log_switch(int initial, list *logs, char *new_syslog_name)
   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)
@@ -388,7 +391,7 @@ log_switch(int initial, list *logs, char *new_syslog_name)
 
 #ifdef HAVE_SYSLOG_H
   if (!bstrcmp(current_syslog_name, new_syslog_name))
-    return;
+    goto done;
 
   if (current_syslog_name)
   {
@@ -402,7 +405,12 @@ log_switch(int initial, list *logs, char *new_syslog_name)
     current_syslog_name = xstrdup(new_syslog_name);
     openlog(current_syslog_name, LOG_CONS | LOG_NDELAY, LOG_DAEMON);
   }
+
 #endif
+
+done:
+  /* Logs exchange done, let the threads log as before */
+  log_unlock();
 }
 
 void