summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2014-12-29Added Solaris backend stubsHEADmasterIgor Pashev6-10/+503
2014-12-19core: Signal the event pipe at most one timeChris Dickens5-25/+41
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>
2014-12-19core: Eliminate hotplug pipe, using list and event pipe insteadChris Dickens6-94/+81
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>
2014-12-19core: Add new flag to record when a new poll fd is addedChris Dickens3-1/+11
This flag will be useful in a subsequent commit that further consolidates event handling. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2014-12-19core: Add helper functions to signal and clear the event pipeChris Dickens4-29/+46
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2014-12-19core: Rename pipe used to signal internal eventsChris Dickens4-25/+24
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2014-12-19core: Transition device close event to use event_data_lockChris Dickens4-24/+20
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>
2014-12-19core: Add new lock to protect internal context event dataChris Dickens3-1/+7
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>
2014-12-19core: Rename pollfd_modify counter and its lock to device_closeChris Dickens4-37/+37
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>
2014-12-19core: Remove taking of events lock inside usbi_fd_notification()Chris Dickens3-31/+21
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>
2014-12-16Doxygen: upgrade doxygen.cfg.in fileLudovic Rousseau2-740/+1786
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
2014-12-16Doxygen: fix a duplicate labelLudovic Rousseau2-2/+2
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"
2014-12-16Doxygen: fix a duplicate labelLudovic Rousseau2-2/+2
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"
2014-12-16API: remove unused libusb_hotplug_callback structLudovic Rousseau2-2/+1
The structure libusb_hotplug_callback was declared (but not defined) and never used in the public API.
2014-12-16API: Add an Application Programming Interface pageLudovic Rousseau2-1/+150
This page lists the all the public functions, structures and enums provided by libusb. The HTML page is generated by Doxygen.
2014-12-16Windows: fix 2 bugs in windows_handle_events()Pete Batard2-2/+4
* 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
2014-12-01misc: Fix grammar in a commentSimon Newton2-2/+3
# Closes #41
2014-11-13Windows: Silence VS2013 code analysis warningsPete Batard5-9/+13
* Also update Windows version report for Windows 10
2014-11-06Windows: Fix cygwin64 buildPete Batard2-4/+3
* Issue reported by Thejus
2014-09-27Fix broken 'make install'Akshay Jaggi4-5/+7
...that was broken with dc97425bb415422423b8876af0e34111e566d56d (Haiku inclusion)
2014-09-25haiku: Add Haiku supportAkshay Jaggi15-4/+1582
2014-09-06io: Move timerfd close into error handling pathChris Dickens2-6/+5
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>
2014-09-06io: Fix memory leaks in usbi_io_init()Chris Dickens2-4/+9
* 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>
2014-09-06threads_posix: Fix compiler warning due to redefinition of _GNU_SOURCEChris Dickens1-3/+1
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2014-09-06core: Make use of headers consistent across all filesChris Dickens17-18/+31
* 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>
2014-09-03core: Fix compiler warnings on MinGW and Visual StudioChris Dickens2-9/+12
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2014-09-03Windows: Define WINVER to fix building on MinGWTormod Volden2-1/+2
* For newer versions of MinGW, VerSetConditionMask() is only defined if building for Windows XP (0x501) or newer.
2014-08-29core: Fix reference count leak for default contextChris Dickens1-1/+3
If the default context was created but failed to fully initialize, the reference count was not decremented appropriately.
2014-08-29core: Rename count variable for pollfds for consistency with other count ↵Chris Dickens2-8/+8
variables Signed-off-by: Chris Dickens <chris.dickens@hp.com>
2014-08-27core: Reuse poll fds across calls to handle_events()Chris Dickens3-43/+61
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>
2014-08-27Misc: Add myself to the README as a maintainerChris Dickens1-0/+1
2014-08-27core: Be more efficient by not passing internal fds to backendChris Dickens1-23/+26
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>
2014-08-27core: Only interrupt event handlers as necessary during libusb_open()Chris Dickens6-11/+14
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>
2014-08-27usbi_handle_transfer_completion: Remove signal to event waitersChris Dickens1-3/+0
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>
2014-06-13libusb 1.0.19Hans de Goede3-2/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-06-13Fix leak in failure path of libusb_get_max_packet_size()John Sheu1-5/+13
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>
2014-06-10Fixed clang static analyzer warning about dereferencing nullSean McBride2-2/+2
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>
2014-06-10Made darwin_hotplug_poll static to fix Xcode warningSean McBride2-2/+2
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
2014-05-30libusb 1.0.19-rc2Hans de Goede4-3/+4
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-05-30libusb_submit_transfer: Don't reference the device on submission failureHans de Goede2-4/+4
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>
2014-05-30libusb_submit_transfer: Fix possible deadlockHans de Goede2-3/+3
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>
2014-05-30linux_udev: Fix a Coverity warningHans de Goede2-2/+3
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>
2014-05-30linux_usbfs: op_handle_events: Protect against not finding the device-handleHans de Goede2-1/+7
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>
2014-05-30linux_usbfs: Don't mark init_count as volatileHans de Goede2-2/+2
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>
2014-05-30Fix a small typo in comment to free_streams()Lars Kanis1-1/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-05-20Windows: fix broken WDK compilation for XP targetsPete Batard2-2/+2
* 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.
2014-05-19ChangeLog: Add an entry about the Russian strerror translationHans de Goede2-1/+2
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-05-19libusb 1.0.19-rc1Hans de Goede5-5/+23
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-05-19strerrror.c: Add Russian translationЛарионов Даниил2-3/+18
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-05-18windows: fix USB 3.0 speed detection on Windows 8 or laterPete Batard5-23/+183
* ...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