mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 01:42:18 +00:00
Fix a non-deterministic server test case failure
Very occasionally, when the file logger was creating the symlink from 'serval.log' to the current log file, there was a race with another process doing exactly the same, causing one of them to log an symlink-failed ERROR that caused the server/StartTwice test to fail (when asserting that the "start" command contained no ERROR log messages). Now the symlink failure is logged at WARN level, which will not cause the test to fail.
This commit is contained in:
parent
94c58e8126
commit
6627c868d0
7
log.c
7
log.c
@ -519,9 +519,14 @@ static void _open_log_file(_log_iterator *it)
|
||||
++s;
|
||||
if (strchr(s, '/'))
|
||||
relpath = _log_file_path;
|
||||
// If racing with another process at this exact same point, then the symlink(2) call may
|
||||
// fail with EEXIST, in which case log a warning, not an error.
|
||||
unlink(strbuf_str(sbsymlink));
|
||||
if (symlink(relpath, strbuf_str(sbsymlink)) == -1)
|
||||
_logs_printf_nl(LOG_LEVEL_ERROR, __HERE__, "Cannot symlink %s to %s - %s [errno=%d]", strbuf_str(sbsymlink), relpath, strerror(errno), errno);
|
||||
_logs_printf_nl(errno == EEXIST ? LOG_LEVEL_WARN : LOG_LEVEL_ERROR,
|
||||
__HERE__,
|
||||
"Cannot symlink %s -> %s - %s [errno=%d]",
|
||||
strbuf_str(sbsymlink), relpath, strerror(errno), errno);
|
||||
}
|
||||
// Expire old log files.
|
||||
size_t pathsiz = strlen(_log_file_path) + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user