From df509539d43dc6826cbe2e22debc3ce70d4a34e6 Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Sun, 29 Jan 2012 20:15:48 +0200 Subject: [PATCH] Let wpa_supplicant_deinit_iface() know that process is terminating This will be needed to be able to move ctrl_iface TERMINATING event to the end of interface removal. Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 2 +- wpa_supplicant/dbus/dbus_new_handlers.c | 2 +- wpa_supplicant/dbus/dbus_old_handlers.c | 2 +- wpa_supplicant/p2p_supplicant.c | 4 ++-- wpa_supplicant/wpa_supplicant.c | 13 +++++++------ wpa_supplicant/wpa_supplicant_i.h | 3 ++- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index ad3cbb9cb..88981d4b0 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -3883,7 +3883,7 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global, wpa_s = wpa_supplicant_get_iface(global, cmd); if (wpa_s == NULL) return -1; - return wpa_supplicant_remove_iface(global, wpa_s); + return wpa_supplicant_remove_iface(global, wpa_s, 0); } diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 621653f38..da67beae8 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -576,7 +576,7 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message, wpa_s = get_iface_by_dbus_path(global, path); if (wpa_s == NULL) reply = wpas_dbus_error_iface_unknown(message); - else if (wpa_supplicant_remove_iface(global, wpa_s)) { + else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) { reply = wpas_dbus_error_unknown_error( message, "wpa_supplicant couldn't remove this " "interface."); diff --git a/wpa_supplicant/dbus/dbus_old_handlers.c b/wpa_supplicant/dbus/dbus_old_handlers.c index a7eabf35c..8370a95bb 100644 --- a/wpa_supplicant/dbus/dbus_old_handlers.c +++ b/wpa_supplicant/dbus/dbus_old_handlers.c @@ -229,7 +229,7 @@ DBusMessage * wpas_dbus_global_remove_interface(DBusMessage *message, goto out; } - if (!wpa_supplicant_remove_iface(global, wpa_s)) { + if (!wpa_supplicant_remove_iface(global, wpa_s, 0)) { reply = wpas_dbus_new_success_reply(message); } else { reply = dbus_message_new_error(message, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4c271e1e4..a6298a7dd 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -280,7 +280,7 @@ static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s) global = wpa_s->global; ifname = os_strdup(wpa_s->ifname); type = wpas_p2p_if_type(wpa_s->p2p_group_interface); - wpa_supplicant_remove_iface(wpa_s->global, wpa_s); + wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); wpa_s = global->ifaces; if (wpa_s && ifname) wpa_drv_if_remove(wpa_s, type, ifname); @@ -2449,7 +2449,7 @@ void wpas_p2p_deinit_global(struct wpa_global *global) break; ifname = os_strdup(tmp->ifname); type = wpas_p2p_if_type(tmp->p2p_group_interface); - wpa_supplicant_remove_iface(global, tmp); + wpa_supplicant_remove_iface(global, tmp, 0); if (ifname) wpa_drv_if_remove(wpa_s, type, ifname); os_free(ifname); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 90363fed7..45149ffca 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2402,7 +2402,7 @@ next_driver: static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, - int notify) + int notify, int terminate) { if (wpa_s->drv_priv) { wpa_supplicant_deauthenticate(wpa_s, @@ -2468,14 +2468,14 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, if (wpa_supplicant_init_iface(wpa_s, &t_iface)) { wpa_printf(MSG_DEBUG, "Failed to add interface %s", iface->ifname); - wpa_supplicant_deinit_iface(wpa_s, 0); + wpa_supplicant_deinit_iface(wpa_s, 0, 0); os_free(wpa_s); return NULL; } /* Notify the control interfaces about new iface */ if (wpas_notify_iface_added(wpa_s)) { - wpa_supplicant_deinit_iface(wpa_s, 1); + wpa_supplicant_deinit_iface(wpa_s, 1, 0); os_free(wpa_s); return NULL; } @@ -2504,7 +2504,8 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, * %wpa_supplicant is terminated. */ int wpa_supplicant_remove_iface(struct wpa_global *global, - struct wpa_supplicant *wpa_s) + struct wpa_supplicant *wpa_s, + int terminate) { struct wpa_supplicant *prev; @@ -2524,7 +2525,7 @@ int wpa_supplicant_remove_iface(struct wpa_global *global, if (global->p2p_group_formation == wpa_s) global->p2p_group_formation = NULL; - wpa_supplicant_deinit_iface(wpa_s, 1); + wpa_supplicant_deinit_iface(wpa_s, 1, terminate); os_free(wpa_s); return 0; @@ -2740,7 +2741,7 @@ void wpa_supplicant_deinit(struct wpa_global *global) #endif /* CONFIG_P2P */ while (global->ifaces) - wpa_supplicant_remove_iface(global, global->ifaces); + wpa_supplicant_remove_iface(global, global->ifaces, 1); if (global->ctrl_iface) wpa_supplicant_global_ctrl_iface_deinit(global->ctrl_iface); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 8ae2500e4..91982e581 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -578,7 +578,8 @@ void wpa_show_license(void); struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, struct wpa_interface *iface); int wpa_supplicant_remove_iface(struct wpa_global *global, - struct wpa_supplicant *wpa_s); + struct wpa_supplicant *wpa_s, + int terminate); struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global, const char *ifname); struct wpa_global * wpa_supplicant_init(struct wpa_params *params);