mirror of
https://github.com/Silicondust/libhdhomerun
synced 2025-08-20 21:43:27 -07:00
ensure that errno is set correctly after hdhomerun_sock_connect
This commit is contained in:
parent
0d3b72c1cc
commit
b9d5d04fea
1 changed files with 9 additions and 3 deletions
|
@ -332,13 +332,19 @@ bool hdhomerun_sock_connect(struct hdhomerun_sock_t *sock, uint32_t remote_addr,
|
||||||
poll_event.events = POLLOUT;
|
poll_event.events = POLLOUT;
|
||||||
poll_event.revents = 0;
|
poll_event.revents = 0;
|
||||||
|
|
||||||
if (poll(&poll_event, 1, (int)timeout) <= 0) {
|
int ret = poll(&poll_event, 1, (int)timeout);
|
||||||
|
if (ret < 0) {
|
||||||
|
return false;
|
||||||
|
} else if (ret == 0) {
|
||||||
|
errno = ETIMEDOUT;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((poll_event.revents & POLLOUT) == 0) {
|
if (connect(sock->sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
|
||||||
|
if (errno != EISCONN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue