summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-09-26 06:54:24 +0200
committerGravatar Nikias Bassen2019-09-26 06:54:24 +0200
commit2578b8c6c152a88a21931596cd0055d6607ecdcf (patch)
tree1a588d95123014b875a55f616d9e731dff1d61b7 /src
parent83087efe7197dcae77d94a8ff56e1eb70907aa9e (diff)
downloadidevicerestore-2578b8c6c152a88a21931596cd0055d6607ecdcf.tar.gz
idevicerestore-2578b8c6c152a88a21931596cd0055d6607ecdcf.tar.bz2
Add more cancellation points to handle CTRL+C
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c28
-rw-r--r--src/normal.c6
2 files changed, 31 insertions, 3 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index edb977c..9dc6ce8 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1000,6 +1000,9 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
}
+ if (client->flags & FLAG_QUIT) {
+ return -1;
+ }
if (get_tss_response(client, build_identity, &client->tss) < 0) {
error("ERROR: Unable to get SHSH blobs for this device\n");
return -1;
@@ -1019,6 +1022,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
}
+ if (client->flags & FLAG_QUIT) {
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -1;
+ }
if (client->flags & FLAG_SHSHONLY) {
if (!tss_enabled) {
info("This device does not require a TSS record\n");
@@ -1073,6 +1081,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
fixup_tss(client->tss);
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.25);
+ if (client->flags & FLAG_QUIT) {
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -1;
+ }
// if the device is in normal mode, place device into recovery mode
if (client->mode->index == MODE_NORMAL) {
@@ -1087,6 +1100,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.3);
+ if (client->flags & FLAG_QUIT) {
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -1;
+ }
// if the device is in DFU mode, place device into recovery mode
if (client->mode->index == MODE_DFU) {
@@ -1148,6 +1166,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
sleep(7);
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.5);
+ if (client->flags & FLAG_QUIT) {
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -1;
+ }
if (!client->image4supported && (client->build_major > 8)) {
// we need another tss request with nonce.
@@ -1192,6 +1215,11 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.7);
+ if (client->flags & FLAG_QUIT) {
+ if (delete_fs && filesystem)
+ unlink(filesystem);
+ return -1;
+ }
// now finally do the magic to put the device into restore mode
if (client->mode->index == MODE_RECOVERY) {
diff --git a/src/normal.c b/src/normal.c
index 14fa0f6..89ec462 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -238,14 +238,14 @@ int normal_enter_recovery(struct idevicerestore_client_t* client)
device = NULL;
debug("DEBUG: Waiting for device to disconnect...\n");
- WAIT_FOR(client->mode != &idevicerestore_modes[MODE_NORMAL] || (client->flags & FLAG_QUIT), 30);
+ WAIT_FOR(client->mode != &idevicerestore_modes[MODE_NORMAL] || (client->flags & FLAG_QUIT), 60);
if (client->mode == &idevicerestore_modes[MODE_NORMAL] || (client->flags & FLAG_QUIT)) {
error("ERROR: Failed to place device in recovery mode\n");
return -1;
}
debug("DEBUG: Waiting for device to connect in recovery mode...\n");
- WAIT_FOR(client->mode == &idevicerestore_modes[MODE_RECOVERY] || (client->flags & FLAG_QUIT), 30);
+ WAIT_FOR(client->mode == &idevicerestore_modes[MODE_RECOVERY] || (client->flags & FLAG_QUIT), 60);
if (client->mode != &idevicerestore_modes[MODE_RECOVERY] || (client->flags & FLAG_QUIT)) {
error("ERROR: Failed to enter recovery mode\n");
return -1;
@@ -425,7 +425,7 @@ int normal_handle_create_stashbag(struct idevicerestore_client_t* client, plist_
}
int ticks = 0;
- while (ticks++ < 130) {
+ while (ticks++ < 130 && !(client->flags & FLAG_QUIT)) {
plist_t pl = NULL;
perr = preboard_receive_with_timeout(preboard, &pl, 1000);
if (perr == PREBOARD_E_TIMEOUT) {