diff options
author | Nikias Bassen | 2019-10-11 23:08:48 +0200 |
---|---|---|
committer | Nikias Bassen | 2019-10-11 23:10:07 +0200 |
commit | 767fcceaeb456f5e281a6bd1b3f51713e4989293 (patch) | |
tree | d9a01fbea3c1a85f41ca0f033037737739a14629 /src/restore.c | |
parent | 75a61508bd3c2013492744fb5aea755e19b01086 (diff) | |
download | idevicerestore-767fcceaeb456f5e281a6bd1b3f51713e4989293.tar.gz idevicerestore-767fcceaeb456f5e281a6bd1b3f51713e4989293.tar.bz2 |
Use condition variable instead of active waiting for device event handling
With some devices and USB hardware the reconnect of a device might actually
be faster than the check interval of the active waiting loop. With mutexes
and a condition variable we will not miss the moment of reconnect anymore,
even if it is really quick (like 7ms, right DanyL?)
Diffstat (limited to 'src/restore.c')
-rw-r--r-- | src/restore.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/restore.c b/src/restore.c index 0ea8a45..fea57fb 100644 --- a/src/restore.c +++ b/src/restore.c @@ -306,15 +306,19 @@ int restore_reboot(struct idevicerestore_client_t* client) } } + mutex_lock(&client->device_event_mutex); + info("Rebooting restore mode device...\n"); restored_reboot(client->restore->client); restored_client_free(client->restore->client); - WAIT_FOR(client->mode != &idevicerestore_modes[MODE_RESTORE] || (client->flags & FLAG_QUIT), 30); + cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 30000); if (client->mode == &idevicerestore_modes[MODE_RESTORE]) { + mutex_unlock(&client->device_event_mutex); return -1; } + mutex_unlock(&client->device_event_mutex); return 0; } |