wpa_ctrl: Wait for a total of 10 seconds, not 10 seconds per iteration
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>
This commit is contained in:
parent
0d9be88551
commit
f942149684
1 changed files with 13 additions and 3 deletions
|
@ -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))
|
void (*msg_cb)(char *msg, size_t len))
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct os_reltime started_at;
|
struct os_reltime started_at, ending_at;
|
||||||
int res;
|
int res;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
const char *_cmd;
|
const char *_cmd;
|
||||||
|
@ -539,9 +539,19 @@ retry_send:
|
||||||
}
|
}
|
||||||
os_free(cmd_buf);
|
os_free(cmd_buf);
|
||||||
|
|
||||||
|
os_get_reltime(&ending_at);
|
||||||
|
ending_at.sec += 10;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
tv.tv_sec = 10;
|
struct os_reltime diff;
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
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_ZERO(&rfds);
|
||||||
FD_SET(ctrl->s, &rfds);
|
FD_SET(ctrl->s, &rfds);
|
||||||
res = select(ctrl->s + 1, &rfds, NULL, NULL, &tv);
|
res = select(ctrl->s + 1, &rfds, NULL, NULL, &tv);
|
||||||
|
|
Loading…
Reference in a new issue