diff --git a/hostapd/main.c b/hostapd/main.c index 689248367..77f205047 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -251,7 +251,7 @@ hostapd_interface_init(struct hapd_interfaces *interfaces, /** * handle_term - SIGINT and SIGTERM handler to terminate hostapd process */ -static void handle_term(int sig, void *eloop_ctx, void *signal_ctx) +static void handle_term(int sig, void *signal_ctx) { wpa_printf(MSG_DEBUG, "Signal %d received - terminating", sig); eloop_terminate(); @@ -262,19 +262,19 @@ static void handle_term(int sig, void *eloop_ctx, void *signal_ctx) /** * handle_reload - SIGHUP handler to reload configuration */ -static void handle_reload(int sig, void *eloop_ctx, void *signal_ctx) +static void handle_reload(int sig, void *signal_ctx) { - struct hapd_interfaces *interfaces = eloop_ctx; + struct hapd_interfaces *interfaces = signal_ctx; wpa_printf(MSG_DEBUG, "Signal %d received - reloading configuration", sig); hostapd_for_each_interface(interfaces, handle_reload_iface, NULL); } -static void handle_dump_state(int sig, void *eloop_ctx, void *signal_ctx) +static void handle_dump_state(int sig, void *signal_ctx) { #ifdef HOSTAPD_DUMP_STATE - struct hapd_interfaces *interfaces = eloop_ctx; + struct hapd_interfaces *interfaces = signal_ctx; hostapd_for_each_interface(interfaces, handle_dump_state_iface, NULL); #endif /* HOSTAPD_DUMP_STATE */ } @@ -290,16 +290,16 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces) return -1; } - if (eloop_init(interfaces)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); return -1; } #ifndef CONFIG_NATIVE_WINDOWS - eloop_register_signal(SIGHUP, handle_reload, NULL); - eloop_register_signal(SIGUSR1, handle_dump_state, NULL); + eloop_register_signal(SIGHUP, handle_reload, interfaces); + eloop_register_signal(SIGUSR1, handle_dump_state, interfaces); #endif /* CONFIG_NATIVE_WINDOWS */ - eloop_register_signal_terminate(handle_term, NULL); + eloop_register_signal_terminate(handle_term, interfaces); #ifndef CONFIG_NATIVE_WINDOWS openlog("hostapd", 0, LOG_DAEMON); diff --git a/radius_example/radius_example.c b/radius_example/radius_example.c index 59982abbd..4ff4337e8 100644 --- a/radius_example/radius_example.c +++ b/radius_example/radius_example.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) os_memset(&ctx, 0, sizeof(ctx)); inet_aton("127.0.0.1", &ctx.own_ip_addr); - if (eloop_init(&ctx)) { + if (eloop_init()) { printf("Failed to initialize event loop\n"); return -1; } diff --git a/src/utils/eloop.c b/src/utils/eloop.c index 59fab9901..a6b60254a 100644 --- a/src/utils/eloop.c +++ b/src/utils/eloop.c @@ -50,8 +50,6 @@ struct eloop_sock_table { }; struct eloop_data { - void *user_data; - int max_sock; struct eloop_sock_table readers; @@ -81,10 +79,9 @@ static void eloop_sigsegv_handler(int sig) #endif /* WPA_TRACE */ -int eloop_init(void *user_data) +int eloop_init(void) { os_memset(&eloop, 0, sizeof(eloop)); - eloop.user_data = user_data; #ifdef WPA_TRACE signal(SIGSEGV, eloop_sigsegv_handler); #endif /* WPA_TRACE */ @@ -408,7 +405,6 @@ static void eloop_process_pending_signals(void) if (eloop.signals[i].signaled) { eloop.signals[i].signaled = 0; eloop.signals[i].handler(eloop.signals[i].sig, - eloop.user_data, eloop.signals[i].user_data); } } @@ -588,9 +584,3 @@ void eloop_wait_for_read_sock(int sock) FD_SET(sock, &rfds); select(sock + 1, &rfds, NULL, NULL, NULL); } - - -void * eloop_get_user_data(void) -{ - return eloop.user_data; -} diff --git a/src/utils/eloop.h b/src/utils/eloop.h index cf83f3836..1228f24d2 100644 --- a/src/utils/eloop.h +++ b/src/utils/eloop.h @@ -65,25 +65,19 @@ typedef void (*eloop_timeout_handler)(void *eloop_data, void *user_ctx); /** * eloop_signal_handler - eloop signal event callback type * @sig: Signal number - * @eloop_ctx: Registered callback context data (global user_data from - * eloop_init() call) * @signal_ctx: Registered callback context data (user_data from * eloop_register_signal(), eloop_register_signal_terminate(), or * eloop_register_signal_reconfig() call) */ -typedef void (*eloop_signal_handler)(int sig, void *eloop_ctx, - void *signal_ctx); +typedef void (*eloop_signal_handler)(int sig, void *signal_ctx); /** * eloop_init() - Initialize global event loop data - * @user_data: Pointer to global data passed as eloop_ctx to signal handlers * Returns: 0 on success, -1 on failure * - * This function must be called before any other eloop_* function. user_data - * can be used to configure a global (to the process) pointer that will be - * passed as eloop_ctx parameter to signal handlers. + * This function must be called before any other eloop_* function. */ -int eloop_init(void *user_data); +int eloop_init(void); /** * eloop_register_read_sock - Register handler for read events @@ -231,10 +225,6 @@ int eloop_is_timeout_registered(eloop_timeout_handler handler, * handler has returned. This means that the normal limits for sighandlers * (i.e., only "safe functions" allowed) do not apply for the registered * callback. - * - * Signals are 'global' events and there is no local eloop_data pointer like - * with other handlers. The global user_data pointer registered with - * eloop_init() will be used as eloop_ctx for signal handlers. */ int eloop_register_signal(int sig, eloop_signal_handler handler, void *user_data); @@ -251,10 +241,6 @@ int eloop_register_signal(int sig, eloop_signal_handler handler, * sighandlers (i.e., only "safe functions" allowed) do not apply for the * registered callback. * - * Signals are 'global' events and there is no local eloop_data pointer like - * with other handlers. The global user_data pointer registered with - * eloop_init() will be used as eloop_ctx for signal handlers. - * * This function is a more portable version of eloop_register_signal() since * the knowledge of exact details of the signals is hidden in eloop * implementation. In case of operating systems using signal(), this function @@ -275,10 +261,6 @@ int eloop_register_signal_terminate(eloop_signal_handler handler, * limits for sighandlers (i.e., only "safe functions" allowed) do not apply * for the registered callback. * - * Signals are 'global' events and there is no local eloop_data pointer like - * with other handlers. The global user_data pointer registered with - * eloop_init() will be used as eloop_ctx for signal handlers. - * * This function is a more portable version of eloop_register_signal() since * the knowledge of exact details of the signals is hidden in eloop * implementation. In case of operating systems using signal(), this function @@ -331,10 +313,4 @@ int eloop_terminated(void); */ void eloop_wait_for_read_sock(int sock); -/** - * eloop_get_user_data - Get global user data - * Returns: user_data pointer that was registered with eloop_init() - */ -void * eloop_get_user_data(void); - #endif /* ELOOP_H */ diff --git a/src/utils/eloop_none.c b/src/utils/eloop_none.c index 215030b21..18eae4e5a 100644 --- a/src/utils/eloop_none.c +++ b/src/utils/eloop_none.c @@ -41,8 +41,6 @@ struct eloop_signal { }; struct eloop_data { - void *user_data; - int max_sock, reader_count; struct eloop_sock *readers; @@ -60,10 +58,9 @@ struct eloop_data { static struct eloop_data eloop; -int eloop_init(void *user_data) +int eloop_init(void) { memset(&eloop, 0, sizeof(eloop)); - eloop.user_data = user_data; return 0; } @@ -402,9 +399,3 @@ void eloop_wait_for_read_sock(int sock) * reading */ } - - -void * eloop_get_user_data(void) -{ - return eloop.user_data; -} diff --git a/src/utils/eloop_win.c b/src/utils/eloop_win.c index c95aa76b7..671a7760f 100644 --- a/src/utils/eloop_win.c +++ b/src/utils/eloop_win.c @@ -50,8 +50,6 @@ struct eloop_signal { }; struct eloop_data { - void *user_data; - int max_sock; size_t reader_count; struct eloop_sock *readers; @@ -79,10 +77,9 @@ struct eloop_data { static struct eloop_data eloop; -int eloop_init(void *user_data) +int eloop_init(void) { os_memset(&eloop, 0, sizeof(eloop)); - eloop.user_data = user_data; eloop.num_handles = 1; eloop.handles = os_malloc(eloop.num_handles * sizeof(eloop.handles[0])); @@ -614,9 +611,3 @@ void eloop_wait_for_read_sock(int sock) WSAEventSelect(sock, event, 0); WSACloseEvent(event); } - - -void * eloop_get_user_data(void) -{ - return eloop.user_data; -} diff --git a/wpa_supplicant/ctrl_iface_dbus.c b/wpa_supplicant/ctrl_iface_dbus.c index 06f5a886b..709e947fe 100644 --- a/wpa_supplicant/ctrl_iface_dbus.c +++ b/wpa_supplicant/ctrl_iface_dbus.c @@ -208,7 +208,7 @@ static void timeout_toggled(DBusTimeout *timeout, void *data) } -static void process_wakeup_main(int sig, void *eloop_ctx, void *signal_ctx) +static void process_wakeup_main(int sig, void *signal_ctx) { struct ctrl_iface_dbus_priv *iface = signal_ctx; diff --git a/wpa_supplicant/ctrl_iface_dbus_new_helpers.c b/wpa_supplicant/ctrl_iface_dbus_new_helpers.c index 02738721d..d2da61594 100644 --- a/wpa_supplicant/ctrl_iface_dbus_new_helpers.c +++ b/wpa_supplicant/ctrl_iface_dbus_new_helpers.c @@ -270,7 +270,7 @@ static void timeout_toggled(DBusTimeout *timeout, void *data) } -static void process_wakeup_main(int sig, void *eloop_ctx, void *signal_ctx) +static void process_wakeup_main(int sig, void *signal_ctx) { struct ctrl_iface_dbus_new_priv *iface = signal_ctx; diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c index c73ec8590..4eed85413 100644 --- a/wpa_supplicant/eapol_test.c +++ b/wpa_supplicant/eapol_test.c @@ -949,10 +949,9 @@ static int scard_get_triplets(int argc, char *argv[]) } -static void eapol_test_terminate(int sig, void *eloop_ctx, - void *signal_ctx) +static void eapol_test_terminate(int sig, void *signal_ctx) { - struct wpa_supplicant *wpa_s = eloop_ctx; + struct wpa_supplicant *wpa_s = signal_ctx; wpa_msg(wpa_s, MSG_INFO, "Signal %d received - terminating", sig); eloop_terminate(); } @@ -1128,7 +1127,7 @@ int main(int argc, char *argv[]) return -1; } - if (eloop_init(&wpa_s)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); return -1; } @@ -1171,8 +1170,8 @@ int main(int argc, char *argv[]) eloop_register_timeout(timeout, 0, eapol_test_timeout, &eapol_test, NULL); eloop_register_timeout(0, 0, send_eap_request_identity, &wpa_s, NULL); - eloop_register_signal_terminate(eapol_test_terminate, NULL); - eloop_register_signal_reconfig(eapol_test_terminate, NULL); + eloop_register_signal_terminate(eapol_test_terminate, &wpa_s); + eloop_register_signal_reconfig(eapol_test_terminate, &wpa_s); eloop_run(); eloop_cancel_timeout(eapol_test_timeout, &eapol_test, NULL); diff --git a/wpa_supplicant/preauth_test.c b/wpa_supplicant/preauth_test.c index a24d65f27..cebe2bac6 100644 --- a/wpa_supplicant/preauth_test.c +++ b/wpa_supplicant/preauth_test.c @@ -277,10 +277,9 @@ static void wpa_init_conf(struct wpa_supplicant *wpa_s, const char *ifname) } -static void eapol_test_terminate(int sig, void *eloop_ctx, - void *signal_ctx) +static void eapol_test_terminate(int sig, void *signal_ctx) { - struct wpa_supplicant *wpa_s = eloop_ctx; + struct wpa_supplicant *wpa_s = signal_ctx; wpa_msg(wpa_s, MSG_INFO, "Signal %d received - terminating", sig); eloop_terminate(); } @@ -317,7 +316,7 @@ int main(int argc, char *argv[]) return -1; } - if (eloop_init(&wpa_s)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); return -1; } @@ -354,8 +353,8 @@ int main(int argc, char *argv[]) eloop_register_timeout(30, 0, eapol_test_timeout, &preauth_test, NULL); eloop_register_timeout(0, 100000, eapol_test_poll, &wpa_s, NULL); - eloop_register_signal_terminate(eapol_test_terminate, NULL); - eloop_register_signal_reconfig(eapol_test_terminate, NULL); + eloop_register_signal_terminate(eapol_test_terminate, &wpa_s); + eloop_register_signal_reconfig(eapol_test_terminate, &wpa_s); eloop_run(); if (preauth_test.auth_timed_out) diff --git a/wpa_supplicant/tests/test_wpa.c b/wpa_supplicant/tests/test_wpa.c index 77fc36a14..7249ffb1e 100644 --- a/wpa_supplicant/tests/test_wpa.c +++ b/wpa_supplicant/tests/test_wpa.c @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) wpa_debug_level = 0; wpa_debug_show_keys = 1; - if (eloop_init(&wpa)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); return -1; } diff --git a/wpa_supplicant/wpa_priv.c b/wpa_supplicant/wpa_priv.c index bb9095ba9..b7825ed2a 100644 --- a/wpa_supplicant/wpa_priv.c +++ b/wpa_supplicant/wpa_priv.c @@ -1029,7 +1029,7 @@ int main(int argc, char *argv[]) wpa_printf(MSG_DEBUG, "wpa_priv control directory: '%s'", ctrl_dir); - if (eloop_init(NULL)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); goto out; } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index d79866138..df7d1d557 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -546,10 +546,9 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state) } -static void wpa_supplicant_terminate(int sig, void *eloop_ctx, - void *signal_ctx) +static void wpa_supplicant_terminate(int sig, void *signal_ctx) { - struct wpa_global *global = eloop_ctx; + struct wpa_global *global = signal_ctx; struct wpa_supplicant *wpa_s; for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING "- signal %d " @@ -647,10 +646,9 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s) } -static void wpa_supplicant_reconfig(int sig, void *eloop_ctx, - void *signal_ctx) +static void wpa_supplicant_reconfig(int sig, void *signal_ctx) { - struct wpa_global *global = eloop_ctx; + struct wpa_global *global = signal_ctx; struct wpa_supplicant *wpa_s; wpa_printf(MSG_DEBUG, "Signal %d received - reconfiguring", sig); for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { @@ -2320,7 +2318,7 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params) wpa_debug_timestamp = global->params.wpa_debug_timestamp = params->wpa_debug_timestamp; - if (eloop_init(global)) { + if (eloop_init()) { wpa_printf(MSG_ERROR, "Failed to initialize event loop"); wpa_supplicant_deinit(global); return NULL; @@ -2389,8 +2387,8 @@ int wpa_supplicant_run(struct wpa_global *global) wpa_s->ctrl_iface); } - eloop_register_signal_terminate(wpa_supplicant_terminate, NULL); - eloop_register_signal_reconfig(wpa_supplicant_reconfig, NULL); + eloop_register_signal_terminate(wpa_supplicant_terminate, global); + eloop_register_signal_reconfig(wpa_supplicant_reconfig, global); eloop_run();