aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/main.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2015-07-20 10:33:30 (GMT)
committerJouni Malinen <j@w1.fi>2015-07-20 10:33:30 (GMT)
commit3188aabaf1b04ac40c5baa8270cee72862568205 (patch)
tree3a1ca250e0b71db687ff2a05382e71a68c380e25 /hostapd/main.c
parent8c0d0ff22e402977ddf814d798a5c8e02a21199c (diff)
downloadhostap-3188aabaf1b04ac40c5baa8270cee72862568205.zip
hostap-3188aabaf1b04ac40c5baa8270cee72862568205.tar.gz
hostap-3188aabaf1b04ac40c5baa8270cee72862568205.tar.bz2
Add shared periodic cleanup function for AP mode
This new mechanism can be used to combine multiple periodic AP (including P2P GO) task into a single eloop timeout to minimize number of wakeups for the process. hostapd gets its own periodic caller and wpa_supplicant uses the previously added timer to trigger these calls. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'hostapd/main.c')
-rw-r--r--hostapd/main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/hostapd/main.c b/hostapd/main.c
index 534f182..6c7406a 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -534,6 +534,28 @@ static int gen_uuid(const char *txt_addr)
#endif /* CONFIG_WPS */
+#ifndef HOSTAPD_CLEANUP_INTERVAL
+#define HOSTAPD_CLEANUP_INTERVAL 10
+#endif /* HOSTAPD_CLEANUP_INTERVAL */
+
+static int hostapd_periodic_call(struct hostapd_iface *iface, void *ctx)
+{
+ hostapd_periodic_iface(iface);
+ return 0;
+}
+
+
+/* Periodic cleanup tasks */
+static void hostapd_periodic(void *eloop_ctx, void *timeout_ctx)
+{
+ struct hapd_interfaces *interfaces = eloop_ctx;
+
+ eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL, 0,
+ hostapd_periodic, interfaces, NULL);
+ hostapd_for_each_interface(interfaces, hostapd_periodic_call, NULL);
+}
+
+
int main(int argc, char *argv[])
{
struct hapd_interfaces interfaces;
@@ -667,6 +689,9 @@ int main(int argc, char *argv[])
return -1;
}
+ eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL, 0,
+ hostapd_periodic, &interfaces, NULL);
+
if (fst_global_init()) {
wpa_printf(MSG_ERROR,
"Failed to initialize global FST context");
@@ -762,6 +787,7 @@ int main(int argc, char *argv[])
}
os_free(interfaces.iface);
+ eloop_cancel_timeout(hostapd_periodic, &interfaces, NULL);
hostapd_global_deinit(pid_file);
os_free(pid_file);