diff options
author | Maria Matejka <mq@ucw.cz> | 2019-07-30 12:11:49 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-07-30 12:26:37 +0200 |
commit | 48addc88be27c46d83805ec2854bf1b5e0f0ddb3 (patch) | |
tree | 6311f5012ca3ab93d66edaeb10e7d062fc32963a /sysdep/unix/log.c | |
parent | 3b62417c356796a35229ce07238abf98fb569ccb (diff) |
Log: Fixed race condition in reconfigure while BFD is running
Diffstat (limited to 'sysdep/unix/log.c')
-rw-r--r-- | sysdep/unix/log.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 45f442e7..18894f98 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -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 |