P2P: Use monotonic time for GO client waiting

GO activation can fail if the first client doesn't connect
within a certain time, but this should not be dependent on
wall time -- use monotonic time instead.

While at it, use os_reltime_expired().

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2013-12-16 21:08:40 +01:00 committed by Jouni Malinen
parent 3326f19355
commit 151ab808fa
2 changed files with 7 additions and 7 deletions

View file

@ -853,7 +853,7 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
network_id = ssid->id;
if (!client) {
wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 0);
os_get_time(&wpa_s->global->p2p_go_wait_client);
os_get_reltime(&wpa_s->global->p2p_go_wait_client);
}
}
@ -1030,7 +1030,7 @@ static void p2p_go_configured(void *ctx, void *data)
" [PERSISTENT]" : "");
}
os_get_time(&wpa_s->global->p2p_go_wait_client);
os_get_reltime(&wpa_s->global->p2p_go_wait_client);
if (params->persistent_group) {
network_id = wpas_p2p_store_persistent_group(
wpa_s->parent, ssid,
@ -6143,10 +6143,10 @@ int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
}
if (!ret && wpa_s->global->p2p_go_wait_client.sec) {
struct os_time now;
os_get_time(&now);
if (now.sec > wpa_s->global->p2p_go_wait_client.sec +
P2P_MAX_INITIAL_CONN_WAIT_GO) {
struct os_reltime now;
os_get_reltime(&now);
if (os_reltime_expired(&now, &wpa_s->global->p2p_go_wait_client,
P2P_MAX_INITIAL_CONN_WAIT_GO)) {
/* Wait for the first client has expired */
wpa_s->global->p2p_go_wait_client.sec = 0;
} else {

View file

@ -246,7 +246,7 @@ struct wpa_global {
struct wpa_supplicant *p2p_group_formation;
struct wpa_supplicant *p2p_invite_group;
u8 p2p_dev_addr[ETH_ALEN];
struct os_time p2p_go_wait_client;
struct os_reltime p2p_go_wait_client;
struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
int p2p_disabled;