return 0;
}
-/*
- * Interrupt the iteration of the event handling thread, so that it picks
- * up the fd change.
- */
-void usbi_fd_notification(struct libusb_context *ctx)
-{
- int pending_events;
-
- /* Record that there is a new poll fd.
- * Only signal an event if there are no prior pending events. */
- usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
- ctx->pollfds_modified = 1;
- if (!pending_events)
- usbi_signal_event(ctx);
- usbi_mutex_unlock(&ctx->event_data_lock);
-}
-
/** \ingroup dev
* Open a device and obtain a device handle. A handle allows you to perform
* I/O on the device in question.
usbi_mutex_init_recursive(&ctx->events_lock, NULL);
usbi_mutex_init(&ctx->event_waiters_lock, NULL);
usbi_cond_init(&ctx->event_waiters_cond, NULL);
- usbi_mutex_init_recursive(&ctx->event_data_lock, NULL);
+ usbi_mutex_init(&ctx->event_data_lock, NULL);
list_init(&ctx->flying_transfers);
list_init(&ctx->ipollfds);
list_init(&ctx->hotplug_msgs);
ctx->fd_cb_user_data = user_data;
}
+/*
+ * Interrupt the iteration of the event handling thread, so that it picks
+ * up the fd change. Callers of this function must hold the event_data_lock.
+ */
+static void usbi_fd_notification(struct libusb_context *ctx)
+{
+ int pending_events;
+
+ /* Record that there is a new poll fd.
+ * Only signal an event if there are no prior pending events. */
+ pending_events = usbi_pending_events(ctx);
+ ctx->pollfds_modified = 1;
+ if (!pending_events)
+ usbi_signal_event(ctx);
+}
+
/* Add a file descriptor to the list of file descriptors to be monitored.
* events should be specified as a bitmask of events passed to poll(), e.g.
* POLLIN and/or POLLOUT. */
int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events);
void usbi_remove_pollfd(struct libusb_context *ctx, int fd);
-void usbi_fd_notification(struct libusb_context *ctx);
/* device discovery */