- int ret, i;
-
- while (session->running) {
- ret = g_poll(pollfds, num_sources, source_timeout);
-
- for (i = 0; i < num_sources; i++) {
- if (pollfds[i].revents > 0 || (ret == 0
- && source_timeout == sources[i].timeout)) {
- /*
- * Invoke the source's callback on an event,
- * or if the poll timeout out and this source
- * asked for that timeout.
- */
- if (!sources[i].cb(pollfds[i].fd, pollfds[i].revents,
- sources[i].cb_data))
- sr_session_source_remove(pollfds[i].fd);
- }
+ struct sr_session *session = sr_current_session;
+ unsigned int i;
+ int ret;
+
+ ret = g_poll(session->pollfds, session->num_sources,
+ block ? session->source_timeout : 0);
+ for (i = 0; i < session->num_sources; i++) {
+ if (session->pollfds[i].revents > 0 || (ret == 0
+ && session->source_timeout == session->sources[i].timeout)) {
+ /*
+ * Invoke the source's callback on an event,
+ * or if the poll timed out and this source
+ * asked for that timeout.
+ */
+ if (!session->sources[i].cb(session->pollfds[i].fd,
+ session->pollfds[i].revents,
+ session->sources[i].cb_data))
+ sr_session_source_remove(session,
+ session->sources[i].poll_object);