summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-09-27 13:48:54 +0200
committerGravatar Nikias Bassen2019-09-27 13:48:54 +0200
commit7e06820721be573b625921da86f736a89989d023 (patch)
treee53d1c5a91c7ee785c3672f81caf13ae214cad51
parent8f96c52de2f9f35f361d29095190fc673db7d1c1 (diff)
downloadlibimobiledevice-7e06820721be573b625921da86f736a89989d023.tar.gz
libimobiledevice-7e06820721be573b625921da86f736a89989d023.tar.bz2
idevicebackup2: Handle timeout vs. error condition in main loop
-rw-r--r--tools/idevicebackup2.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index 58fda8d..1ac5d1a 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -2,8 +2,8 @@
* idevicebackup2.c
* Command line interface to use the device's backup and restore service
*
- * Copyright (c) 2010-2018 Nikias Bassen All Rights Reserved.
- * Copyright (c) 2009-2010 Martin Szulecki All Rights Reserved.
+ * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.
+ * Copyright (c) 2009-2010 Martin Szulecki, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -2128,6 +2128,7 @@ checkpoint:
int operation_ok = 0;
plist_t message = NULL;
+ mobilebackup2_error_t mberr;
char *dlmsg = NULL;
int file_count = 0;
int errcode = 0;
@@ -2138,10 +2139,13 @@ checkpoint:
do {
free(dlmsg);
dlmsg = NULL;
- mobilebackup2_receive_message(mobilebackup2, &message, &dlmsg);
- if (!message || !dlmsg) {
- PRINT_VERBOSE(1, "Device is not ready yet. Going to try again in 2 seconds...\n");
- sleep(2);
+ mberr = mobilebackup2_receive_message(mobilebackup2, &message, &dlmsg);
+ if (mberr == MOBILEBACKUP2_E_RECEIVE_TIMEOUT) {
+ PRINT_VERBOSE(2, "Device is not ready yet, retrying...\n");
+ goto files_out;
+ } else if (mberr != MOBILEBACKUP2_E_SUCCESS) {
+ PRINT_VERBOSE(0, "ERROR: Could not receive from mobilebackup2 (%d)\n", mberr);
+ quit_flag++;
goto files_out;
}