Port latest duration check fixes to trunk.

1.3
Andreas Granig 14 years ago
parent 31f3e0282b
commit ea30c3bd45

@ -439,7 +439,7 @@ int cdr_create_cdrs(med_entry_t *records, u_int64_t count,
g_strlcpy(cdr->call_id, e->callid, sizeof(cdr->call_id));
g_strlcpy(cdr->start_time, e->timestamp, sizeof(cdr->start_time));
cdr->duration = tmp_unix_endtime - e->unix_timestamp > 0 ? tmp_unix_endtime - e->unix_timestamp : 0;
cdr->duration = (tmp_unix_endtime >= e->unix_timestamp) ? tmp_unix_endtime - e->unix_timestamp : 0;
g_strlcpy(cdr->call_status, call_status, sizeof(cdr->call_status));
g_strlcpy(cdr->call_code, e->sip_code, sizeof(cdr->call_code));

@ -334,13 +334,13 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_
char str_customer_cost[32] = "";
char str_source_accid[32] = "";
char str_dest_accid[32] = "";
snprintf(str_source_clir, sizeof(str_source_clir), "%d", e->source_clir);
snprintf(str_duration, sizeof(str_duration), "%d", e->duration);
snprintf(str_carrier_cost, sizeof(str_carrier_cost), "%d", e->carrier_cost);
snprintf(str_reseller_cost, sizeof(str_reseller_cost), "%d", e->reseller_cost);
snprintf(str_customer_cost, sizeof(str_customer_cost), "%d", e->customer_cost);
snprintf(str_source_accid, sizeof(str_source_accid), "%d", e->source_account_id);
snprintf(str_dest_accid, sizeof(str_dest_accid), "%d", e->destination_account_id);
snprintf(str_source_clir, sizeof(str_source_clir), "%u", e->source_clir);
snprintf(str_duration, sizeof(str_duration), "%u", e->duration);
snprintf(str_carrier_cost, sizeof(str_carrier_cost), "%u", e->carrier_cost);
snprintf(str_reseller_cost, sizeof(str_reseller_cost), "%u", e->reseller_cost);
snprintf(str_customer_cost, sizeof(str_customer_cost), "%u", e->customer_cost);
snprintf(str_source_accid, sizeof(str_source_accid), "%u", e->source_account_id);
snprintf(str_dest_accid, sizeof(str_dest_accid), "%u", e->destination_account_id);
CDRPRINT("(NULL, now(), '");
CDRESCAPE(e->source_user_id);
@ -538,6 +538,8 @@ int medmysql_batch_start(struct medmysql_batches *batches) {
static int medmysql_flush_cdr(struct medmysql_batches *batches) {
/* FILE *qlog; */
if (batches->cdrs.len == 0)
return 0;
if (batches->cdrs.str[batches->cdrs.len - 1] != ',')
@ -551,6 +553,22 @@ static int medmysql_flush_cdr(struct medmysql_batches *batches) {
batches->cdrs.len = 0;
syslog(LOG_CRIT, "Error inserting cdrs: %s",
mysql_error(cdr_handler));
/*
// agranig: tmp. way to log failed query, since it's too big
// for syslog. Make this configurable (path, enable) via
// cmd line switches
qlog = fopen("/var/log/ngcp/cdr-query.log", "a");
if(qlog == NULL)
{
syslog(LOG_CRIT, "Failed to open cdr query log file '/var/log/ngcp/cdr-query.log': %s", strerror(errno));
return -1;
}
if(fputs(batches->cdrs.str, qlog) == EOF)
{
syslog(LOG_CRIT, "Failed to write to cdr query log file '/var/log/ngcp/cdr-query.log': %s", strerror(errno));
}
fclose(qlog);
*/
return -1;
}

Loading…
Cancel
Save