Fix some cleaning bugs

This commit is contained in:
Quentin 2021-01-14 14:43:28 +01:00
parent b5ad9f495e
commit 8cb871e0d2

View file

@ -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);