summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-05-18 20:14:20 +0200
committerGravatar Nikias Bassen2020-05-18 20:14:20 +0200
commit397961eccdcf6aefd2733a615dd5d8870f440889 (patch)
tree5865e59ddf1233181fc2e19580a7d90412dcf4c3
parent0268777212847afd7734cb280115aea70dc81c92 (diff)
downloadlibimobiledevice-397961eccdcf6aefd2733a615dd5d8870f440889.tar.gz
libimobiledevice-397961eccdcf6aefd2733a615dd5d8870f440889.tar.bz2
idevice_connection_send: Make sure send works with non-blocking sockets
-rw-r--r--src/idevice.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/idevice.c b/src/idevice.c
index 418ee86..7b3625e 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -565,8 +565,24 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_
565 } 565 }
566 *sent_bytes = sent; 566 *sent_bytes = sent;
567 return IDEVICE_E_SUCCESS; 567 return IDEVICE_E_SUCCESS;
568 } else {
569 uint32_t sent = 0;
570 while (sent < len) {
571 uint32_t bytes = 0;
572 int s = internal_connection_send(connection, data+sent, len-sent, &bytes);
573 if (s < 0) {
574 break;
575 }
576 sent += bytes;
577 }
578 debug_info("internal_connection_send %d, sent %d", len, sent);
579 if (sent < len) {
580 *sent_bytes = 0;
581 return IDEVICE_E_NOT_ENOUGH_DATA;
582 }
583 *sent_bytes = sent;
584 return IDEVICE_E_SUCCESS;
568 } 585 }
569 return internal_connection_send(connection, data, len, sent_bytes);
570} 586}
571 587
572static idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received) 588static idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received)