eloop: Remove global user data pointer
This is not really needed since all signal handlers can use a context pointer provided during signal handler registration.
This commit is contained in:
parent
9969e5a46a
commit
0456ea16d8
13 changed files with 37 additions and 93 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue