X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhandle_lat.c;h=04a4848b82dd752cad13c7682dfb55f340e5b4ca;hb=refs%2Fheads%2Fmaster;hp=d6943070a345ab7f49e97ef1cc8d79a81f232828;hpb=971d163b345ab3f74d6a5252722371dc17a8fe7a;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/handle_lat.c b/VNFs/DPPD-PROX/handle_lat.c index d6943070..04a4848b 100644 --- a/VNFs/DPPD-PROX/handle_lat.c +++ b/VNFs/DPPD-PROX/handle_lat.c @@ -419,7 +419,7 @@ static void lat_stop(struct task_base *tbase) task_lat_reset_eld(task); memset(task->previous_packet, 0, sizeof(task->previous_packet) * task->generator_count); } - if (task->loss_id) { + if (task->loss_id && task->fp_loss) { for (uint i = 0; i < task->loss_id; i++) { fprintf(task->fp_loss, "packet %d: %d\n", task->loss_buffer[i].packet_id, task->loss_buffer[i].n); } @@ -842,11 +842,6 @@ static void init_task_lat(struct task_base *tbase, struct task_args *targ) init_task_lat_latency_buffer(task, targ->lconf->id); } - char name[256]; - sprintf(name, "loss_%u.txt", targ->lconf->id); - task->fp_loss = fopen(name, "w+"); - PROX_PANIC(task->fp_loss == NULL, "Failed to open %s\n", name); - if (targ->bucket_size < DEFAULT_BUCKET_SIZE) { targ->bucket_size = DEFAULT_BUCKET_SIZE; } @@ -901,6 +896,11 @@ static void init_task_lat(struct task_base *tbase, struct task_args *targ) } task->loss_buffer_size = targ->loss_buffer_size; if (task->loss_buffer_size) { + char name[256]; + sprintf(name, "loss_%u.txt", targ->lconf->id); + task->fp_loss = fopen(name, "w+"); + PROX_PANIC(task->fp_loss == NULL, "Failed to open %s\n", name); + task->loss_buffer = prox_zmalloc(task->loss_buffer_size * sizeof(struct loss_buffer), rte_lcore_to_socket_id(targ->lconf->id)); PROX_PANIC(task->loss_buffer == NULL, "Failed to allocate %lu bytes (in huge pages) for loss_buffer\n", task->loss_buffer_size * sizeof(struct loss_buffer));