From 5b2f2e11852edf81be401736e5ece7c9debe047e Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Mon, 17 Nov 2014 23:53:10 -0800 Subject: core: Rename pipe used to signal internal events Signed-off-by: Chris Dickens --- libusb/core.c | 10 +++++----- libusb/io.c | 32 ++++++++++++++++---------------- libusb/libusbi.h | 5 ++--- libusb/version_nano.h | 2 +- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/libusb/core.c b/libusb/core.c index 87cb776..042f7a5 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1180,8 +1180,8 @@ void usbi_fd_notification(struct libusb_context *ctx) unsigned char dummy = 1; ssize_t r; - /* write some data on control pipe to interrupt event handlers */ - r = usbi_write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + /* write some data on event pipe to interrupt event handlers */ + r = usbi_write(ctx->event_pipe[1], &dummy, sizeof(dummy)); if (r != sizeof(dummy)) usbi_warn(ctx, "internal signalling write failed"); } @@ -1404,8 +1404,8 @@ void API_EXPORTED libusb_close(libusb_device_handle *dev_handle) ctx->device_close++; usbi_mutex_unlock(&ctx->event_data_lock); - /* write some data on control pipe to interrupt event handlers */ - r = usbi_write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + /* write some data on event pipe to interrupt event handlers */ + r = usbi_write(ctx->event_pipe[1], &dummy, sizeof(dummy)); if (r <= 0) { usbi_warn(ctx, "internal signalling write failed, closing anyway"); do_close(ctx, dev_handle); @@ -1419,7 +1419,7 @@ void API_EXPORTED libusb_close(libusb_device_handle *dev_handle) libusb_lock_events(ctx); /* read the dummy data */ - r = usbi_read(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); + r = usbi_read(ctx->event_pipe[0], &dummy, sizeof(dummy)); if (r <= 0) usbi_warn(ctx, "internal signalling read failed, closing anyway"); diff --git a/libusb/io.c b/libusb/io.c index 029ed57..97af568 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1032,7 +1032,7 @@ printf("completed!\n"); * * -# During initialization, libusb opens an internal pipe, and it adds the read * end of this pipe to the set of file descriptors to be polled. - * -# During libusb_close(), libusb writes some dummy data on this control pipe. + * -# During libusb_close(), libusb writes some dummy data on this event pipe. * This immediately interrupts the event handler. libusb also records * internally that it is trying to interrupt event handlers for this * high-priority event. @@ -1065,7 +1065,7 @@ printf("completed!\n"); * call to libusb_open(): * * -# The device is opened and a file descriptor is added to the poll set. - * -# libusb sends some dummy data on the control pipe, and records that it + * -# libusb sends some dummy data on the event pipe, and records that it * is trying to modify the poll descriptor set. * -# The event handler is interrupted, and the same behaviour change as for * libusb_close() takes effect, causing all event handling threads to become @@ -1120,13 +1120,13 @@ int usbi_io_init(struct libusb_context *ctx) list_init(&ctx->ipollfds); /* FIXME should use an eventfd on kernels that support it */ - r = usbi_pipe(ctx->ctrl_pipe); + r = usbi_pipe(ctx->event_pipe); if (r < 0) { r = LIBUSB_ERROR_OTHER; goto err; } - r = usbi_add_pollfd(ctx, ctx->ctrl_pipe[0], POLLIN); + r = usbi_add_pollfd(ctx, ctx->event_pipe[0], POLLIN); if (r < 0) goto err_close_pipe; @@ -1166,10 +1166,10 @@ err_close_hp_pipe: usbi_close(ctx->hotplug_pipe[0]); usbi_close(ctx->hotplug_pipe[1]); err_remove_pipe: - usbi_remove_pollfd(ctx, ctx->ctrl_pipe[0]); + usbi_remove_pollfd(ctx, ctx->event_pipe[0]); err_close_pipe: - usbi_close(ctx->ctrl_pipe[0]); - usbi_close(ctx->ctrl_pipe[1]); + usbi_close(ctx->event_pipe[0]); + usbi_close(ctx->event_pipe[1]); err: usbi_mutex_destroy(&ctx->flying_transfers_lock); usbi_mutex_destroy(&ctx->pollfds_lock); @@ -1182,9 +1182,9 @@ err: void usbi_io_exit(struct libusb_context *ctx) { - usbi_remove_pollfd(ctx, ctx->ctrl_pipe[0]); - usbi_close(ctx->ctrl_pipe[0]); - usbi_close(ctx->ctrl_pipe[1]); + usbi_remove_pollfd(ctx, ctx->event_pipe[0]); + usbi_close(ctx->event_pipe[0]); + usbi_close(ctx->event_pipe[1]); usbi_remove_pollfd(ctx, ctx->hotplug_pipe[0]); usbi_close(ctx->hotplug_pipe[0]); usbi_close(ctx->hotplug_pipe[1]); @@ -1977,7 +1977,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv) /* there are certain fds that libusb uses internally, currently: * - * 1) control pipe + * 1) event pipe * 2) hotplug pipe * 3) timerfd * @@ -2046,7 +2046,7 @@ redo_poll: special_event = 0; - /* fd[0] is always the ctrl pipe */ + /* fds[0] is always the event pipe */ if (fds[0].revents) { /* another thread wanted to interrupt event handling, and it succeeded! * handle any other events that cropped up at the same time, and @@ -2055,17 +2055,17 @@ redo_poll: unsigned char dummy; unsigned int ru; - usbi_dbg("caught a fish on the control pipe"); + usbi_dbg("caught a fish on the event pipe"); - /* read the dummy data from the control pipe unless someone is closing + /* read the dummy data from the event pipe unless someone is closing * a device */ usbi_mutex_lock(&ctx->event_data_lock); ru = ctx->device_close; usbi_mutex_unlock(&ctx->event_data_lock); if (!ru) { - ret = usbi_read(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); + ret = usbi_read(ctx->event_pipe[0], &dummy, sizeof(dummy)); if (ret != sizeof(dummy)) { - usbi_err(ctx, "control pipe read error %d err=%d", + usbi_err(ctx, "event pipe read error %d err=%d", ret, errno); r = LIBUSB_ERROR_OTHER; goto handled; diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 5548b80..cdcc61a 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -244,9 +244,8 @@ struct libusb_context { int debug; int debug_fixed; - /* internal control pipe, used for interrupting event handling when - * an internal event occurs. */ - int ctrl_pipe[2]; + /* internal event pipe, used for signalling occurrence of an internal event. */ + int event_pipe[2]; struct list_head usb_devs; usbi_mutex_t usb_devs_lock; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 3ac4f9e..b41fc42 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10934 +#define LIBUSB_NANO 10935 -- cgit v1.2.3