libnetwork: handle EINTR on select() and poll()
Change-Id: I4e3562bd2564dd0c61142d0b467c81abd393373a Reviewed-on: https://review.haiku-os.org/c/haiku/+/3726 Reviewed-by: waddlesplash <waddlesplash@gmail.com> Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
This commit is contained in:
parent
f8157a3971
commit
0ce3a760d3
@ -309,7 +309,10 @@ BAbstractSocket::_WaitFor(int flags, bigtime_t timeout) const
|
||||
entry.fd = Socket();
|
||||
entry.events = flags;
|
||||
|
||||
int result = poll(&entry, 1, millis);
|
||||
int result;
|
||||
do {
|
||||
result = poll(&entry, 1, millis);
|
||||
} while (result == -1 && errno == EINTR);
|
||||
if (result < 0)
|
||||
return errno;
|
||||
if (result == 0)
|
||||
|
@ -490,7 +490,13 @@ BNetEndpoint::IsDataPending(bigtime_t timeout)
|
||||
tv.tv_usec = (timeout % 1000000);
|
||||
}
|
||||
|
||||
if (select(fSocket + 1, &fds, NULL, NULL, timeout >= 0 ? &tv : NULL) < 0) {
|
||||
int status;
|
||||
do {
|
||||
status = select(fSocket + 1, &fds, NULL, NULL,
|
||||
timeout >= 0 ? &tv : NULL);
|
||||
} while (status == -1 && errno == EINTR);
|
||||
|
||||
if (status < 0) {
|
||||
fStatus = errno;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user