Skip to content
Snippets Groups Projects
Commit 478c424c authored by Simon McVittie's avatar Simon McVittie
Browse files

logger: When we reopen a file, make sure to record its new identity


Otherwise, after reopening a deleted or replaced file, we would reopen
it once per line, because its inode number constantly differs from
the original inode number.

After commit 1f502cb4 "logger: Fix always re-opening files when
--log-fd is used", this was the only remaining place where we assign
to self->file_fd without also assigning to self->file_stat.

Fixes: 8f65507d "logger: Recreate output log files if they get deleted"
Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent db1bca1f
No related branches found
No related tags found
1 merge request!743logger: Fix always re-opening files when --log-fd is used
This commit is part of merge request !743. Comments created here will be created in the context of that merge request.
......@@ -1242,13 +1242,27 @@ logger_process_complete_line (SrtLogger *self,
OPEN_FLAGS,
0644));
if (new_fd < 0)
_srt_log_warning ("Unable to re-open log file: %s",
g_strerror (errno));
{
_srt_log_warning ("Unable to re-open log file: %s",
g_strerror (errno));
}
/* Reuse current_stat (which might or might not be populated)
* for the device and inode of the replacement file */
else if (fstat (new_fd, &current_stat) < 0)
{
_srt_log_warning ("Unable to stat log file \"%s\": %s",
self->filename, g_strerror (errno));
}
else if (!lock_output_file (self->filename, new_fd, &local_error))
_srt_log_warning ("Unable to re-lock log file: %s",
local_error->message);
{
_srt_log_warning ("Unable to re-lock log file: %s",
local_error->message);
}
else
self->file_fd = glnx_steal_fd (&new_fd);
{
self->file_fd = glnx_steal_fd (&new_fd);
self->file_stat = current_stat;
}
}
else if (self->max_bytes > 0
&& (current_stat.st_size + len) > self->max_bytes)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment