There's no good reason to not always reset the file size

after re-opening
This commit is contained in:
Nils O. Selåsdal
2015-02-10 21:46:08 +01:00
parent d187c1d63b
commit c90ad5e257
+6 -7
View File
@@ -447,10 +447,12 @@ int uc_log_reopen_files(void)
UC_TAILQ_FOREACH_CONTAINER(dest, entry, &g_destinations) { UC_TAILQ_FOREACH_CONTAINER(dest, entry, &g_destinations) {
if (dest->dest_type == UC_LDEST_FILE) { if (dest->dest_type == UC_LDEST_FILE) {
rc = uc_log_reopen_file(dest); int r_rc;
if (rc == 0) { r_rc = uc_log_reopen_file(dest);
dest->type.file.size = 0; if (r_rc != 0) {
rc = r_rc;
} }
dest->type.file.size = 0;
} }
} }
@@ -633,7 +635,6 @@ static void uc_log_file_rotate_size(struct UCLogDestination *dest)
char new_filename[_POSIX_PATH_MAX * 2]; char new_filename[_POSIX_PATH_MAX * 2];
char old_filename[_POSIX_PATH_MAX * 2]; char old_filename[_POSIX_PATH_MAX * 2];
unsigned int i; unsigned int i;
int rc;
if (dest->type.file.file_name == NULL) { if (dest->type.file.file_name == NULL) {
return; return;
@@ -653,10 +654,8 @@ static void uc_log_file_rotate_size(struct UCLogDestination *dest)
rename(dest->type.file.file_name, new_filename); rename(dest->type.file.file_name, new_filename);
//re-open current file //re-open current file
rc = uc_log_reopen_file(dest); uc_log_reopen_file(dest);
if (rc == 0) {
dest->type.file.size = 0; dest->type.file.size = 0;
}
return; return;
} }