]> sjero.net Git - wget/blobdiff - src/openssl.c
Bump version number in NEWS.
[wget] / src / openssl.c
index 78fb5d85c6761ecc08b30195223421165050cf81..2e2366903f7c8a906a55f69e48c15d8ea0eb4cd9 100644 (file)
@@ -161,7 +161,7 @@ key_type_to_ssl_type (enum keyfile_type type)
 bool
 ssl_init ()
 {
-  SSL_METHOD *meth;
+  SSL_METHOD const *meth;
 
   if (ssl_ctx)
     /* The SSL has already been initialized. */
@@ -263,9 +263,8 @@ 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_WANT_READ
-             || (SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
-                 && errno == EINTR)));
+         && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
+         && errno == EINTR);
 
   return ret;
 }
@@ -289,10 +288,10 @@ openssl_poll (int fd, double timeout, int wait_for, void *arg)
 {
   struct openssl_transport_context *ctx = arg;
   SSL *conn = ctx->conn;
-  if (timeout == 0)
-    return 1;
   if (SSL_pending (conn))
     return 1;
+  if (timeout == 0)
+    return 1;
   return select_fd (fd, timeout, wait_for);
 }
 
@@ -302,6 +301,8 @@ openssl_peek (int fd, char *buf, int bufsize, void *arg)
   int ret;
   struct openssl_transport_context *ctx = arg;
   SSL *conn = ctx->conn;
+  if (! openssl_poll (fd, 0.0, WAIT_FOR_READ, arg))
+    return 0;
   do
     ret = SSL_peek (conn, buf, bufsize);
   while (ret == -1