eloop: Add eloop_sock_requeue()

This function can be used to re-build eloop socket tables after forking
for eloop implementations that need this.

Signed-off-by: Roy Marples <roy@marples.name>
This commit is contained in:
Roy Marples 2016-01-22 20:28:25 +00:00 committed by Jouni Malinen
parent 70f4f052f1
commit 2e69bdd16a
8 changed files with 35 additions and 7 deletions

View file

@ -1444,7 +1444,7 @@ int main(int argc, char *argv[])
}
}
if (daemonize && os_daemonize(pid_file))
if (daemonize && os_daemonize(pid_file) && eloop_sock_requeue())
return -1;
if (interactive)

View file

@ -408,9 +408,16 @@ static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
}
#endif /* EAP_SERVER_TNC */
if (daemonize && os_daemonize(pid_file)) {
wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
return -1;
if (daemonize) {
if (os_daemonize(pid_file)) {
wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
return -1;
}
if (eloop_sock_requeue()) {
wpa_printf(MSG_ERROR, "eloop_sock_requeue: %s",
strerror(errno));
return -1;
}
}
eloop_run();

View file

@ -525,6 +525,12 @@ static void eloop_sock_table_dispatch(struct epoll_event *events, int nfds)
#endif /* CONFIG_ELOOP_EPOLL */
int eloop_sock_requeue(void)
{
return 0;
}
static void eloop_sock_table_destroy(struct eloop_sock_table *table)
{
if (table) {

View file

@ -312,6 +312,14 @@ int eloop_register_signal_terminate(eloop_signal_handler handler,
int eloop_register_signal_reconfig(eloop_signal_handler handler,
void *user_data);
/**
* eloop_sock_requeue - Requeue sockets
*
* Requeue sockets after forking because some implementations require this,
* such as epoll and kqueue.
*/
int eloop_sock_requeue(void);
/**
* eloop_run - Start the event loop
*

View file

@ -692,3 +692,9 @@ void eloop_wait_for_read_sock(int sock)
WSAEventSelect(sock, event, 0);
WSACloseEvent(event);
}
int eloop_sock_requeue(void)
{
return 0;
}

View file

@ -4441,7 +4441,7 @@ int main(int argc, char *argv[])
}
}
if (daemonize && os_daemonize(pid_file))
if (daemonize && os_daemonize(pid_file) && eloop_sock_requeue())
return -1;
if (action_file)

View file

@ -1128,7 +1128,7 @@ int main(int argc, char *argv[])
interfaces = iface;
}
if (daemonize && os_daemonize(pid_file))
if (daemonize && os_daemonize(pid_file) && eloop_sock_requeue())
goto out;
eloop_register_signal_terminate(wpa_priv_terminate, NULL);

View file

@ -5221,7 +5221,8 @@ int wpa_supplicant_run(struct wpa_global *global)
struct wpa_supplicant *wpa_s;
if (global->params.daemonize &&
wpa_supplicant_daemon(global->params.pid_file))
(wpa_supplicant_daemon(global->params.pid_file) ||
eloop_sock_requeue()))
return -1;
if (global->params.wait_for_monitor) {