diff options
-rw-r--r-- | sysklogd/syslogd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 04221fc33..266657f3b 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -110,6 +110,7 @@ typedef struct { | |||
110 | typedef struct logFile_t { | 110 | typedef struct logFile_t { |
111 | const char *path; | 111 | const char *path; |
112 | int fd; | 112 | int fd; |
113 | time_t last_log_time; | ||
113 | #if ENABLE_FEATURE_ROTATE_LOGFILE | 114 | #if ENABLE_FEATURE_ROTATE_LOGFILE |
114 | unsigned size; | 115 | unsigned size; |
115 | uint8_t isRegular; | 116 | uint8_t isRegular; |
@@ -165,7 +166,6 @@ struct globals { | |||
165 | #if ENABLE_FEATURE_IPC_SYSLOG | 166 | #if ENABLE_FEATURE_IPC_SYSLOG |
166 | struct shbuf_ds *shbuf; | 167 | struct shbuf_ds *shbuf; |
167 | #endif | 168 | #endif |
168 | time_t last_log_time; | ||
169 | /* localhost's name. We print only first 64 chars */ | 169 | /* localhost's name. We print only first 64 chars */ |
170 | char *hostname; | 170 | char *hostname; |
171 | 171 | ||
@@ -588,15 +588,16 @@ static void log_locally(time_t now, char *msg, logFile_t *log_file) | |||
588 | /* fd can't be 0 (we connect fd 0 to /dev/log socket) */ | 588 | /* fd can't be 0 (we connect fd 0 to /dev/log socket) */ |
589 | /* fd is 1 if "-O -" is in use */ | 589 | /* fd is 1 if "-O -" is in use */ |
590 | if (log_file->fd > 1) { | 590 | if (log_file->fd > 1) { |
591 | /* Reopen log file every second. This allows admin | 591 | /* Reopen log files every second. This allows admin |
592 | * to delete the file and not worry about restarting us. | 592 | * to delete the files and not worry about restarting us. |
593 | * This costs almost nothing since it happens | 593 | * This costs almost nothing since it happens |
594 | * _at most_ once a second. | 594 | * _at most_ once a second for each file, and happens |
595 | * only when each file is actually written. | ||
595 | */ | 596 | */ |
596 | if (!now) | 597 | if (!now) |
597 | now = time(NULL); | 598 | now = time(NULL); |
598 | if (G.last_log_time != now) { | 599 | if (log_file->last_log_time != now) { |
599 | G.last_log_time = now; | 600 | log_file->last_log_time = now; |
600 | close(log_file->fd); | 601 | close(log_file->fd); |
601 | goto reopen; | 602 | goto reopen; |
602 | } | 603 | } |