From d2cea315d1c1cc0b968a55ce314c57333268ff22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Arreola=20Rodr=C3=ADguez?= Date: Thu, 2 Jan 2020 12:54:37 -0600 Subject: [PATCH] Agrego el cierre del socket de eventos del netlink. --- src/main.c | 3 +++ src/netlink-events.c | 12 ++++++++++++ src/netlink-events.h | 1 + 3 files changed, 16 insertions(+) diff --git a/src/main.c b/src/main.c index 44991fd..05098c6 100644 --- a/src/main.c +++ b/src/main.c @@ -131,5 +131,8 @@ int main (int argc, char *argv[]) { g_main_loop_run (loop); + /* Detener la llegada de eventos */ + netlink_events_clear (&handle); + return 0; } diff --git a/src/netlink-events.c b/src/netlink-events.c index b9fb1b1..6a21b56 100644 --- a/src/netlink-events.c +++ b/src/netlink-events.c @@ -85,3 +85,15 @@ void netlink_events_setup (NetworkInadorHandle *handle) { handle->nl_sock_route_events = sock_req; } +void netlink_events_clear (NetworkInadorHandle *handle) { + /* Primero, detener los eventos del source watch */ + + g_source_remove (handle->route_events_source); + + handle->route_events_source = 0; + /* Cerrar el socket */ + + nl_close (handle->nl_sock_route_events); + handle->nl_sock_route_events = NULL; +} + diff --git a/src/netlink-events.h b/src/netlink-events.h index f231122..68bace6 100644 --- a/src/netlink-events.h +++ b/src/netlink-events.h @@ -26,5 +26,6 @@ #include "common.h" void netlink_events_setup (NetworkInadorHandle *handle); +void netlink_events_clear (NetworkInadorHandle *handle); #endif