TT#182200 fix CDR index bookkeeping

The `cdr_index` variable already tracks the number of created CDRs, as
it points to the slot for the next CDR record to be inserted. It's
increased by one at the start of the processing loop, so if we end up
skipping over an entry after it's been increased, it must be decreased
again, which keeps the count intact and prevents empty CDR records from
being created.

Fix-up for Ia7e8446fe4953d1391f99ea1530990e3d385c056

Change-Id: Ibb650a4b00978a272ef8f60751f6efda0491a912
(cherry picked from commit 4ffa758826)
mr10.4.1
Richard Fuchs 4 years ago
parent 683c99171c
commit 2d2cdd0b42

@ -1423,7 +1423,7 @@ static cdr_entry_t *alloc_cdrs(uint64_t cdr_count) {
static int cdr_create_cdrs(med_entry_t *records, uint64_t count,
cdr_entry_t **cdrs, uint64_t *cdr_count, uint64_t *alloc_size, uint8_t *trash, int do_intermediate)
{
uint64_t i = 0, cdr_index = 0, created = 0;
uint64_t i = 0, cdr_index = 0;
uint64_t invites = 0;
int timed_out = 0;
@ -1516,6 +1516,7 @@ static int cdr_create_cdrs(med_entry_t *records, uint64_t count,
if (validate_src_dst_leg(e))
{
L_DEBUG("Skip intermediate CDR index %lu without valid src_leg and dst_leg for call-id '%s'\n", cdr_index, e->callid);
cdr_index--;
continue;
}
@ -1528,8 +1529,6 @@ static int cdr_create_cdrs(med_entry_t *records, uint64_t count,
}
}
++created; // TODO: move to the end when everything is successful ?
g_string_assign(cdr->call_id, e->callid);
cdr->start_time = e->unix_timestamp;
cdr->duration = (tmp_unix_endtime >= e->unix_timestamp) ? tmp_unix_endtime - e->unix_timestamp : 0;
@ -1571,7 +1570,7 @@ static int cdr_create_cdrs(med_entry_t *records, uint64_t count,
return -1;
}
*cdr_count = created;
*cdr_count = cdr_index;
/*L_DEBUG("Created %llu CDRs:", *cdr_count);*/

Loading…
Cancel
Save