diff options
author | Pete Batard <pbatard@gmail.com> | 2010-03-10 20:39:07 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-03-10 23:38:32 +0000 |
commit | 409d6d2c588b71bdd5a1bb1c8fe9b5d3f796c54e (patch) | |
tree | 0533e795f052e86d2b5d7a154d7f606f85175137 /libusb/os | |
parent | ff45b74423802946aff421c77a965407bbd30c83 (diff) | |
download | libusb-409d6d2c588b71bdd5a1bb1c8fe9b5d3f796c54e.tar.gz |
moved usbi_fd_notification call after usbi_add_pollfd
Diffstat (limited to 'libusb/os')
-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 | 16 | ||||
-rw-r--r-- | libusb/os/windows_usb.h | 5 |
4 files changed, 19 insertions, 24 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index a099ff7..aa7082d 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 c31cf1e..c3fa9c3 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 @@ -85,7 +90,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 42ab75b..eb7c5f9 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); @@ -1878,7 +1880,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; } @@ -1898,7 +1902,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; } @@ -1917,7 +1923,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; @@ -2713,7 +2721,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; } @@ -2789,7 +2797,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; } @@ -4491,7 +4499,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; } @@ -4593,7 +4601,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 921b1c0..2ccb7a8 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -351,11 +351,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 |