TT#33319 don't hold large structure on the stack

avoids false positive from valgrind

Change-Id: Iae2ed784c701ca3d99f6a1a0fbee2308538fbe6c
changes/96/19396/3
Richard Fuchs 7 years ago
parent 2812d161a5
commit dd75641cc9

@ -156,7 +156,7 @@ int main(int argc, char **argv)
uint64_t mysql_id_count, redis_id_count, rec_count, i; uint64_t mysql_id_count, redis_id_count, rec_count, i;
uint64_t cdr_count, last_count; uint64_t cdr_count, last_count;
int maprefresh; int maprefresh;
struct medmysql_batches batches; struct medmysql_batches *batches;
struct timeval loop_tv_start, loop_tv_stop; struct timeval loop_tv_start, loop_tv_stop;
uint64_t loop_runtime; uint64_t loop_runtime;
#ifdef WITH_TIME_CALC #ifdef WITH_TIME_CALC
@ -234,6 +234,12 @@ int main(int argc, char **argv)
config_daemonize, config_pid_path, config_interval); config_daemonize, config_pid_path, config_interval);
maprefresh = 0; maprefresh = 0;
batches = malloc(sizeof(*batches));
if (!batches) {
L_ERROR("Out of memory allocating batches");
return -1;
}
while(!mediator_shutdown) while(!mediator_shutdown)
{ {
L_DEBUG("Starting mediation loop\n"); L_DEBUG("Starting mediation loop\n");
@ -272,7 +278,7 @@ int main(int argc, char **argv)
goto idle; goto idle;
} }
if (medmysql_batch_start(&batches)) { if (medmysql_batch_start(batches)) {
L_ERROR("Failed to start MySQL batches\n"); L_ERROR("Failed to start MySQL batches\n");
break; break;
} }
@ -290,7 +296,7 @@ int main(int argc, char **argv)
if(medmysql_fetch_records(&(mysql_callids[i]), &records, &rec_count) != 0) if(medmysql_fetch_records(&(mysql_callids[i]), &records, &rec_count) != 0)
goto out; goto out;
if(cdr_process_records(records, rec_count, &cdr_count, &batches) != 0) if(cdr_process_records(records, rec_count, &cdr_count, batches) != 0)
goto out; goto out;
if(rec_count > 0) if(rec_count > 0)
@ -327,7 +333,7 @@ int main(int argc, char **argv)
L_DEBUG("process cdr with cid '%s' and %"PRIu64" records\n", redis_callids[i].value, rec_count); L_DEBUG("process cdr with cid '%s' and %"PRIu64" records\n", redis_callids[i].value, rec_count);
if (rec_count) { if (rec_count) {
if(cdr_process_records(records, rec_count, &cdr_count, &batches) != 0) { if(cdr_process_records(records, rec_count, &cdr_count, batches) != 0) {
free(records); free(records);
goto out; goto out;
} }
@ -349,7 +355,7 @@ int main(int argc, char **argv)
//////////////// end ////////////////// //////////////// end //////////////////
if (medmysql_batch_end(&batches)) if (medmysql_batch_end(batches))
break; break;
gettimeofday(&loop_tv_stop, NULL); gettimeofday(&loop_tv_stop, NULL);
@ -377,6 +383,7 @@ out:
medmysql_cleanup(); medmysql_cleanup();
medredis_cleanup(); medredis_cleanup();
free(batches);
L_INFO("Successfully shut down."); L_INFO("Successfully shut down.");
return 0; return 0;

Loading…
Cancel
Save