3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 05:39:24 +01:00

dbus: Use the shutdown procedure instead of l_main_quit

Move the calling of the *_shutdown functions from the signal handler to
a new public function, and use that function inside the DBus disconnect
handler to make sure resources are cleanly released.
This commit is contained in:
Andrew Zaborowski 2017-05-03 19:53:51 +02:00 committed by Denis Kenzior
parent faba9d509a
commit 33f8b1f53d
3 changed files with 13 additions and 6 deletions

View File

@ -31,6 +31,7 @@
#include <ell/dbus-private.h> #include <ell/dbus-private.h>
#include "src/dbus.h" #include "src/dbus.h"
#include "src/agent.h" #include "src/agent.h"
#include "src/iwd.h"
struct l_dbus *g_dbus = 0; struct l_dbus *g_dbus = 0;
@ -196,7 +197,7 @@ static void ready_callback(void *user_data)
static void disconnect_callback(void *user_data) static void disconnect_callback(void *user_data)
{ {
l_info("D-Bus disconnected, quitting..."); l_info("D-Bus disconnected, quitting...");
l_main_quit(); iwd_shutdown();
} }
struct l_dbus *dbus_get_bus(void) struct l_dbus *dbus_get_bus(void)

View File

@ -36,3 +36,5 @@ typedef void (*iwd_device_foreach_func)(struct device *, void *data);
void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data); void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data);
const struct l_settings *iwd_get_config(void); const struct l_settings *iwd_get_config(void);
void iwd_shutdown(void);

View File

@ -59,6 +59,14 @@ static void main_loop_quit(struct l_timeout *timeout, void *user_data)
l_main_quit(); l_main_quit();
} }
void iwd_shutdown(void)
{
dbus_shutdown();
netdev_shutdown();
timeout = l_timeout_create(1, main_loop_quit, NULL, NULL);
}
static void signal_handler(struct l_signal *signal, uint32_t signo, static void signal_handler(struct l_signal *signal, uint32_t signo,
void *user_data) void *user_data)
{ {
@ -66,11 +74,7 @@ static void signal_handler(struct l_signal *signal, uint32_t signo,
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
l_info("Terminate"); l_info("Terminate");
iwd_shutdown();
dbus_shutdown();
netdev_shutdown();
timeout = l_timeout_create(1, main_loop_quit, NULL, NULL);
break; break;
} }
} }