]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_ctrl: Wait for a total of 10 seconds, not 10 seconds per iteration
authorAlan T. DeKok <aland@freeradius.org>
Fri, 23 Jul 2021 09:57:43 +0000 (05:57 -0400)
committerJouni Malinen <j@w1.fi>
Mon, 18 Apr 2022 14:18:40 +0000 (17:18 +0300)
EINTR will cause the loop to restart, which means that the total
time could be significantly longer than 10 seconds.

Signed-off-by: Alan DeKok <aland@deployingradius.com>
src/common/wpa_ctrl.c

index 40a979531b53673b4f7dafbc8d55919c8c493a7f..7e197f094fd1ec91096d4d22c4a821e0e8f64b38 100644 (file)
@@ -483,7 +483,7 @@ int wpa_ctrl_request(struct wpa_ctrl *ctrl, const char *cmd, size_t cmd_len,
                     void (*msg_cb)(char *msg, size_t len))
 {
        struct timeval tv;
-       struct os_reltime started_at;
+       struct os_reltime started_at, ending_at;
        int res;
        fd_set rfds;
        const char *_cmd;
@@ -539,9 +539,19 @@ retry_send:
        }
        os_free(cmd_buf);
 
+       os_get_reltime(&ending_at);
+       ending_at.sec += 10;
+
        for (;;) {
-               tv.tv_sec = 10;
-               tv.tv_usec = 0;
+               struct os_reltime diff;
+
+               os_get_reltime(&started_at);
+               if (os_reltime_before(&ending_at, &started_at))
+                       return -2;
+               os_reltime_sub(&ending_at, &started_at, &diff);
+               tv.tv_sec = diff.sec;
+               tv.tv_usec = diff.usec;
+
                FD_ZERO(&rfds);
                FD_SET(ctrl->s, &rfds);
                res = select(ctrl->s + 1, &rfds, NULL, NULL, &tv);