Some sources may not be necessarily associated with a device. The best example
is the anykey pollfd from sigrok-cli. sr_session_stop only removes sources
associated with hardware devices via dev_acquisition_stop. Sources such as
anykey are not removed, and thus session->num_sources will not get to 0. As a
result, we may get into situations where the event loop enters an infinite
state.
To prevent this, all we have to do is remove any active sources that are still
present after dev_acquisition_stop has been called for all devices.
This fixes bug 14.
}
}
+ /*
+ * Some sources may not be necessarily associated with a device.
+ * Those sources may still be present even after stopping all devices.
+ * We need to make sure all sources are removed, or we risk running the
+ * session in an infinite loop.
+ */
+ while (session->num_sources)
+ sr_session_source_remove(session->sources[0].poll_object);
+
return SR_OK;
}