pulse: avoid blocking in epoll

When the custom poll function told us there is activity on the
epoll fd, don't do a blocking wait on the epoll fd. It might be
possible that the active fd is removed and then we would block
forever.

Fixes #349
This commit is contained in:
Wim Taymans 2020-10-29 15:56:22 +01:00
parent b50929d200
commit 0265514023

View file

@ -327,7 +327,7 @@ static int usec_to_timeout(pa_usec_t u)
SPA_EXPORT SPA_EXPORT
int pa_mainloop_poll(pa_mainloop *m) int pa_mainloop_poll(pa_mainloop *m)
{ {
int res; int res, timeout;
bool do_iterate; bool do_iterate;
if (m->quit) if (m->quit)
@ -344,13 +344,15 @@ int pa_mainloop_poll(pa_mainloop *m)
usec_to_timeout(m->timeout), usec_to_timeout(m->timeout),
m->poll_func_userdata); m->poll_func_userdata);
do_iterate = res == 1 && SPA_FLAG_IS_SET(fds[0].revents, POLLIN); do_iterate = res == 1 && SPA_FLAG_IS_SET(fds[0].revents, POLLIN);
timeout = 0;
} else { } else {
do_iterate = true; do_iterate = true;
timeout = m->timeout;
} }
if (do_iterate) { if (do_iterate) {
pw_loop_enter(m->loop); pw_loop_enter(m->loop);
res = pw_loop_iterate(m->loop, m->timeout); res = pw_loop_iterate(m->loop, timeout);
pw_loop_leave(m->loop); pw_loop_leave(m->loop);
} }