summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/handle_lat.c
diff options
context:
space:
mode:
authorXavier Simonart <simonartxavier@gmail.com>2022-01-07 15:02:22 +0000
committerXavier Simonart <simonartxavier@gmail.com>2022-01-10 19:43:25 +0000
commit7d46676d5d377dc9def2a266ebd9b6b86570e732 (patch)
treeda11de46843a5d6e08067b5658228520dffa61c1 /VNFs/DPPD-PROX/handle_lat.c
parent80eea140cb384fdce34d9681a1f0929016ca9b03 (diff)
Do not create (empty) latency loss file if disabled
Signed-off-by: Xavier Simonart <simonartxavier@gmail.com> Change-Id: Ia407e8d8bbdc19e8ca531b363c6cb0ed84ca5250
Diffstat (limited to 'VNFs/DPPD-PROX/handle_lat.c')
-rw-r--r--VNFs/DPPD-PROX/handle_lat.c12
1 files changed, 6 insertions, 6 deletions
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));