session: Fix USB timeout handling

In sr_session_iteration(), remove the inverted evaluation of the
block parameter if a USB source is present. This stops the deluge
of USB event callbacks due to the timeout always being zero.

Also, just for cleanliness, initialize the revents member of each
GPollFD instance to zero.
This commit is contained in:
Daniel Elstner 2015-08-30 12:20:03 +02:00
parent 452986bec4
commit 89efe06460
3 changed files with 4 additions and 1 deletions

View File

@ -165,6 +165,7 @@ static int dev_open(struct sr_dev_inst *sdi)
/* Set fd and local attributes */
devc->pollfd.fd = devc->fd;
devc->pollfd.events = G_IO_IN;
devc->pollfd.revents = 0;
/* Get the default attributes */
beaglelogic_get_samplerate(devc);

View File

@ -389,7 +389,6 @@ static int sr_session_iteration(struct sr_session *session, gboolean block)
#ifdef HAVE_LIBUSB_1_0
if (session->ctx->usb_source_present) {
timeout = block ? 0 : session->source_timeout;
ret = libusb_get_next_timeout(session->ctx->libusb_ctx, &tv);
if (ret < 0) {
sr_err("Error getting libusb timeout: %s",
@ -856,6 +855,7 @@ SR_API int sr_session_source_add(struct sr_session *session, int fd,
p.fd = fd;
p.events = events;
p.revents = 0;
return _sr_session_source_add(session, &p, timeout, cb, cb_data, (gintptr)fd);
}
@ -908,6 +908,7 @@ SR_API int sr_session_source_add_channel(struct sr_session *session,
#else
p.fd = g_io_channel_unix_get_fd(channel);
p.events = events;
p.revents = 0;
#endif
return _sr_session_source_add(session, &p, timeout, cb, cb_data, (gintptr)channel);

View File

@ -251,6 +251,7 @@ SR_PRIV int usb_source_add(struct sr_session *session, struct sr_context *ctx,
/* Add event, set by USB wait thread, to session poll set. */
ctx->usb_pollfd.fd = ctx->usb_wait_complete_event;
ctx->usb_pollfd.events = G_IO_IN;
ctx->usb_pollfd.revents = 0;
ctx->usb_cb = cb;
ctx->usb_cb_data = cb_data;
sr_session_source_add_pollfd(session, &ctx->usb_pollfd, timeout,