From fa2bc21668919751be087e621cd5f327c03a78f9 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 24 Sep 2021 09:03:44 +0200 Subject: Prevent unnecessary delay on inital device detection --- src/idevicerestore.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/idevicerestore.c b/src/idevicerestore.c index d20de69..615aa0f 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -346,11 +346,13 @@ int idevicerestore_start(struct idevicerestore_client_t* client) // check which mode the device is currently in so we know where to start mutex_lock(&client->device_event_mutex); - cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000); - if (client->mode == MODE_UNKNOWN || (client->flags & FLAG_QUIT)) { - mutex_unlock(&client->device_event_mutex); - error("ERROR: Unable to discover device mode. Please make sure a device is attached.\n"); - return -1; + if (client->mode == MODE_UNKNOWN) { + cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000); + if (client->mode == MODE_UNKNOWN || (client->flags & FLAG_QUIT)) { + mutex_unlock(&client->device_event_mutex); + error("ERROR: Unable to discover device mode. Please make sure a device is attached.\n"); + return -1; + } } idevicerestore_progress(client, RESTORE_STEP_DETECT, 0.1); info("Found device in %s mode\n", client->mode->string); -- cgit v1.1-32-gdbae