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>
This commit is contained in:
parent
b7997e01db
commit
e5e74e5500
3 changed files with 78 additions and 0 deletions
|
@ -599,6 +599,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;
|
||||
}
|
||||
|
||||
|
||||
#ifndef CONFIG_NATIVE_WINDOWS
|
||||
static void eloop_handle_alarm(int sig)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue