aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-01-05 07:59:38 (GMT)
committerJouni Malinen <j@w1.fi>2014-01-07 08:45:10 (GMT)
commita09ffd5f2f9ad8ef396be52246aab9b9ab507ad6 (patch)
tree8d6899ede75878049e765c8902239cc8379bef16
parentbce774ad6358a04341e9e6d45ff3060ff955c87a (diff)
downloadhostap-a09ffd5f2f9ad8ef396be52246aab9b9ab507ad6.zip
hostap-a09ffd5f2f9ad8ef396be52246aab9b9ab507ad6.tar.gz
hostap-a09ffd5f2f9ad8ef396be52246aab9b9ab507ad6.tar.bz2
Fix req_scan-deplete-timeout and update eloop API for this
Commit e2f5a9889a3a2bb8f1eed0cf274c7fbbabe3e9de was supposed to prevent new scan request from pushing out the old one. However, it did not really do that since eloop_deplete_timeout() returned 0 both for the case where the old timeout existed (and was sooner) and if the old timeout did not exist. It returned 1 only for the case where an old timeout did exist and was larger than the new requested value. That case used to result in wpa_supplicant_req_scan() rescheduling the timeout, but hew code in eloop_deplete_timeout() did the exact same thing and as such, did not really change anything apart from the debug log message. Extend the eloop_deplete_timeout() (and eloop_replenish_timeout() for that matter since it is very similar) to return three different values based on whether the timeout existed or not and if yes, whether it was modified. This allows wpa_supplicant_req_scan() to schedule a new timeout only in the case there was no old timeout. Signed-hostap: Jouni Malinen <j@w1.fi>
-rw-r--r--src/ap/sta_info.c2
-rw-r--r--src/ap/wps_hostapd.c3
-rw-r--r--src/utils/eloop.c6
-rw-r--r--src/utils/eloop.h6
-rw-r--r--src/utils/eloop_win.c6
-rw-r--r--wpa_supplicant/scan.c20
6 files changed, 26 insertions, 17 deletions
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 4592cc8..670b834 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -494,7 +494,7 @@ void ap_sta_replenish_timeout(struct hostapd_data *hapd, struct sta_info *sta,
u32 session_timeout)
{
if (eloop_replenish_timeout(session_timeout, 0,
- ap_handle_session_timer, hapd, sta)) {
+ ap_handle_session_timer, hapd, sta) == 1) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "setting session timeout "
"to %d seconds", session_timeout);
diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c
index 9edf0f5..4c94210 100644
--- a/src/ap/wps_hostapd.c
+++ b/src/ap/wps_hostapd.c
@@ -295,7 +295,8 @@ void hostapd_wps_eap_completed(struct hostapd_data *hapd)
* timeout to happen after EAP completion rather than the originally
* scheduled 100 ms after new configuration became known.
*/
- if (eloop_deplete_timeout(0, 0, wps_reload_config, hapd->iface, NULL))
+ if (eloop_deplete_timeout(0, 0, wps_reload_config, hapd->iface, NULL) ==
+ 1)
wpa_printf(MSG_DEBUG, "WPS: Reschedule immediate configuration reload");
}
diff --git a/src/utils/eloop.c b/src/utils/eloop.c
index e983edc..f83a232 100644
--- a/src/utils/eloop.c
+++ b/src/utils/eloop.c
@@ -623,10 +623,11 @@ int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs,
user_data);
return 1;
}
+ return 0;
}
}
- return 0;
+ return -1;
}
@@ -654,10 +655,11 @@ int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs,
user_data);
return 1;
}
+ return 0;
}
}
- return 0;
+ return -1;
}
diff --git a/src/utils/eloop.h b/src/utils/eloop.h
index d3980fa..07b8c0d 100644
--- a/src/utils/eloop.h
+++ b/src/utils/eloop.h
@@ -229,7 +229,8 @@ int eloop_is_timeout_registered(eloop_timeout_handler handler,
* @handler: Matching callback function
* @eloop_data: Matching eloop_data
* @user_data: Matching user_data
- * Returns: 1 if the timeout is depleted, 0 if no change is made
+ * Returns: 1 if the timeout is depleted, 0 if no change is made, -1 if no
+ * timeout matched
*
* Find a registered matching <handler,eloop_data,user_data> timeout. If found,
* deplete the timeout if remaining time is more than the requested time.
@@ -245,7 +246,8 @@ int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs,
* @handler: Matching callback function
* @eloop_data: Matching eloop_data
* @user_data: Matching user_data
- * Returns: 1 if the timeout is replenished, 0 if no change is made
+ * Returns: 1 if the timeout is replenished, 0 if no change is made, -1 if no
+ * timeout matched
*
* Find a registered matching <handler,eloop_data,user_data> timeout. If found,
* replenish the timeout if remaining time is less than the requested time.
diff --git a/src/utils/eloop_win.c b/src/utils/eloop_win.c
index a1f9996..de47fb2 100644
--- a/src/utils/eloop_win.c
+++ b/src/utils/eloop_win.c
@@ -378,10 +378,11 @@ int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs,
user_data);
return 1;
}
+ return 0;
}
}
- return 0;
+ return -1;
}
@@ -409,10 +410,11 @@ int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs,
user_data);
return 1;
}
+ return 0;
}
}
- return 0;
+ return -1;
}
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index c45130f..da827bd 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -888,17 +888,19 @@ void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec)
*/
void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec)
{
- if (eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL))
- {
- wpa_dbg(wpa_s, MSG_DEBUG, "Rescheduling scan request: %d sec %d usec",
+ int res = eloop_deplete_timeout(sec, usec, wpa_supplicant_scan, wpa_s,
+ NULL);
+ if (res == 1) {
+ wpa_dbg(wpa_s, MSG_DEBUG, "Rescheduling scan request: %d.%06d sec",
sec, usec);
- return;
+ } else if (res == 0) {
+ wpa_dbg(wpa_s, MSG_DEBUG, "Ignore new scan request for %d.%06d sec since an earlier request is scheduled to trigger sooner",
+ sec, usec);
+ } else {
+ wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d.%06d sec",
+ sec, usec);
+ eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL);
}
-
- wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec",
- sec, usec);
- eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL);
- eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL);
}