aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/eloop_win.c
diff options
context:
space:
mode:
authorKyeyoon Park <kyeyoonp@qca.qualcomm.com>2013-11-06 08:11:35 (GMT)
committerJouni Malinen <j@w1.fi>2013-11-07 22:22:32 (GMT)
commite5e74e55002349b44d27ea0f25e43bc5d7e7f74e (patch)
treeeb5df54c6ed6fcb651604913273cfc367d97d4f4 /src/utils/eloop_win.c
parentb7997e01dba714413ac346cf2600720673e83738 (diff)
downloadhostap-e5e74e55002349b44d27ea0f25e43bc5d7e7f74e.zip
hostap-e5e74e55002349b44d27ea0f25e43bc5d7e7f74e.tar.gz
hostap-e5e74e55002349b44d27ea0f25e43bc5d7e7f74e.tar.bz2
eloop: Add support for replenishing a registered timeout
eloop_replenish_timeout() finds a registered matching <handler,eloop_data,user_data> timeout. If found, replenishes the timeout if remaining time is less than the requested time. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'src/utils/eloop_win.c')
-rw-r--r--src/utils/eloop_win.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/eloop_win.c b/src/utils/eloop_win.c
index eda412f..1f40530 100644
--- a/src/utils/eloop_win.c
+++ b/src/utils/eloop_win.c
@@ -354,6 +354,37 @@ int eloop_is_timeout_registered(eloop_timeout_handler handler,
}
+int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs,
+ eloop_timeout_handler handler, void *eloop_data,
+ void *user_data)
+{
+ struct os_time now, requested, remaining;
+ struct eloop_timeout *tmp;
+
+ dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
+ if (tmp->handler == handler &&
+ tmp->eloop_data == eloop_data &&
+ tmp->user_data == user_data) {
+ requested.sec = req_secs;
+ requested.usec = req_usecs;
+ os_get_time(&now);
+ os_time_sub(&tmp->time, &now, &remaining);
+ if (os_time_before(&remaining, &requested)) {
+ eloop_cancel_timeout(handler, eloop_data,
+ user_data);
+ eloop_register_timeout(requested.sec,
+ requested.usec,
+ handler, eloop_data,
+ user_data);
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
/* TODO: replace with suitable signal handler */
#if 0
static void eloop_handle_signal(int sig)