From 3909271599917bc4a3a996f99bdd3f88c49577fa Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 9 May 2022 19:02:35 +0200 Subject: Ignore remove events when unsubscribing the event callback Otherwise we see 'Device removed' messages which might be misleading. --- src/ideviceinstaller.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c index e45bb12..2334199 100644 --- a/src/ideviceinstaller.c +++ b/src/ideviceinstaller.c @@ -117,6 +117,7 @@ int use_notifier = 0; int notification_expected = 0; int is_device_connected = 0; int command_completed = 0; +int ignore_events = 0; int err_occurred = 0; int notified = 0; @@ -351,6 +352,9 @@ static int zip_get_app_directory(struct zip* zf, char** path) static void idevice_event_callback(const idevice_event_t* event, void* userdata) { + if (ignore_events) { + return; + } if (event->event == IDEVICE_DEVICE_REMOVE) { if (!strcmp(udid, event->udid)) { fprintf(stderr, "ideviceinstaller: Device removed\n"); @@ -362,6 +366,7 @@ static void idevice_event_callback(const idevice_event_t* event, void* userdata) static void idevice_wait_for_command_to_complete() { is_device_connected = 1; + ignore_events = 0; /* subscribe to make sure to exit on device removal */ idevice_event_subscribe(idevice_event_callback, NULL); @@ -377,6 +382,7 @@ static void idevice_wait_for_command_to_complete() wait_ms(50); } + ignore_events = 1; idevice_event_unsubscribe(); } -- cgit v1.1-32-gdbae