]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use monotonic time for GO client waiting
authorJohannes Berg <johannes.berg@intel.com>
Mon, 16 Dec 2013 20:08:40 +0000 (21:08 +0100)
committerJouni Malinen <j@w1.fi>
Tue, 24 Dec 2013 06:00:03 +0000 (08:00 +0200)
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>

wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 6e56f1b1669f0b5923150fc739e1d9f6a2fd99af..117e4936b0f4346d566d4f9c6772c94bbc90c649 100644 (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 {
index 769e3530216d360bfcaf7e9b7ab785032d1f20a2..648b313dacbef6f142c14c95ed0833d23bb0fa14 100644 (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;