| Age | Commit message (Collapse) | Author | Files | Lines |
|
If usbmuxd_events_unsubscribe() is called before the device monitor
thread has connected to usbmuxd, listenfd is still -1, so there is
nothing to shut down. Where thread_cancel() is not available (Windows,
or builds without pthread_cancel) unsubscribe then relies on clearing
`running`, but device_monitor() sets `running = 1` and `cancelling = 0`
itself when it starts and overwrites that. The thread goes on to
connect, sends Listen and blocks in receive_packet() forever, so
thread_join() never returns.
This is easy to hit with ideviceinstaller on Windows with a network
device and redirected stdout: the command completes before
idevice_wait_for_command_to_complete() subscribes, so subscribe and
unsubscribe happen back to back and the tool hangs on exit.
Fix this by:
- initializing `running`/`cancelling` in usbmuxd_events_subscribe()
under listener_mutex before the monitor thread is created;
- publishing listenfd in device_monitor() under the same mutex, and only
if no cancellation was requested in the meantime (otherwise close the
new socket and exit);
- setting `cancelling`/`running` and shutting down listenfd under the
mutex in usbmuxd_events_unsubscribe(), and only if the socket exists.
|
|
The primary purpose of this change is to support NetBSD.
No functional changes intended.
|
|
|
|
|
|
|
|
|
|
|
|
Since socket_send already returns -errno, this function should pass it as is
|
|
inotify_init creates a file descriptor which by default is not makes
with CLOEXEC. If the application using libusbmuxd spawns applications
this then leaks through.
|
|
|
|
|
|
|
|
|
|
|
|
Thanks to @timgates42 for pointing this out.
|
|
|
|
|
|
[clang-tidy] Found with google-readability-casting
Signed-off-by: Rosen Penev rosenp@gmail.com
|
|
[clang-tidy] Found with readability-else-after-return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
[clang-tidy] Found with readability-redundant-control-flow
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
[clang-tidy] Found with readability-inconsistent-declaration-parameter-name
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
|
|
usbmuxd_unsubscribe()
|
|
|
|
|
|
|
|
|
|
can be used in different threads
|
|
Fixes #63.
|
|
|
|
|
|
|
|
|
|
|
|
By using USBMUXD_SOCKET_ADDRESS environment variable, it is possible
to make libusbmuxd connect to the specified address. The value needs
to be in format ADDRESS:PORT (or UNIX:PATH on unix systems). If no port
number is specified or parsing fails, the standard socket address (or
unix domain socket file path) will be used silently.
|
|
This commit extends the interface with a new function usbmuxd_get_device()
that allows to look up USB *and* network devices, while the 'old' interface
usbmuxd_get_device_by_udid() only targets USB devices.
The usbmuxd_device_info_t structure now has new members 'conn_type' and
'conn_data' so that the returned device info allows to figure out if
a device is available via USB or network. Check the comments in
include/usbmuxd.h for more details.
|
|
|
|
compiler warning
|
|
|
|
|
|
usbmux id
|
|
|
|
|
|
|
|
Fixes compilation on OpenBSD, which surprisingly doesn't have them
|
|
Similar to the previous commit, WaitForSingleObject may return an error
code. While not sure how to handle this error we return it to the caller
of usbmuxd_unsubscribe.
|
|
In order to avoid race condition between an usbmuxd_event_cb_t firing in
a different thread and usbmuxd_unsubscribe() being called, libusbmuxd
users must assume that once usbmuxd_unsubcribe() returns, no more
usbmuxd_event_cb_t callbacks will fire, but also that those which were
already started when usbmuxd_unsubcribe() is called will have completed.
usbmuxd_unsubcribe() tries to guarantee this, but
pthread_kill/pthread_join may fail, in which case this guarantee would
not hold. This commit makes sure an error is reported to the caller when
we get in this situation (though I'm not really sure how the caller
could handle it).
|
|
|
|
|
|
error to the user on receiving this message.
|