+ fd_index += source->num_fds;
+
+ if (source->triggered)
+ continue; /* already handled */
+ if (ret > 0 && revents == 0)
+ continue; /* skip timeouts if any I/O event occurred */
+
+ /* Make invalid to avoid confusion in case of multiple FDs. */
+ if (source->num_fds > 1)
+ fd = -1;
+ if (ret <= 0)
+ revents = 0;
+
+ due = source->due;
+#if HAVE_LIBUSB_1_0 && !defined(G_OS_WIN32)
+ if (usb_due < due && source->poll_object
+ == (gintptr)session->ctx->libusb_ctx)
+ due = usb_due;
+#endif
+ if (revents == 0 && stop_time < due)
+ continue;
+ /*
+ * The source may be gone after the callback returns,
+ * so access any data now that needs accessing.
+ */
+ if (source->timeout >= 0)
+ source->due = stop_time + source->timeout;
+ source->triggered = TRUE;
+ triggered = TRUE;
+ /*
+ * Invoke the source's callback on an event or timeout.
+ */
+ if (!source->cb(fd, revents, source->cb_data))
+ sr_session_source_remove_internal(session, poll_object);
+ /*
+ * We want to take as little time as possible to stop
+ * the session if we have been told to do so. Therefore,
+ * we check the flag after processing every source, not
+ * just once per main event loop.
+ */
+ if (!stopped)
+ stopped = sr_session_check_aborted(session);
+
+ /* Restart loop as the sources list may have changed. */
+ fd_index = 0;
+ i = 0;