[asterisk-commits] cdr/cdr csv.c: Set file name for csv master to the module wh... (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 2 12:02:01 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: cdr/cdr_csv.c: Set file name for csv master to the module when (re)loaded.
......................................................................
cdr/cdr_csv.c: Set file name for csv master to the module when (re)loaded.
Compute the location for the csv master file when the module is
loaded or reload. Before it was calculated every time a log
entry was written.
Change-Id: I3ed9f6a8f965308099db70b71128f43d4d3f5585
---
M cdr/cdr_csv.c
1 file changed, 9 insertions(+), 4 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Richard Mudgett: Looks good to me, but someone else must approve
Matt Jordan: Looks good to me, approved; Verified
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 6fb2b71..31f95c0 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -60,6 +60,7 @@
static int loaded = 0;
static int newcdrcolumns = 0;
static const char config[] = "cdr.conf";
+static char file_csv_master[PATH_MAX];
/* #define CSV_LOGUNIQUEID 1 */
/* #define CSV_LOGUSERFIELD 1 */
@@ -119,6 +120,12 @@
ast_config_destroy(cfg);
return 0;
}
+
+ /* compute the location of the csv master file */
+ ast_mutex_lock(&f_lock);
+ snprintf(file_csv_master, sizeof(file_csv_master),
+ "%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
+ ast_mutex_unlock(&f_lock);
for (; v; v = v->next) {
if (!strcasecmp(v->name, "usegmtime")) {
@@ -293,16 +300,14 @@
{
/* Make sure we have a big enough buf */
char buf[1024];
- char csvmaster[PATH_MAX];
- snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
if (build_csv_record(buf, sizeof(buf), cdr)) {
ast_log(LOG_WARNING, "Unable to create CSV record in %d bytes. CDR not recorded!\n", (int)sizeof(buf));
return 0;
}
ast_mutex_lock(&f_lock);
- if (writefile(buf, csvmaster))
- ast_log(LOG_WARNING, "Unable to write CSV record to master '%s' : %s\n", csvmaster, strerror(errno));
+ if (writefile(buf, file_csv_master))
+ ast_log(LOG_WARNING, "Unable to write CSV record to master '%s' : %s\n", file_csv_master, strerror(errno));
if (accountlogs && !ast_strlen_zero(cdr->accountcode)) {
if (writefile_account(buf, cdr->accountcode))
--
To view, visit https://gerrit.asterisk.org/404
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ed9f6a8f965308099db70b71128f43d4d3f5585
Gerrit-PatchSet: 5
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <decipher.hk at gmail.com>
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-commits
mailing list