From 80eec8b83cca16d7a7c7cf9fc53422505cf31225 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 21 May 2020 04:36:29 +0200 Subject: idevice: [OpenSSL] Handle non-blocking SSL_write --- src/idevice.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/idevice.c b/src/idevice.c index 7b3625e..d3f28c2 100644 --- a/src/idevice.c +++ b/src/idevice.c @@ -549,7 +549,20 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_ uint32_t sent = 0; while (sent < len) { #ifdef HAVE_OPENSSL + int c = socket_check_fd((int)(long)connection->data, FDM_WRITE, 100); + if (c < 0) { + break; + } else if (c == 0) { + continue; + } int s = SSL_write(connection->ssl_data->session, (const void*)(data+sent), (int)(len-sent)); + if (s <= 0) { + int sslerr = SSL_get_error(connection->ssl_data->session, s); + if (sslerr == SSL_ERROR_WANT_WRITE) { + continue; + } + break; + } #else ssize_t s = gnutls_record_send(connection->ssl_data->session, (void*)(data+sent), (size_t)(len-sent)); #endif -- cgit v1.1-32-gdbae