From 151ab808fa64c7b3d302ec476c5797d89a42ac54 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 16 Dec 2013 21:08:40 +0100 Subject: [PATCH] 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 --- wpa_supplicant/p2p_supplicant.c | 12 ++++++------ wpa_supplicant/wpa_supplicant_i.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 6e56f1b16..117e4936b 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -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 { diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 769e35302..648b313da 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -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;