summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-05-09 19:02:35 +0200
committerGravatar Nikias Bassen2022-05-09 19:02:35 +0200
commit3909271599917bc4a3a996f99bdd3f88c49577fa (patch)
treeeea92211456cff432b9512b73e350a6db2705a95
parent534ddefac4b7118bd4781cd91f8781d8727ff49a (diff)
downloadideviceinstaller-3909271599917bc4a3a996f99bdd3f88c49577fa.tar.gz
ideviceinstaller-3909271599917bc4a3a996f99bdd3f88c49577fa.tar.bz2
Ignore remove events when unsubscribing the event callback
Otherwise we see 'Device removed' messages which might be misleading.
-rw-r--r--src/ideviceinstaller.c6
1 files changed, 6 insertions, 0 deletions
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();
}