From 2901cb1169eab5b29179c46e0a844752fd669fb0 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Wed, 25 May 2016 01:37:19 +0200 Subject: [PATCH] main: Restore agent_exit call before main loop exit --- src/agent.c | 9 ++++++--- src/agent.h | 1 + src/dbus.c | 6 ++++++ src/dbus.h | 1 + src/main.c | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/agent.c b/src/agent.c index 7c4f6146..023fe711 100644 --- a/src/agent.c +++ b/src/agent.c @@ -447,11 +447,14 @@ bool agent_init(struct l_dbus *dbus) bool agent_exit(struct l_dbus *dbus) { - if (default_agent) - release_agent(default_agent); - l_dbus_unregister_object(dbus, IWD_AGENT_MANAGER_PATH); l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE); return true; } + +void agent_shutdown(void) +{ + if (default_agent) + release_agent(default_agent); +} diff --git a/src/agent.h b/src/agent.h index 8453a5ed..be683341 100644 --- a/src/agent.h +++ b/src/agent.h @@ -35,6 +35,7 @@ typedef void (*agent_request_passphrase_func_t) (enum agent_result result, bool agent_init(struct l_dbus *dbus); bool agent_exit(struct l_dbus *dbus); bool agent_setup(struct l_dbus_interface *interface); +void agent_shutdown(void); unsigned int agent_request_passphrase(const char *path, agent_request_passphrase_func_t callback, diff --git a/src/dbus.c b/src/dbus.c index 04fc0006..5cb41deb 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -246,3 +246,9 @@ bool dbus_exit(void) return true; } + +void dbus_shutdown(void) +{ + /* Allow AgentManager to send a Release call before disconnecting */ + agent_shutdown(); +} diff --git a/src/dbus.h b/src/dbus.h index 5a356e2c..1d6b6689 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -63,3 +63,4 @@ struct l_dbus_message *dbus_error_not_implemented(struct l_dbus_message *msg); bool dbus_init(bool enable_debug, bool use_kdbus); bool dbus_exit(void); +void dbus_shutdown(void); diff --git a/src/main.c b/src/main.c index ab3208f5..c08326a0 100644 --- a/src/main.c +++ b/src/main.c @@ -36,7 +36,6 @@ #include "src/device.h" #include "src/wiphy.h" #include "src/dbus.h" -#include "src/agent.h" #include "src/network.h" #include "src/eapol.h" #include "src/scan.h" @@ -59,6 +58,8 @@ static void signal_handler(struct l_signal *signal, uint32_t signo, case SIGTERM: l_info("Terminate"); + dbus_shutdown(); + timeout = l_timeout_create(1, main_loop_quit, NULL, NULL); break; }