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_
}
*sent_bytes = sent;
return IDEVICE_E_SUCCESS;
+ } else {
+ uint32_t sent = 0;
+ while (sent < len) {
+ uint32_t bytes = 0;
+ int s = internal_connection_send(connection, data+sent, len-sent, &bytes);
+ if (s < 0) {
+ break;
+ }
+ sent += bytes;
+ }
+ debug_info("internal_connection_send %d, sent %d", len, sent);
+ if (sent < len) {
+ *sent_bytes = 0;
+ return IDEVICE_E_NOT_ENOUGH_DATA;
+ }
+ *sent_bytes = sent;
+ return IDEVICE_E_SUCCESS;
}
- return internal_connection_send(connection, data, len, sent_bytes);
}
static idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received)