summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
parent8f96c52de2f9f35f361d29095190fc673db7d1c1 (diff)
downloadlibimobiledevice-7e06820721be573b625921da86f736a89989d023.tar.gz
libimobiledevice-7e06820721be573b625921da86f736a89989d023.tar.bz2
idevicebackup2: Handle timeout vs. error condition in main loop
Diffstat (limited to 'tools')
-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 @@
2 * idevicebackup2.c 2 * idevicebackup2.c
3 * Command line interface to use the device's backup and restore service 3 * Command line interface to use the device's backup and restore service
4 * 4 *
5 * Copyright (c) 2010-2018 Nikias Bassen All Rights Reserved. 5 * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved.
6 * Copyright (c) 2009-2010 Martin Szulecki All Rights Reserved. 6 * Copyright (c) 2009-2010 Martin Szulecki, All Rights Reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
@@ -2128,6 +2128,7 @@ checkpoint:
2128 int operation_ok = 0; 2128 int operation_ok = 0;
2129 plist_t message = NULL; 2129 plist_t message = NULL;
2130 2130
2131 mobilebackup2_error_t mberr;
2131 char *dlmsg = NULL; 2132 char *dlmsg = NULL;
2132 int file_count = 0; 2133 int file_count = 0;
2133 int errcode = 0; 2134 int errcode = 0;
@@ -2138,10 +2139,13 @@ checkpoint:
2138 do { 2139 do {
2139 free(dlmsg); 2140 free(dlmsg);
2140 dlmsg = NULL; 2141 dlmsg = NULL;
2141 mobilebackup2_receive_message(mobilebackup2, &message, &dlmsg); 2142 mberr = mobilebackup2_receive_message(mobilebackup2, &message, &dlmsg);
2142 if (!message || !dlmsg) { 2143 if (mberr == MOBILEBACKUP2_E_RECEIVE_TIMEOUT) {
2143 PRINT_VERBOSE(1, "Device is not ready yet. Going to try again in 2 seconds...\n"); 2144 PRINT_VERBOSE(2, "Device is not ready yet, retrying...\n");
2144 sleep(2); 2145 goto files_out;
2146 } else if (mberr != MOBILEBACKUP2_E_SUCCESS) {
2147 PRINT_VERBOSE(0, "ERROR: Could not receive from mobilebackup2 (%d)\n", mberr);
2148 quit_flag++;
2145 goto files_out; 2149 goto files_out;
2146 } 2150 }
2147 2151