From 8cb871e0d2c1fd9b34047d61186c415211a18988 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 14 Jan 2021 14:43:28 +0100 Subject: [PATCH] Fix some cleaning bugs --- src/meas_lat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/meas_lat.c b/src/meas_lat.c index 6cb94b9..250510a 100644 --- a/src/meas_lat.c +++ b/src/meas_lat.c @@ -83,13 +83,21 @@ struct evt_core_fdinfo* register_timer(struct evt_core_ctx* evts, struct measlat } int on_receive_measure_packet_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { + struct measlat_ctx* mctx = fdinfo->cat->app_ctx; + printf("An error occured with socket %d\n", fdinfo->fd); char url[255]; sprintf(url, "timer:%d", fdinfo->fd); struct evt_core_fdinfo* assoc_timer = evt_core_get_from_url (ctx, url); - if (assoc_timer != NULL) evt_core_rm_fd (ctx, assoc_timer->fd); + if (assoc_timer != NULL) { + evt_core_rm_fd (ctx, assoc_timer->fd); + printf("Deleted associated timer %s\n", url); + } else { + printf("No associated timer %s\n", url); + } - return 1; + if (mctx->connectionless) return 1; + else return 0; } void measlat_stop( @@ -294,8 +302,8 @@ void register_categories(struct evt_core_ctx* evts, struct measlat_ctx* mctx) { template.flags = EPOLLIN | EPOLLET; evt_core_add_cat(evts, &template); - template.cb = on_receive_measure_packet; // intended but not elegant - template.err_cb = NULL; // intended but not elegant + template.cb = on_receive_measure_packet; + template.err_cb = on_receive_measure_packet_err; template.name = "tcp-read"; template.flags = EPOLLIN | EPOLLET; evt_core_add_cat(evts, &template);