+ if (ret > 0 && revents == 0)
+ continue; /* skip timeouts if any I/O event occurred */
+
+ due = source->due;
+#ifdef HAVE_LIBUSB_1_0
+ if (source->is_usb && usb_due < due)
+ 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(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. */
+ i = 0;