diff options
author | Pete Batard <pbatard@gmail.com> | 2010-03-10 20:39:07 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-03-10 20:39:07 +0000 |
commit | b35a7e03dcf9ea087b267099d8d8edd4b77ee124 (patch) | |
tree | 5c45a57d05052f78bb02daa343383f03db5b8ec4 /libusb | |
parent | f4b7fdd52794eb94bda5117d89dc07e2c5dce2ab (diff) | |
download | libusb-b35a7e03dcf9ea087b267099d8d8edd4b77ee124.tar.gz |
moved usbi_fd_notification call after usbi_add_pollfdr203
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/os/poll_windows.c | 15 | ||||
-rw-r--r-- | libusb/os/poll_windows.h | 7 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 19 | ||||
-rw-r--r-- | libusb/os/windows_usb.h | 5 |
4 files changed, 22 insertions, 24 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index b6fed7c..3bbe615 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -70,12 +70,6 @@ // Uncomment to debug the polling layer //#define DEBUG_POLL_WINDOWS - -// Uncomment to have poll return with EINTR as soon as a new transfer (fd) is added -// This should result in a LIBUSB_ERROR_INTERRUPTED being returned by libusb calls, -// which should give the app an opportunity to resubmit a new fd set. -//#define DYNAMIC_FDS - #if defined(DEBUG_POLL_WINDOWS) #define poll_dbg usbi_dbg #else @@ -122,8 +116,6 @@ static inline int _open_osfhandle(intptr_t osfhandle, int flags) #define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0) -extern void usbi_fd_notification(struct libusb_context *ctx); - // public fd data const struct winfd INVALID_WINFD = {-1, NULL, NULL, RW_NONE, FALSE}; struct winfd poll_fd[MAX_FDS]; @@ -434,7 +426,7 @@ out1: * read and one for write. Using a single R/W fd is unsupported and will * produce unexpected results */ -struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_context *ctx) +struct winfd usbi_create_fd(HANDLE handle, int access_mode) { int i, fd; struct winfd wfd = INVALID_WINFD; @@ -489,11 +481,6 @@ struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_contex usbi_mutex_unlock(&new_fd_mutex); // Notify poll that fds have been updated SetEvent(fd_update); -#else - // NOTE: For now, usbi_fd_notification is only called on fd creation, as - // fd deletion results in a CancelIo() event, which poll should detect. - // Will see if there's an actual justification to call this on delete... - usbi_fd_notification(ctx); #endif return wfd; } diff --git a/libusb/os/poll_windows.h b/libusb/os/poll_windows.h index 996ff48..0da805b 100644 --- a/libusb/os/poll_windows.h +++ b/libusb/os/poll_windows.h @@ -26,6 +26,11 @@ #pragma warning(disable:4127) // conditional expression is constant #endif +// Uncomment to have poll return with EINTR as soon as a new transfer (fd) is added +// This should result in a LIBUSB_ERROR_INTERRUPTED being returned by libusb calls, +// which should give the app an opportunity to resubmit a new fd set. +//#define DYNAMIC_FDS + #if !defined(ssize_t) #if defined (_WIN64) #define ssize_t __int64 @@ -84,7 +89,7 @@ int usbi_close(int fd); void init_polling(void); void exit_polling(void); -struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_context *ctx); +struct winfd usbi_create_fd(HANDLE handle, int access_mode); void usbi_free_fd(int fd); struct winfd fd_to_winfd(int fd); struct winfd handle_to_winfd(HANDLE handle); diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 5b0ae89..dd4dac0 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -58,6 +58,8 @@ #define LOOP_CHECK(fcall) { r=fcall; if (r != LIBUSB_SUCCESS) continue; } #define LOOP_BREAK(err) { r=err; continue; } +extern void usbi_fd_notification(struct libusb_context *ctx); + // Helper prototypes static int windows_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len, int *host_endian); static int windows_clock_gettime(int clk_id, struct timespec *tp); @@ -1737,6 +1739,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, (short)((transfer->endpoint & LIBUSB_ENDPOINT_IN)?POLLIN:POLLOUT)); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; } @@ -1756,6 +1761,9 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, (short)((transfer->endpoint & LIBUSB_ENDPOINT_IN)?POLLIN:POLLOUT)); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; } @@ -1774,6 +1782,9 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) } usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, POLLIN); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; @@ -2543,7 +2554,7 @@ static int winusb_submit_control_transfer(struct usbi_transfer *itransfer) usbi_dbg("will use interface %d", current_interface); winusb_handle = handle_priv->interface_handle[current_interface].api_handle; - wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx); + wfd = usbi_create_fd(winusb_handle, _O_RDONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -2619,7 +2630,7 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer) winusb_handle = handle_priv->interface_handle[current_interface].api_handle; direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN; - wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx); + wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -3583,7 +3594,7 @@ static int hid_submit_control_transfer(struct usbi_transfer *itransfer) usbi_dbg("will use interface %d", current_interface); hid_handle = handle_priv->interface_handle[current_interface].api_handle; - wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx); + wfd = usbi_create_fd(hid_handle, _O_RDONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -3685,7 +3696,7 @@ static int hid_submit_bulk_transfer(struct usbi_transfer *itransfer) { hid_handle = handle_priv->interface_handle[current_interface].api_handle; direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN; - wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx); + wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index dcc9df3..6a54d7e 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -345,11 +345,6 @@ typedef RETURN_TYPE CONFIGRET; #define CR_SUCCESS 0x00000000 #define CR_NO_SUCH_DEVNODE 0x0000000D -//#if defined(_CFGMGR32_) -//#define CMAPI DECLSPEC_EXPORT -//#else -//#define CMAPI DECLSPEC_IMPORT -//#endif #define USB_DEVICE_DESCRIPTOR_TYPE LIBUSB_DT_DEVICE #define USB_CONFIGURATION_DESCRIPTOR_TYPE LIBUSB_DT_CONFIG |