| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When queue more usb requests, and more devices working at the same time
256's limitation is easy to reach.
This patch remove such limitation of windows version.
dymatic allocate map fd_table.
each time increase 256 entry if request more fds.
Closes #592
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
These functions were declared as returning int, but failed to actually
return anything, and no one was using their return values anyway.
Closes #562
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fun()
{
libusb_open()
... sync transfer
libusb_close()
}
two thread call fun infininately.
to speed up crash, enable application verifier
below 20 cycle, assert(fd!=NULL) happen at check_pollfds
below 100 cycle, crash at pollable_fd->overlappend in
winusb_get_overlapped result
with this fix, success fun over 1000 cycles
in handle_events
usbi_mutex_lock()
fds = ctx->pollfds
nfds = ctx->pollfds_cnt;
usbi_mutex_unclock()
usbi_poll()
callback.
usbi poll is not in mutex. pollfds may be change by usbi_add_pollfd
and usbi_remove_pollfd.
Although usbi_add_pollfd and usbi_remove_pollfd hold mutex, but
usbi_poll and callback is not in protext of mutex.
windows use fd as index of fb_table. fb_table may changed by
usbi_remove_pollfd. the map between fd and internal file_descriptor may
be wrong.
this patch added ref count for file_descriptor, only free file_desciptor
and remove it from fb_table when ref count is 0.
ref count will be increase when fds copy with mutex lock.
so fd always index validate file_descriptor.
ref count will be descress before return from handle_events.
the file_descriptor can be free safely at this time.
Closes #521
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit unifies the two Windows backends into a single project and
enables the user to switch to the UsbDk backend, if available, using the
libusb_set_option() function. All contexts will use the WinUSB backend
by default for backwards compatibility.
With this change, the UsbDk-specific projects are no longer required.
Closes #309
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous poll() implementation worked okay but had some issues. It
was inefficient, had a large footprint, and there were simply some use
cases that didn't work (e.g. a synchronous transfer that completes when
no other event or transfer is pending would not be processed until the
next poll() timeout).
This commit introduces a new, simpler design that simply associates an
OVERLAPPED structure to an integer that acts as a file descriptor. The
poll() emulation now solely cares about the OVERLAPPED structure, not
transfers or HANDLEs or cancelation functions. These details have been
moved up into the higher OS-specific layers.
For Windows NT environments, several deficiencies have been addressed:
1) It was previously possible to successfully submit a transfer but fail
to add the "file descriptor" to the pollfd set. This was silently
ignored and would result in the user never seeing the transfer being
completed.
2) Synchronously completed transfers would previously not be processed
unless another event (such as a timeout or other transfer completion)
was processed.
3) Canceling any one transfer on an endpoint would previously result in
*all* transfers on that endpoint being canceled, due to the use of
the AbortPipe() function.
This commit addresses all of these issues. In particular, run-time
detection of the CancelIoEx() function will allow the user to cancel a
single outstanding transfer without affecting any others still in
process.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
* ...since Microsoft broke IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX between Windows 7 and Windows 8
* Also improve Windows version detection and reporting
* Closes #10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Without this fix if a transfer is reused then there is a period of
time between it being adding to the flying transfer list and
submitted where the fd value will be the old fd value.
* If this occurs at the same time as all of the following conditions
then the incorrect transfer will be handled as having completed:
* The old fd value in the reused transfer has been recycled for a
currently pending transfer.
* This other pending transfer has a later timeout than the reused
transfer (so therefore comes later in the flying transfer list).
* The other pending transfer completes, therefore signalling the fd.
As the flying transfer list is examined in order when handling events,
the resubmitted transfer with the old fd value will be considered as
completed. This will generally cause a NULL pointer dereference as the
OVERLAPPED structure was already freed.
Also see:
http://libusbx.1081486.n5.nabble.com/Libusbx-devel-PATCH-Fix-NULL-pointer-dereference-in-Windows-and-WinCE-backends-when-reusing-transfers-tt1041.html
|
|
|
|
|
|
| |
* Update copyrights and switch to UTF-8 everywhere
* Add SleepEx() to missing.h, and move include to libusbi.h
* Remove ifdef for GetSystemTimeAsFileTime()
|
|
|
|
|
| |
* Because poll_windows now requires struct usbi_transfer to be
defined, it's inclusion in libusbi.h had to be moved down.
|
|
|
|
| |
* Also remove extra lines at the end of samples
|
|
|
|
|
|
| |
* The DYNAMIC_FDS, AUTO_CLAIM and FORCE_INSTANT_TIMEOUTS options
were introduced for development/testing and don't appear to be
used by the Windows backend users => remove them.
|
|
|
|
|
|
| |
* prefer calloc over malloc
* silence VS2010 intellisense warnings on mem allocation
* other minor fixes and formatting improvements to align with -pbatard
|
|
|
|
|
| |
* Mentions of 'libusb' in doxygen are changed to 'libusbx'
* Also update copyright notices and remove unneeded EOF LFs
|
|
|
|
|
|
| |
* issue reported by Elmi
Signed-off-by: Michael Plante <michael.plante@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
use _open() and _close() rather than _open_osfhandle() and CloseHandle()
* use of CloseHandle() prevented the pipe fds from being
relinquished on libusb_exit()
* leaked fds could lead to the OS running out of new fds
and LIBUSB_ERROR_NO_MEM being returned as a result
* using _open() avoids _open_osfhandle() redef for cygwin
* issue reported by Stephano Antonelli
|
|
|
|
|
|
|
|
|
|
|
| |
On Linux, assume nfds_t is always available.
On Darwin, fall back to unsigned int when poll() exists but there
is no nfds_t, such as on Mac OS X before 10.4.
On Windows (both MinGW and Cygwin), always use unsigned int instead
of nfds_t, and don't check for poll.h because we use our own poll()
implementation.
|
|
Via Cygwin/MinGW, libusb now has windows support.
Thanks to contributors: Michael Plante, Orin Eman, Peter Stuge,
Stephan Meyer, Xiaofan Chen.
|