Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
This change will ensure that the event pipe is only signalled
at most one time during the course of any incoming events. New
events that occur while the event pipe is in the signalled state
will not cause the event pipe to be signalled again.
This change will provide support for the use of native events on
the Windows/WinCE backends, as these events are binary and do not
"count" the number of times they are signalled.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
To further consolidate libusb internal events, this change removes
the hotplug pipe. Hotplug messages are now kept in a list within the
context, and the event pipe is signalled when a new hotplug message
is added. When handling events, the hotplug messages will be processed
from the list instead of from a separate pipe.
This change is greatly beneficial for the Windows/WinCE backends which
do not allow pipes to be used in the WaitFor* functions.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
This flag will be useful in a subsequent commit that further
consolidates event handling.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
This change removes the device_close_lock and uses the shared event
data lock to protect the value of the device_close counter.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
This lock will be used in subsequent changes that will consolidate
all different event sources (i.e. device close, fd notification,
hotplug message) into a single event.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
This counter is now solely used for closing a device, so rename
the variable appropriately.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
It is unnecessary to take the events lock when a thread needs to
interrupt an event handler to receive a change list of poll fds.
It is sufficient to simply write to the control pipe and let the
event handler be notified of this event when it polls.
Taking the events lock inside this function leads to opportunity
for deadlock in certain situations, such as a client program
running on an OS that uses fd notification on each individual
transfer. If the client program were to protect a list of transfers
with a single lock, it could deadlock if that lock were taken in
two separate threads, one which is attempting to submit a new
transfer and one which is executing inside the transfer completion
callback.
Thanks to Dmitry Fleytman and Pavel Gurvich for reporting this.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Warning: Tag `XML_SCHEMA' at line 942 of file `doxygen.cfg' has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
Warning: Tag `XML_DTD' at line 948 of file `doxygen.cfg' has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
I upgrade the doxygen.cfg.in using: "doxygen -u doxygen.cfg.in"
The configuration file changed from Doxyfile 1.5.3 to Doxyfile 1.8.8
|
|
libusb/io.c:46: warning: multiple use of section label 'intro' while
adding section, (first occurrence: libusb/core.c, line 79)
Use label "io_intro" instead of "intro"
|
|
libusb/hotplug.c:46: warning: multiple use of section label 'intro'
while adding section, (first occurrence: libusb/core.c, line 79)
Use label "hotplug_intro" instead of "intro"
|
|
The structure libusb_hotplug_callback was declared (but not defined) and
never used in the public API.
|
|
This page lists the all the public functions, structures and enums
provided by libusb.
The HTML page is generated by Doxygen.
|
|
* Var found was not reset to false before list_for_each_entry()
* ctx->open_devs_lock was not released on error.
* Issues reported by Yongjian Xu
|
|
# Closes #41
|
|
* Also update Windows version report for Windows 10
|
|
* Issue reported by Thejus
|
|
...that was broken with dc97425bb415422423b8876af0e34111e566d56d (Haiku inclusion)
|
|
|
|
This makes error handling consistent with other areas. This is a
follow-on change to commit b72f4cf77edb1975cada8aab5ae63361c68c5992.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
* If the hotplug pipe failed to be created, the usbi_pollfd for the
control pipe was being leaked.
* If the usbi_pollfd for timerfd failed to be added, the usbi_pollfd
for the hotplug pipe was being leaked.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
* Include config.h before anything else in all files
* Remove unnecessary inclusion of libusb.h
* Use angle brackets for system headers and quotes for local headers
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
* For newer versions of MinGW, VerSetConditionMask() is only defined
if building for Windows XP (0x501) or newer.
|
|
If the default context was created but failed to fully initialize,
the reference count was not decremented appropriately.
|
|
variables
Signed-off-by: Chris Dickens <chris.dickens@hp.com>
|
|
Prior to this patch, the array of poll fds given to poll() was
allocated and freed every time handle_events() was called. This
is unnecessary if the list of poll fds has not changed since the
last call to handle_events(). With this patch, the array and count
of poll fds is stored in the context and only reallocated when the
list of poll fds changes, saving any unnecessary overhead.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
There are a number of fds that the core uses internally. Currently
any events on these fds are masked out so that the backend will
skip over them during handle_events().
This change improves upon this by simply not providing these fds
to the backend.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
The current behavior of libusb_open() unconditionally interrupts
any event handlers via usbi_fd_notification(). However, not all
backends, namely Win/WinCE, make changes to the pollfd list during
a device open.
This change adds a new CAP for backends (HAS_POLLABLE_DEVICE_FD),
and libusb_open() will only call usbi_fd_notification() if the
backend declares this capability.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
usbi_handle_transfer_completion() is only called by backends when
handling transfer completion. The backend can only make this call
whilst holding the events lock, therefore it is pointless to send
this signal. Any threads waiting to be signaled will be woken up
and will either find that an event handler is still active or will
try to obtain the events lock and be blocked.
Event waiters are automatically signaled in libusb_unlock_events(),
so when the backend is done handling events it will release the lock
and wake up any waiters. At this point the events lock wll be free,
which is the only time waking up waiters makes sense.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
If libusb_get_max_packet_size() or libusb_get_max_iso_packet_size()
fails to find the endpoint, it leaks the configuration descriptor. Fix
this.
Signed-off-by: John Sheu <sheu@google.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
It looks like *ifcp should be the same as iface,
so I just use the latter instead of the former.
Closes pull request #13
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
If submission fails libusb_ref_device will never get balanced by an unref
on completion, since there will be no completion.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Fix a possible deadlock due to a lock ordering reversal, caught by Coverity:
*** CID 62579: Thread deadlock (ORDER_REVERSAL)
/libusb/io.c: 1451 in libusb_submit_transfer()
1445 r = calculate_timeout(itransfer);
1446 if (r < 0) {
1447 r = LIBUSB_ERROR_OTHER;
1448 goto out;
1449 }
1450
>>> CID 62579: Thread deadlock (ORDER_REVERSAL)
>>> Calling "pthread_mutex_lock" acquires lock "libusb_context.flying_transfers_lock" while holding lock "usbi_transfer.lock" (count: 1 / 4).
1451 usbi_mutex_lock(&ctx->flying_transfers_lock);
1452 r = add_to_flying_list(itransfer);
1453 if (r == LIBUSB_SUCCESS) {
1454 r = usbi_backend->submit_transfer(itransfer);
1455 }
1456 if (r != LIBUSB_SUCCESS) {
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
This really is a false positive, but easy enough to silence:
*** CID 62578: Failure to restore non-local value (MISSING_RESTORE)
/libusb/os/linux_udev.c: 64 in linux_udev_start_event_monitor()
58 int r;
59
60 assert(udev_ctx == NULL);
61 udev_ctx = udev_new();
62 if (!udev_ctx) {
63 usbi_err(NULL, "could not create udev context");
>>> CID 62578: Failure to restore non-local value (MISSING_RESTORE)
>>> Value of non-local "udev_ctx" that was verified to be "NULL" is not restored as it was along other paths.
64 return LIBUSB_ERROR_OTHER;
65 }
66
67 udev_monitor = udev_monitor_new_from_netlink(udev_ctx, "udev");
68 if (!udev_monitor) {
69 usbi_err(NULL, "could not initialize udev monitor");
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
We scan the list of open devices to find the device-handle based on the fd,
add a check to ensure that we've actually found the handle before continuing.
This fixes the following Coverity warning:
*** CID 62575: Explicit null dereferenced (FORWARD_NULL)
/libusb/os/linux_usbfs.c: 2594 in op_handle_events()
2588 hpriv = _device_handle_priv(handle);
2589 if (hpriv->fd == pollfd->fd)
2590 break;
2591 }
2592
2593 if (pollfd->revents & POLLERR) {
>>> CID 62575: Explicit null dereferenced (FORWARD_NULL)
>>> Dereferencing null pointer "hpriv".
2594 usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fd);
2595 usbi_handle_disconnect(handle);
2596 /* device will still be marked as attached if hotplug
monitor thread
2597 * hasn't processed remove event yet */
2598 usbi_mutex_static_lock(&linux_hotplug_lock);
2599 if (handle->dev->attached)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
There is no reason to mark init_count as volatile, it is protected by the
linux_hotplug_startstop_lock. Removing the volatile marking fixes the
following Coverity warning:
*** CID 62574: Side effect in assertion (ASSERT_SIDE_EFFECT)
/libusb/os/linux_usbfs.c: 460 in op_exit()
454 return r;
455 }
456
457 static void op_exit(void)
458 {
459 usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
>>> CID 62574: Side effect in assertion (ASSERT_SIDE_EFFECT)
>>> Argument "init_count" of assert() has a side effect because the variable is volatile. The containing function might work differently in a non-debug build.
460 assert(init_count != 0);
461 if (!--init_count) {
462 /* tear down event handler */
463 (void)linux_stop_event_monitor();
464 }
465 usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
* On XP environments, the call to GetSystemMetrics() fails without an explicit reference to user.lib...
which end user applications would also need to do.
Considering that this call was just to differentiate Windows 2003 from 2003 R2, just remove it.
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.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
|