summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/idevice.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/idevice.c b/src/idevice.c
index 02d34cc..794af8b 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -453,19 +453,24 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_
453 453
454 if (connection->ssl_data) { 454 if (connection->ssl_data) {
455 uint32_t received = 0; 455 uint32_t received = 0;
456 int do_select = 1;
456 457
457 while (received < len) { 458 while (received < len) {
458 459#ifdef HAVE_OPENSSL
459 int conn_error = socket_check_fd((int)(long)connection->data, FDM_READ, timeout); 460 do_select = (SSL_pending(connection->ssl_data->session) == 0);
460 idevice_error_t error = socket_recv_to_idevice_error(conn_error, len, received); 461#endif
461 462 if (do_select) {
462 switch (error) { 463 int conn_error = socket_check_fd((int)(long)connection->data, FDM_READ, timeout);
463 case IDEVICE_E_SUCCESS: 464 idevice_error_t error = socket_recv_to_idevice_error(conn_error, len, received);
464 break; 465
465 case IDEVICE_E_UNKNOWN_ERROR: 466 switch (error) {
466 debug_info("ERROR: socket_check_fd returned %d (%s)", conn_error, strerror(-conn_error)); 467 case IDEVICE_E_SUCCESS:
467 default: 468 break;
468 return error; 469 case IDEVICE_E_UNKNOWN_ERROR:
470 debug_info("ERROR: socket_check_fd returned %d (%s)", conn_error, strerror(-conn_error));
471 default:
472 return error;
473 }
469 } 474 }
470 475
471#ifdef HAVE_OPENSSL 476#ifdef HAVE_OPENSSL