From e17d2d63c2e3565e9e8974bdee216b18b1a6d820 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 2 Mar 2015 16:19:08 +0200 Subject: [PATCH] agent: Make sure Release is sent when iwd exits The main loop cannot be quit in signal handler as that would prevent the agent.c from sending the Release command to the agent. --- src/main.c | 14 +++++++++++++- src/manager.c | 2 -- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 64f7702e..300fc8f2 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,14 @@ #include "src/wiphy.h" #include "src/kdbus.h" #include "src/dbus.h" +#include "src/agent.h" + +static struct l_timeout *timeout = NULL; + +static void main_loop_quit(struct l_timeout *timeout, void *user_data) +{ + l_main_quit(); +} static void signal_handler(struct l_signal *signal, uint32_t signo, void *user_data) @@ -41,7 +49,10 @@ static void signal_handler(struct l_signal *signal, uint32_t signo, case SIGINT: case SIGTERM: l_info("Terminate"); - l_main_quit(); + + agent_exit(); + + timeout = l_timeout_create(1, main_loop_quit, NULL, NULL); break; } } @@ -171,6 +182,7 @@ destroy: done: l_signal_remove(signal); + l_timeout_remove(timeout); return exit_status; } diff --git a/src/manager.c b/src/manager.c index a5366b83..801ed97f 100644 --- a/src/manager.c +++ b/src/manager.c @@ -132,7 +132,5 @@ bool manager_exit(struct l_dbus *dbus) l_dbus_unregister_interface(dbus, IWD_MANAGER_PATH, IWD_MANAGER_INTERFACE); - agent_exit(); - return true; }