[sr-dev] git:master:c244381c: acc: use gmtime_r() for a safer multi-thread usage
Victor Seva
linuxmaniac at torreviejawireless.org
Tue May 12 14:59:46 CEST 2020
Module: kamailio
Branch: master
Commit: c244381c69459b3708d3603e548fafac8321acf8
URL: https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafac8321acf8
Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2020-05-12T14:59:13+02:00
acc: use gmtime_r() for a safer multi-thread usage
---
Modified: src/modules/acc/acc_cdr.c
---
Diff: https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafac8321acf8.diff
Patch: https://github.com/kamailio/kamailio/commit/c244381c69459b3708d3603e548fafac8321acf8.patch
---
diff --git a/src/modules/acc/acc_cdr.c b/src/modules/acc/acc_cdr.c
index 7b052440e6..d59192156a 100644
--- a/src/modules/acc/acc_cdr.c
+++ b/src/modules/acc/acc_cdr.c
@@ -141,7 +141,7 @@ static int db_write_cdr( struct dlg_cell* dialog,
long long_val;
double double_val;
char * end;
- struct tm *t;
+ struct tm t;
char cdr_time_format_buf[MAX_CDR_CORE][TIME_STR_BUFFER_SIZE];
if(acc_cdrs_table.len<=0)
@@ -191,9 +191,9 @@ static int db_write_cdr( struct dlg_cell* dialog,
}
if (acc_time_mode==4) {
VAL_TYPE(db_cdr_vals+i)=DB1_STRING;
- t = gmtime(&timeval_val.tv_sec);
+ gmtime_r(&timeval_val.tv_sec, &t);
/* Convert time_t structure to format accepted by the database */
- if (strftime(cdr_time_format_buf[i], TIME_STR_BUFFER_SIZE, TIME_STRING_FORMAT, t) <= 0) {
+ if (strftime(cdr_time_format_buf[i], TIME_STR_BUFFER_SIZE, TIME_STRING_FORMAT, &t) <= 0) {
cdr_time_format_buf[i][0] = '\0';
}
More information about the sr-dev
mailing list