summaryrefslogtreecommitdiffstats
path: root/src/preflight.c
diff options
context:
space:
mode:
authorGravatar Giuseppe Piscitelli2026-10-07 17:09:50 +0200
committerGravatar Nikias Bassen2026-11-22 18:20:36 +0100
commit7bcdc4104da6db55af3275da3e0ec86996c0f6ab (patch)
treeff29de2d9e07d077562af0a74496df8a34d43981 /src/preflight.c
parent8fbdb7a82034c3c96c0b7547f54302e2a5978465 (diff)
downloadusbmuxd-7bcdc4104da6db55af3275da3e0ec86996c0f6ab.tar.gz
usbmuxd-7bcdc4104da6db55af3275da3e0ec86996c0f6ab.tar.bz2
preflight: serialize device visibility and notifications
Publish device visibility and the attached notification under device_list_mutex, then acquire client_list_mutex in the same order as device removal. Do not notify clients if preflight completes after the device has disappeared. Assisted-by: OpenAI Codex
Diffstat (limited to 'src/preflight.c')
-rw-r--r--src/preflight.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/preflight.c b/src/preflight.c
index 28818fb..be44231 100644
--- a/src/preflight.c
+++ b/src/preflight.c
@@ -170,7 +170,7 @@ retry:
// make restore mode devices visible
free(type);
usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid);
- client_device_add(info);
+ device_set_visible(info);
goto leave;
}
free(type);
@@ -185,7 +185,7 @@ retry:
if (lerr == LOCKDOWN_E_SUCCESS) {
usbmuxd_log(LL_INFO, "%s: StartSession success for device %s", __func__, _dev->udid);
usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid);
- client_device_add(info);
+ device_set_visible(info);
goto leave;
}
@@ -261,7 +261,7 @@ retry:
/* if device is still showing the setup screen it will pair even without trust dialog */
usbmuxd_log(LL_INFO, "%s: Pair success for device %s", __func__, _dev->udid);
usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid);
- client_device_add(info);
+ device_set_visible(info);
goto leave;
}
}
@@ -271,7 +271,7 @@ retry:
if (lerr != LOCKDOWN_E_SUCCESS) {
/* even though we failed, simple mode should still work, so only warn of an error */
usbmuxd_log(LL_INFO, "%s: ERROR: Could not start insecure_notification_proxy on %s, lockdown error %d", __func__, _dev->udid, lerr);
- client_device_add(info);
+ device_set_visible(info);
goto leave;
}
@@ -305,7 +305,7 @@ retry:
usbmuxd_log(LL_INFO, "%s: Waiting for user to trust this computer on device %s", __func__, _dev->udid);
/* make device visible anyways */
- client_device_add(info);
+ device_set_visible(info);
while (cbdata.np && cbdata.is_device_connected && !cbdata.is_finished) {
sleep(1);
@@ -331,7 +331,7 @@ retry:
usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid);
/* make device visible anyways */
- client_device_add(info);
+ device_set_visible(info);
goto leave;
}
@@ -354,7 +354,7 @@ retry:
usbmuxd_log(LL_INFO, "%s: Finished preflight on device %s", __func__, _dev->udid);
/* emit device added event and thus make device visible to clients */
- client_device_add(info);
+ device_set_visible(info);
}
leave:
@@ -379,7 +379,7 @@ void preflight_device_remove_cb(void *data)
void preflight_worker_device_add(struct device_info* info)
{
if (info->pid == PID_APPLE_T2_COPROCESSOR || no_preflight == 1) {
- client_device_add(info);
+ device_set_visible(info);
return;
}
@@ -396,12 +396,12 @@ void preflight_worker_device_add(struct device_info* info)
if (perr != 0) {
free((char*)infocopy->serial);
free(infocopy);
- usbmuxd_log(LL_ERROR, "ERROR: failed to start preflight worker thread for device %s: %s (%d). Invoking client_device_add() directly but things might not work as expected.", info->serial, strerror(perr), perr);
- client_device_add(info);
+ usbmuxd_log(LL_ERROR, "ERROR: failed to start preflight worker thread for device %s: %s (%d). Invoking device_set_visible() directly but things might not work as expected.", info->serial, strerror(perr), perr);
+ device_set_visible(info);
} else {
thread_detach(th);
}
#else
- client_device_add(info);
+ device_set_visible(info);
#endif
}