]> sjero.net Git - wget/blobdiff - src/openssl.c
openssl: Retry to read if a non-blocking socket returns immediately.
[wget] / src / openssl.c
index 5520a77ecaf5e2a281e44577ff8819fc9edd640e..201d24597995bbba66460fe709dcbb5f281dc9c3 100644 (file)
@@ -46,6 +46,10 @@ as that of the covered work.  */
 #include "url.h"
 #include "ssl.h"
 
+#ifdef WINDOWS
+# include <w32sock.h>
+#endif
+
 /* Application-wide SSL context.  This is common to all SSL
    connections.  */
 static SSL_CTX *ssl_ctx;
@@ -257,8 +261,10 @@ openssl_read (int fd, char *buf, int bufsize, void *arg)
   do
     ret = SSL_read (conn, buf, bufsize);
   while (ret == -1
-         && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
-         && errno == EINTR);
+         && (SSL_get_error (conn, ret) == SSL_ERROR_WANT_READ
+             || (SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
+                 && errno == EINTR)));
+
   return ret;
 }