summaryrefslogtreecommitdiff
path: root/libusb/io.c
Commit message (Collapse)AuthorAgeFilesLines
* removed trailing whitespaces (core)Peter Stuge2010-03-181-12/+12
|
* renamed unistd_posix.h to poll_posix.hPete Batard2010-03-021-1/+1
|
* reverts some of the changes from dbd439/6c7a1e (r173)r175Pete Batard2010-02-241-1/+1
|
* includes simplification and cleanup (core)Pete Batard2010-02-241-6/+2
|
* renamed _libusb_ unistd calls to usbi_r172Pete Batard2010-02-241-8/+8
|
* moved standard calls redefinitions into a separate .hPete Batard2010-02-241-7/+1
| | | | This applies to read/write/close/poll/pipe -> unistd_posix.h
* merge abstraction for POSIX Threads and integration changes (Michael Plante, ↵r169Pete Batard2010-02-241-85/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Peter Stuge) v1.0.6 release Darwin: support multiple calls to libusb_init Credit to Orin Eman for finding this bug. Darwin: use logging functions Use usbi_warn, usbi_err, and usbi_info instead of _usbi_log. Darwin: fix memory leak in process_device Credit to Mike Colagrosso for finding this bug. Add internal abstraction for POSIX Threads This prepares for a Windows backend without dependency on pthreads-w32. pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*. A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are introduced for statically initialized mutexes, since they may be implemented using other types when pthreads mutexes aren't used. Move -pthread from libusb/Makefile.am to host-specific AM_CFLAGS in configure.ac. AM_CFLAGS is already used in Makefile.am. (Numerous merge conflicts resolved by Michael Plante) misc fixes to pthreads abstraction * windows_compat.h should not be directly included (use libusbi.h) * windows_usb.c still had some references to pthread_mutex_[un]lock Add libusb_strerror() to get short error message in English from enum (Merge conflicts resolved by Michael Plante) Better cleanup on errors, stricter types and some good casts Avoid various memory leaks in error code paths and remove warnings. Also add usbi_cond_destroy in os/threads_posix.h because it's used for cleanup now. (Merge conflicts resolved by Michael Plante) Rename all interface parameters to usb_interface or interface_number (Merge conflicts resolved by Michael Plante) Add type parameter to the list_for_each_entry() and _safe() macros (Merge conflicts resolved by Michael Plante) VA_ARGS workaround for logging with MSVC6 (Merge conflicts resolved by Michael Plante) Fix context memory leak in libusb_init() * Now holds default_context_lock for duration of libusb_init * Doesn't allocate it if not needed Fix the last MSVC /W3 warning removal of pthreads from MSVC and mingw * removed pthread*.lib from linking in msvc6 (2005/8 not yet edited) * added threads_windows.[ch] to all project files in msvc6 * added usbi_cond_signal to both threading versions, unused * added native windows threading code, now used removed redundant time.h includes removed pthread-win32 informational solution files updated MSVC 2005/2008 for thread abstraction fixed DDK build fixed cygwin's use of POSIX threads fixed dpfp/dpfp_threaded for MinGW compatibility config_msvc.h -> msvc/config.h pthread abstraction for DLL project files fixed bad reference to thread_windows in 2005 DLL vcproj cygwin ifdef is not required in threads_windows.h - removed fixed residuals from previous patches moved thread source detection into autotool scripts
* revert r102/f0d352: handle_timeouts() CORE modificationr163Pete Batard2010-02-181-56/+4
|
* r140: further simplification of the core include sectionsr140Pete Batard2010-02-031-4/+1
|
* r122: fixed poll conflict on cygwin (all compat functions renamed to ↵Pete Batard2010-01-281-9/+10
| | | | | | | _libusb_####) - fixed sscanf_s undefined for non MS compilers - fixed cygiwn warnings in windows_usb.c
* r116: DDK build completion (Orin Eman):Pete Batard2010-01-261-0/+2
| | | | | | - lsusb/xusb sources + ddk_build call - missing libusb_strerror in .def - removed "handle_timeouts_locked unused" warning in in io.c for MinGW
* r112: fixed missing mutex unlock on malloc fail, and destroy mutex/cv in ↵Michael Plante2010-01-251-1/+13
| | | | usbi_io_exit
* r110: fixed missing handle_timeouts_locked, which was removed with r102Pete Batard2010-01-241-0/+45
|
* r109: workaround for broken timercmp on both windows and some posix systems ↵Michael Plante2010-01-241-1/+1
| | | | (latter according to linux manpage, which says glibc does not have this problem)
* r102: handle_timeouts() CORE modificationPete Batard2010-01-221-28/+33
| | | | | - apply the same trick as usbi_handle_disconnect() to handle_timeouts(), so that usbi_handle_transfer_cancellation() can now be called from the backend without locking after a timeout. - remove the unneeded handle_timeouts_locked()
* r85: fixed MSVC warnings for x64 and reverted ssize_t to int for ↵Pete Batard2010-01-161-1/+1
| | | | libusb_get_device_list change introduced with r52. Added definition on ssize_t in libusb.h for MSVC platforms.
* Fix CR/LF inconsistenciesPete Batard2010-01-141-3/+3
|
* svn r55: - fixes list_for_each_entry calls for Darwin and LinuxPete Batard2010-01-141-1/+1
|
* svn r54: - fixes missing config_msvc.hPete Batard2010-01-141-10/+18
|
* svn r29:Pete Batard2010-01-141-8/+13
| | | | | - "poll we can believe in" (requires superficial modifications to core files) - move the "interface" fix into windows_compat.h
* mirror libusb-winusb git branch from 2009.12.03 part 2 - core filesPete Batard2010-01-141-0/+4
|
* Increase libusb_handle_events() timeout to 60 secondsDaniel Drake2009-11-211-6/+5
| | | | | The internal timing seems to be working, this will be a better test of it before we make this timeout unlimited.
* Refine timerfd header check (#18)Daniel Drake2009-11-211-1/+1
| | | | Require glibc-2.9 for the working timerfd support.
* Update documentation about early completion caveatsDaniel Drake2009-11-071-0/+4
|
* Use timerfd for timeout handlingDaniel Drake2009-11-071-28/+311
| | | | | | | | | | | | Use a new file descriptor from the timerfd system calls to handle timeouts. On supported systems, this means that there is less hassle figuring out when the poll() timeout should be, since libusb_get_next_timeout() will always return 0 and the timeout events will be triggered as regular activity on the file descriptor set. Add API function libusb_pollfds_handle_timeouts() to detect whether you're on a platform with the timing headache, and flesh out the surrounding documentation.
* Transfer lockingDaniel Drake2009-11-061-4/+21
| | | | | | | | | | | | At least on Linux, there were some possible races that could occur if a transfer is cancelled from one thread while another thread is handling an event for that transfer, or for if a transfer completes while it is still being submitted from another thread, etc. On the global level, transfers could be submitted and cancelled at the same time. Fix those issues with transfer-level locks.
* Add libusb_get_max_iso_packet_size()Daniel Drake2009-06-281-5/+10
| | | | | | | | | As pointed out by Dennis Muhlestein, libusb_get_max_packet_size() doesn't really do what the documentation might suggest because it does not consider the number of transaction opportunities per microframe. Add a new function to do what is useful for isochronous I/O.
* Darwin: Don't cancel transfers on timeoutNathan Hjelm2009-06-191-1/+8
| | | | ...because the OS does this for us.
* Abstract clock reading into OS layerNathan Hjelm2009-02-161-4/+4
| | | | | | This will differ on Linux and Darwin, at least. [dsd: minor style tweaks]
* Decrement poll() result when internal pipe has been handledDaniel Drake2009-01-171-0/+1
| | | | | | When we receive data on the internal control pipe, we need to correctly decrement the number of ready file descriptors before passing on the remaining work to the OS implementation.
* Prevent transfer from being submitted twice or improperly canceledDavid Moore2009-01-121-5/+3
| | | | | | | | | | This ensures that tpriv->urbs and tpriv->iso_urbs are always set to NULL whenever a transfer is not submitted. In this way, submit_*_transfer() and cancel_*_transfer() can error check to ensure that the transfer is in the correct state to be either submitted or canceled, preventing potential memory leaks or double frees. Signed-off-by: David Moore <dcm@acm.org>
* Improvements to multi-threaded I/O systemDaniel Drake2008-11-211-4/+137
| | | | | | Documentation brushed up, and I realised that another function is needed for tight event handling loops -- they must be able to check if an open/close operation is trying to interrupt it.
* Pause event handling while opening and closing devicesDaniel Drake2008-11-211-4/+71
| | | | | | | | | | | | | | | Ludovic Rousseau found that crashes often occur if you close a device while another thread is doing event handling. Fix this by adding an internal control pipe, which the close routines use to interrupt the event handler and obtain the event handling lock, ensuring that no other thread is handling events while the device is closed. After the close completes, it signals all the event handlers to start up again using the usual mechanism. Also modified libusb_open() to do a similar thing, so that event handlers are interrupted in order to realise that a new poll fd has appeared.
* Async I/O documentation touchupsDaniel Drake2008-08-271-5/+14
|
* Doc: fix typo in events lock sectionDaniel Drake2008-08-271-1/+1
|
* Reset internal transfer flags on submitDaniel Drake2008-08-231-0/+1
| | | | | | This fixes a problem pointed out by Lou, where resubmitting a transfer that previously timed out never timed out again, as if the timeout had been set to 0.
* Add missing GET_CONTEXT()Daniel Drake2008-06-281-0/+1
|
* Allow user data pointer to be passed through pollfd notification APIDaniel Drake2008-06-261-3/+7
|
* Introduce contexts to the APIDaniel Drake2008-06-261-155/+169
| | | | | Suggested by David Zeuthen. This allows multiple libraries in the same process to independently use libusb without interfering.
* Revert "Temporary workaround for event handling serialization issue"Daniel Drake2008-06-241-15/+1
| | | | | | This reverts commit 2d3a1111caff40ebb87983c861ff548cdc9e5946. This was based on the assumption that dying threads would automatically release mutexes, which is not the case.
* Overflow handlingDaniel Drake2008-06-201-0/+51
|
* round up poll timeoutDaniel Drake2008-06-151-0/+5
| | | | | Pointed out by Richard Röjfors, otherwise we end up busy-looping with a poll() timeout of 0.
* Temporary workaround for event handling serialization issueDaniel Drake2008-05-291-1/+15
| | | | | | | | | | | | Ludovic Rousseau pointed out that libusb_unlock_events() is not called when a thread gets terminated with a signal, meaning that event waiters will not be woken up in this case. Add a temporary hack to libusb_event_handler_active() so that at least the other threads will realise on the next iteration of their event handling loop. The real fix will likely involve reworking most of this.
* Take lock before raising event waiters conditionDaniel Drake2008-05-251-0/+2
| | | | | This avoids a race between the user checking for active event handler and then blocking on the condition variable
* Implement serialization of event handlersDaniel Drake2008-05-251-20/+507
| | | | | | Now offers a mechanism to wait for events while another thread is doing the event handling. Complicates things for MT async apps, but then again it's a bit of a tricky combination to start with.
* critical memory leak in handle_eventsDavid Engraf2008-05-191-0/+4
| | | | | | | This patch closes a critical memory leak in handle_events. The fds variable is malloced but never freed. When I'm calling handle_events with a timeout of 0, my system runs out of memory after a few seconds.
* Backend documentation for porting effortsDaniel Drake2008-05-131-0/+16
| | | | Hopefully comprehensive enough for people to get started.
* Handle hot-unpluggingDaniel Drake2008-05-111-40/+72
| | | | | This involved moving from select() to poll() because there is no way to distinguish usbfs's POLLERR condition with select().
* Endianness of control setup packetsDaniel Drake2008-05-111-13/+6
| | | | | | | | Document behaviour where host-endian and bus-endian (little) should be used respectively. Also remove packed attribute from libusb_control_setup as all fields are naturally aligned.
* documentation touchupsDaniel Drake2008-05-051-1/+1
|