Handle errno better when polling for events
This commit is contained in:
parent
037bfeff82
commit
31853ee20c
8
glfw/backend_utils.c
vendored
8
glfw/backend_utils.c
vendored
@ -222,7 +222,9 @@ pollForEvents(EventLoopData *eld, double timeout) {
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if (timeout >= 0) {
|
if (timeout >= 0) {
|
||||||
|
errno = 0;
|
||||||
result = pollWithTimeout(eld->fds, eld->watches_count, timeout);
|
result = pollWithTimeout(eld->fds, eld->watches_count, timeout);
|
||||||
|
int saved_errno = errno;
|
||||||
dispatchTimers(eld);
|
dispatchTimers(eld);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
dispatchEvents(eld);
|
dispatchEvents(eld);
|
||||||
@ -231,16 +233,18 @@ pollForEvents(EventLoopData *eld, double timeout) {
|
|||||||
}
|
}
|
||||||
timeout = end_time - monotonic();
|
timeout = end_time - monotonic();
|
||||||
if (timeout <= 0) break;
|
if (timeout <= 0) break;
|
||||||
if (result < 0 && (errno == EINTR || errno == EAGAIN)) continue;
|
if (result < 0 && (saved_errno == EINTR || saved_errno == EAGAIN)) continue;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
errno = 0;
|
||||||
result = poll(eld->fds, eld->watches_count, -1);
|
result = poll(eld->fds, eld->watches_count, -1);
|
||||||
|
int saved_errno = errno;
|
||||||
dispatchTimers(eld);
|
dispatchTimers(eld);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
dispatchEvents(eld);
|
dispatchEvents(eld);
|
||||||
read_ok = eld->watches[0].ready;
|
read_ok = eld->watches[0].ready;
|
||||||
}
|
}
|
||||||
if (result < 0 && (errno == EINTR || errno == EAGAIN)) continue;
|
if (result < 0 && (saved_errno == EINTR || saved_errno == EAGAIN)) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user