summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-06-24 20:19:32 +0200
committerGravatar Nikias Bassen2019-06-24 20:19:32 +0200
commit7cb1bdf78ce8963da2923d6098645cb648e30259 (patch)
tree129a1e88c4e11cbfbd988bd005031568ed0f491d
parent35a7a8740c4109fc83ef64199d075129a6f4da6d (diff)
downloadidevicerestore-7cb1bdf78ce8963da2923d6098645cb648e30259.tar.gz
idevicerestore-7cb1bdf78ce8963da2923d6098645cb648e30259.tar.bz2
fdr: Handle new timeout error conditions (introduced in latest libimobiledevice)
-rw-r--r--configure.ac12
-rw-r--r--src/fdr.c26
2 files changed, 31 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index c9fcb91..e216535 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,18 @@ if test x$ac_cv_func_strsep != xyes; then
fi
fi
+# check if libimobiledevice has timeout errors
+AC_CACHE_CHECK(for IDEVICE_E_TIMEOUT in enum idevice_error_t, ac_cv_idevice_error_has_timeout,
+ AC_TRY_COMPILE([
+ #include <libimobiledevice/libimobiledevice.h>
+ ], [
+ return IDEVICE_E_TIMEOUT;
+ ], ac_cv_idevice_error_has_timeout=yes, ac_cv_idevice_error_has_timeout=no))
+
+if test "$ac_cv_idevice_error_has_timeout" = "yes"; then
+ AC_DEFINE(HAVE_IDEVICE_E_TIMEOUT, 1, [Define if enum idevice_error_t defines IDEVICE_E_TIMEOUT])
+fi
+
AC_SUBST(GLOBAL_CFLAGS)
AC_SUBST(AC_LDFLAGS)
AC_SUBST(AC_LDADD)
diff --git a/src/fdr.c b/src/fdr.c
index d7dc8d1..68b9aed 100644
--- a/src/fdr.c
+++ b/src/fdr.c
@@ -143,14 +143,20 @@ int fdr_poll_and_handle_message(fdr_client_t fdr)
}
device_error = idevice_connection_receive_timeout(fdr->connection, (char *)&cmd, sizeof(cmd), &bytes, 20000);
- if (device_error != IDEVICE_E_SUCCESS) {
+#ifdef HAVE_IDEVICE_E_TIMEOUT
+ if (device_error == IDEVICE_E_TIMEOUT || (device_error == IDEVICE_E_SUCCESS && bytes != sizeof(cmd)))
+#else
+ if (device_error == IDEVICE_ESUCCESS && bytes != sizeof(cmd))
+#endif
+ {
+ debug("FDR %p timeout waiting for command\n", fdr);
+ return 0;
+ }
+ else if (device_error != IDEVICE_E_SUCCESS) {
if (fdr->connection) {
error("ERROR: Unable to receive message from FDR %p (%d). %u/%d bytes\n", fdr, device_error, bytes, sizeof(cmd));
}
return -1;
- } else if (bytes != sizeof(cmd)) {
- debug("FDR %p timeout waiting for command\n", fdr);
- return 0;
}
if (cmd == FDR_SYNC_MSG) {
@@ -540,12 +546,18 @@ static int fdr_handle_proxy_cmd(fdr_client_t fdr)
while (1) {
bytes = 0;
device_error = idevice_connection_receive_timeout(fdr->connection, buf, sizeof(buf), &bytes, 100);
- if (device_error != IDEVICE_E_SUCCESS) {
+#ifdef HAVE_IDEVICE_E_TIMEOUT
+ if (device_error == IDEVICE_E_TIMEOUT || (device_error == IDEVICE_E_SUCCESS && !bytes))
+#else
+ if (device_error == IDEVICE_E_SUCCESS && !bytes)
+#endif
+ {
+ //debug("WARNING: Timeout waiting for proxy payload. %p\n", fdr);
+ }
+ else if (device_error != IDEVICE_E_SUCCESS) {
error("ERROR: FDR %p Unable to receive proxy payload (%d)\n", fdr, device_error);
res = -1;
break;
- } else if (!bytes) {
- //debug("WARNING: Timeout waiting for proxy payload. %p\n", fdr);
}
if (bytes) {
debug("FDR %p got payload of %u bytes, now try to proxy it\n", fdr, bytes);