TT#44000 support trashing of acc entries that are too old

Change-Id: I9e402dba80fac82f0aeca0b1d78a079510430b83
changes/58/23258/1
Richard Fuchs 8 years ago
parent 0e7d468442
commit a0f63f3f52

@ -158,6 +158,7 @@ int cdr_process_records(med_entry_t *records, uint64_t count, uint64_t *ext_coun
L_DEBUG("No BYE message for callid '%s' found, skipping...",
callid);
*/
trash = 1;
}
}
else

@ -42,6 +42,7 @@ med_stats_period_t config_stats_period = MEDIATOR_DEFAULT_STATSPERIOD;
int config_maintenance = 0;
int strict_leg_tokens = 0;
int config_max_acc_age = 0;
med_loglevel_t config_loglevel = MEDIATOR_DEFAULT_LOGLEVEL;
@ -79,9 +80,10 @@ enum config_option {
OPT_STATS_PERIOD = 'x',
OPT_MAINTENANCE = 'm',
OPT_LEG_TOKENS = 's',
OPT_MAX_ACC_AGE = 'M',
};
static const char options[] = "?a:c:e:D:i:dlL:h:u:p:b:o:H:U:P:B:O:S:t:T:r:R:A:N:Z:z:W:w:X:x:ms";
static const char options[] = "?a:c:e:D:i:dlL:h:u:p:b:o:H:U:P:B:O:S:t:T:r:R:A:N:Z:z:W:w:X:x:msM:";
struct option long_options[] = {
{ "configfile", required_argument, NULL, OPT_CONFIGFILE },
@ -117,6 +119,7 @@ struct option long_options[] = {
{ "stats-period", required_argument, NULL, OPT_STATS_PERIOD },
{ "maintenance", no_argument, NULL, OPT_MAINTENANCE },
{ "leg-tokens", no_argument, NULL, OPT_LEG_TOKENS },
{ "max-acc-age", required_argument, NULL, OPT_MAX_ACC_AGE },
{ NULL, 0, NULL, 0 },
};
@ -160,6 +163,7 @@ static void config_help(const char *self, int rc)
" -r, --redis-db DB\tThe redis usrloc db number (default = '%d').\n" \
" -m, --maintenance\tMaintenance mode (do nothing, just sleep).\n" \
" -s, --leg-tokens\tStrict acc fields (move to trash otherwise).\n" \
" -M, --max-acc-age\tMaximum age of acc records before trashing them (default = disabled).\n" \
" -?, --help\t\tDisplays this message.\n",
MEDIATOR_VERSION, self, MEDIATOR_DEFAULT_CONFIG_FILE,
MEDIATOR_DEFAULT_PIDPATH, MEDIATOR_DEFAULT_LOGLEVEL,
@ -296,6 +300,9 @@ static void config_set_option(enum config_option option, const char *value)
case OPT_LEG_TOKENS:
strict_leg_tokens = 1;
break;
case OPT_MAX_ACC_AGE:
config_max_acc_age = atoi(value);
break;
}
}

@ -43,6 +43,7 @@ extern uint8_t config_dumpcdr;
extern int config_maintenance;
extern int strict_leg_tokens;
extern int config_max_acc_age;
extern med_loglevel_t config_loglevel;

@ -1,5 +1,6 @@
#include "records.h"
#include "config.h"
#include <time.h>
#define comp_ret(a_var, b_var) \
do { \
@ -31,6 +32,13 @@ int records_complete(med_entry_t *records, uint64_t count)
uint8_t has_bye = 0;
uint8_t has_inv_200 = 0;
// if our records are old enough, we always consider them complete
if (count && config_max_acc_age)
{
if (time(NULL) - records[0].unix_timestamp > config_max_acc_age)
return 1;
}
for (uint64_t i = 0; i < count; i++)
{
med_entry_t *s = &records[i];

Loading…
Cancel
Save