Skip to content

preflight: serialize device visibility and notifications - #290

Open
ooonea wants to merge 1 commit into
libimobiledevice:masterfrom
ooonea:fix-preflight-lock-order
Open

ooonea wants to merge 1 commit into
libimobiledevice:masterfrom
ooonea:fix-preflight-lock-order

Conversation

@ooonea

@ooonea ooonea commented Oct 7, 2026

Copy link
Copy Markdown

Preflight takes the client-list mutex before the device-list mutex
(src/client.c:989-991); removal takes them in reverse order
(src/device.c:864-873). Concurrent preflight completion and disconnect
can deadlock usbmuxd.

Publish visibility and the attached event under the device lock before
taking the client lock. Skip the added event if the device has disappeared.

Validation: the original deterministic concurrency test deadlocks; the
patched add-first, remove-first, absent-device and duplicate-add cases pass.
Linux builds with preflight enabled and disabled pass with -Werror.

Assisted-by: OpenAI Codex

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant