Skip to content
Snippets Groups Projects
Verified Commit 9f18dac1 authored by Vitaliy Saychuk's avatar Vitaliy Saychuk Committed by IOPSYS Dev
Browse files

Fixed a bug in CDR file rename

The problem was that the rename() function failed when rotation of the Master.csv was
required due to reaching the maxrow parameter.

This happened, if the temporary CDR file for renaming was in a directory at a different
mount point than Master.csv rename() function was always failed with a 'Cross-device
link' error.

The fix will locate the temporary file in the same directory as the main Master.csv file.
parent 6ac56f14
No related branches found
No related tags found
1 merge request!256Fixed cdr file rename bug
......@@ -147,8 +147,12 @@ static int load_config(int reload)
} else if (!strcasecmp(v->name, "maxrow")) {
maxrow = atoi(v->value);
} else if (!strcasecmp(v->name, "prefdir")) {
ast_mutex_lock(&f_lock);
snprintf(file_csv_master, sizeof(file_csv_master),
"%s/%s/%s", v->value, CSV_LOG_DIR, CSV_MASTER);
snprintf(file_csv_temp, sizeof(file_csv_temp),
"%s/%s/%s", v->value, CSV_LOG_DIR, CSV_TEMP);
ast_mutex_unlock(&f_lock);
}
}
......@@ -391,7 +395,10 @@ static int writefile(char *s, char *file_path)
fflush(ft);
fclose(ft);
remove(file_path); /* rm the original file and rename the temp file to it */
rename(file_csv_temp, file_path);
if (rename(file_csv_temp, file_path)) {
ast_log(LOG_ERROR, "Unable to rename %s to %s : %s\n", file_csv_temp, file_path, strerror(errno));
return -1;
}
} else {
if (!(f = fopen(file_path, "a"))) {
ast_log(LOG_ERROR, "Unable to open file %s : %s\n", file_path, strerror(errno));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment