From 333b7b972a52162de00940dfa75a2cbd87efd9de Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:32:43 +0200 Subject: Try five times to retrieve validation plist if it failed This fixes hanging as the following payload message is not received initially but after polling the second time. --- src/asr.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/asr.c') diff --git a/src/asr.c b/src/asr.c index 2331660..3f9b392 100644 --- a/src/asr.c +++ b/src/asr.c @@ -137,6 +137,7 @@ int asr_perform_validation(idevice_connection_t asr, const char* filesystem) { plist_t packet = NULL; plist_t packet_info = NULL; plist_t payload_info = NULL; + int attempts = 0; file = fopen(filesystem, "rb"); if (file == NULL) { @@ -172,6 +173,17 @@ int asr_perform_validation(idevice_connection_t asr, const char* filesystem) { return -1; } + if (packet == NULL) { + if (attempts < 5) { + info("Retrying to receive validation packet... %d\n", attempts); + attempts++; + sleep(1); + continue; + } + } + + attempts = 0; + node = plist_dict_get_item(packet, "Command"); if (!node || plist_get_node_type(node) != PLIST_STRING) { error("ERROR: Unable to find command node in validation request\n"); @@ -181,10 +193,7 @@ int asr_perform_validation(idevice_connection_t asr, const char* filesystem) { if (!strcmp(command, "OOBData")) { asr_handle_oob_data_request(asr, packet, file); - - plist_free(packet); - } else if(!strcmp(command, "Payload")) { plist_free(packet); break; -- cgit v1.1-32-gdbae From 9433af8a8c8f6d8718712d59547d3c333402551b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:38:53 +0200 Subject: Only debug a plist if debugging flag was set --- src/asr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/asr.c') diff --git a/src/asr.c b/src/asr.c index 3f9b392..f48170a 100644 --- a/src/asr.c +++ b/src/asr.c @@ -87,7 +87,9 @@ int asr_receive(idevice_connection_t asr, plist_t* data) { *data = request; - debug("Received %d bytes:\n%s\n", size, buffer); + debug("Received %d bytes:\n", size); + if (idevicerestore_debug) + debug_plist(request); free(buffer); return 0; } @@ -104,7 +106,8 @@ int asr_send(idevice_connection_t asr, plist_t* data) { } debug("Sent %d bytes:\n", size); - debug_plist(data); + if (idevicerestore_debug) + debug_plist(*data); free(buffer); return 0; } @@ -119,6 +122,8 @@ int asr_send_buffer(idevice_connection_t asr, const char* data, uint32_t size) { return -1; } + debug("Sent %d bytes buffer\n", bytes); + return 0; } -- cgit v1.1-32-gdbae