diff options
author | 2021-07-25 16:06:28 +0200 | |
---|---|---|
committer | 2021-07-25 16:06:28 +0200 | |
commit | 65fddc7b67ae6bcebce54f0b55e4191332067c73 (patch) | |
tree | cf955b519e4aa386dcb87604ad234521d8798d1e /src | |
parent | 3d85cc0c2a74aa0e3f7ad322233399cc35fcd7b8 (diff) | |
download | libimobiledevice-65fddc7b67ae6bcebce54f0b55e4191332067c73.tar.gz libimobiledevice-65fddc7b67ae6bcebce54f0b55e4191332067c73.tar.bz2 |
idevice: Make sure to handle timeout condition for network connections too
Diffstat (limited to 'src')
-rw-r--r-- | src/idevice.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/idevice.c b/src/idevice.c index 071d7b9..ecc0418 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
@@ -615,7 +615,11 @@ static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint3 | |||
615 | if (conn_error < 0) { | 615 | if (conn_error < 0) { |
616 | switch (conn_error) { | 616 | switch (conn_error) { |
617 | case -EAGAIN: | 617 | case -EAGAIN: |
618 | debug_info("ERROR: received partial data %d/%d (%s)", received, len, strerror(-conn_error)); | 618 | if (len) { |
619 | debug_info("ERROR: received partial data %d/%d (%s)", received, len, strerror(-conn_error)); | ||
620 | } else { | ||
621 | debug_info("ERROR: received partial data (%s)", strerror(-conn_error)); | ||
622 | } | ||
619 | return IDEVICE_E_NOT_ENOUGH_DATA; | 623 | return IDEVICE_E_NOT_ENOUGH_DATA; |
620 | case -ETIMEDOUT: | 624 | case -ETIMEDOUT: |
621 | return IDEVICE_E_TIMEOUT; | 625 | return IDEVICE_E_TIMEOUT; |
@@ -623,7 +627,6 @@ static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint3 | |||
623 | return IDEVICE_E_UNKNOWN_ERROR; | 627 | return IDEVICE_E_UNKNOWN_ERROR; |
624 | } | 628 | } |
625 | } | 629 | } |
626 | |||
627 | return IDEVICE_E_SUCCESS; | 630 | return IDEVICE_E_SUCCESS; |
628 | } | 631 | } |
629 | 632 | ||
@@ -640,20 +643,19 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t | |||
640 | if (connection->type == CONNECTION_USBMUXD) { | 643 | if (connection->type == CONNECTION_USBMUXD) { |
641 | int conn_error = usbmuxd_recv_timeout((int)(long)connection->data, data, len, recv_bytes, timeout); | 644 | int conn_error = usbmuxd_recv_timeout((int)(long)connection->data, data, len, recv_bytes, timeout); |
642 | idevice_error_t error = socket_recv_to_idevice_error(conn_error, len, *recv_bytes); | 645 | idevice_error_t error = socket_recv_to_idevice_error(conn_error, len, *recv_bytes); |
643 | |||
644 | if (error == IDEVICE_E_UNKNOWN_ERROR) { | 646 | if (error == IDEVICE_E_UNKNOWN_ERROR) { |
645 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error)); | 647 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error)); |
646 | } | 648 | } |
647 | |||
648 | return error; | 649 | return error; |
649 | } else if (connection->type == CONNECTION_NETWORK) { | 650 | } else if (connection->type == CONNECTION_NETWORK) { |
650 | int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout); | 651 | int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout); |
651 | if (res < 0) { | 652 | idevice_error_t error = socket_recv_to_idevice_error(res, 0, 0); |
652 | debug_info("ERROR: socket_receive_timeout failed: %d (%s)", res, strerror(-res)); | 653 | if (error == IDEVICE_E_SUCCESS) { |
653 | return (res == -EAGAIN ? IDEVICE_E_NOT_ENOUGH_DATA : IDEVICE_E_UNKNOWN_ERROR); | 654 | *recv_bytes = (uint32_t)res; |
655 | } else if (error == IDEVICE_E_UNKNOWN_ERROR) { | ||
656 | debug_info("ERROR: socket_receive_timeout returned %d (%s)", res, strerror(-res)); | ||
654 | } | 657 | } |
655 | *recv_bytes = (uint32_t)res; | 658 | return error; |
656 | return IDEVICE_E_SUCCESS; | ||
657 | } else { | 659 | } else { |
658 | debug_info("Unknown connection type %d", connection->type); | 660 | debug_info("Unknown connection type %d", connection->type); |
659 | } | 661 | } |