eloop: Add eloop_sock_requeue()
authorRoy Marples <roy@marples.name>
Fri, 22 Jan 2016 20:28:25 +0000 (20:28 +0000)
committerJouni Malinen <j@w1.fi>
Sun, 7 Feb 2016 10:38:04 +0000 (12:38 +0200)
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>
hostapd/hostapd_cli.c
hostapd/main.c
src/utils/eloop.c
src/utils/eloop.h
src/utils/eloop_win.c
wpa_supplicant/wpa_cli.c
wpa_supplicant/wpa_priv.c
wpa_supplicant/wpa_supplicant.c

index 52dfc9f..7e6ac23 100644 (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)
index 4913cbd..1b9002c 100644 (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();
index 8647229..fda1a83 100644 (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) {
index 07b8c0d..97af16f 100644 (file)
@@ -313,6 +313,14 @@ 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
  *
  * Start the event loop and continue running as long as there are any
index de47fb2..9c8b12b 100644 (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;
+}
index 1aea0a6..265f72c 100644 (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)
index fa5a6de..3f91cc1 100644 (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);
index 03b1353..c3c1f14 100644 (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) {