Skip to content

Commit 12d3709

Browse files
committed
EH: CS-2064: sge_do_log: support log file rotation with persistent fd
1 parent 2b063c5 commit 12d3709

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

source/libs/uti/sge_log.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ sge_do_log(uint32_t prog_number, const char *prog_or_thread_name, int thread_id,
8989
if (Log_State.log_fd >= 0 && now - Log_State.last_inode_check > 5 * 1000000ULL) {
9090
Log_State.last_inode_check = now;
9191
struct stat st_fd{}, st_path{};
92-
if (fstat(Log_State.log_fd, &st_fd) == 0 && stat(Log_State.log_file, &st_path) == 0 && st_fd.st_ino != st_path.st_ino) {
93-
// log file was rotated — reopen against the new path
92+
// reopen if the path is gone (mv-based rotation, e.g. logchecker.sh) or
93+
// resolves to a different inode (rename+recreate rotation, e.g. logrotate)
94+
if (fstat(Log_State.log_fd, &st_fd) == 0 &&
95+
(stat(Log_State.log_file, &st_path) != 0 || st_fd.st_ino != st_path.st_ino)) {
9496
close(Log_State.log_fd);
9597
Log_State.log_fd = -1;
9698
}

0 commit comments

Comments
 (0)