[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Fri Mar 11 21:33:51 UTC 2016


The branch master has been updated
       via  c3caf7603574184a2cf95134e679a2ff69d6ef05 (commit)
       via  81161070f8ec75ba83964e98ad70c4c4d015c276 (commit)
      from  642befa16e42feadd4d8d843a6d563ae4d161171 (commit)


- Log -----------------------------------------------------------------
commit c3caf7603574184a2cf95134e679a2ff69d6ef05
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Mar 11 21:05:02 2016 +0000

    Remove some dead code from 1999
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

commit 81161070f8ec75ba83964e98ad70c4c4d015c276
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Mar 11 16:47:42 2016 +0000

    Don't clobber the last error
    
    On Windows we call WSAGetLastError() to find out the last error that
    happened on a socket operation. We use this to find out whether we can
    retry the operation or not. You are supposed to call this immediately
    however in a couple of places we logged an error first. This can end up
    making other Windows system calls to get the thread local error state.
    Sometimes that can clobber the error code, so if you call WSAGetLastError()
    later on you get a spurious response and the socket operation looks like
    a fatal error.
    
    Really we shouldn't be logging an error anyway if its a retryable issue.
    Otherwise we could end up with stale errors on the error queue.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/bio/b_sock2.c  | 12 ++++++++----
 crypto/bio/bss_fd.c   |  6 ------
 crypto/bio/bss_sock.c |  6 ------
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/crypto/bio/b_sock2.c b/crypto/bio/b_sock2.c
index bf613ac..9f092fc 100644
--- a/crypto/bio/b_sock2.c
+++ b/crypto/bio/b_sock2.c
@@ -149,8 +149,10 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
 
     if (connect(sock, BIO_ADDR_sockaddr(addr),
                 BIO_ADDR_sockaddr_size(addr)) == -1) {
-        SYSerr(SYS_F_CONNECT, get_last_socket_error());
-        BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
+        if (!BIO_sock_should_retry(-1)) {
+            SYSerr(SYS_F_CONNECT, get_last_socket_error());
+            BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
+        }
         return 0;
     }
     return 1;
@@ -285,8 +287,10 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
     accepted_sock = accept(accept_sock,
                            BIO_ADDR_sockaddr_noconst(addr), &len);
     if (accepted_sock == -1) {
-        SYSerr(SYS_F_ACCEPT, get_last_socket_error());
-        BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
+        if (!BIO_sock_should_retry(accepted_sock)) {
+            SYSerr(SYS_F_ACCEPT, get_last_socket_error());
+            BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
+        }
         return INVALID_SOCKET;
     }
 
diff --git a/crypto/bio/bss_fd.c b/crypto/bio/bss_fd.c
index d00c5ce..48921ee 100644
--- a/crypto/bio/bss_fd.c
+++ b/crypto/bio/bss_fd.c
@@ -267,12 +267,6 @@ int BIO_fd_should_retry(int i)
     if ((i == 0) || (i == -1)) {
         err = get_last_sys_error();
 
-# if defined(OPENSSL_SYS_WINDOWS) && 0/* more microsoft stupidity? perhaps
-                                       * not? Ben 4/1/99 */
-        if ((i == -1) && (err == 0))
-            return (1);
-# endif
-
         return (BIO_fd_non_fatal_error(err));
     }
     return (0);
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index b56cd18..428c514 100644
--- a/crypto/bio/bss_sock.c
+++ b/crypto/bio/bss_sock.c
@@ -214,12 +214,6 @@ int BIO_sock_should_retry(int i)
     if ((i == 0) || (i == -1)) {
         err = get_last_socket_error();
 
-# if defined(OPENSSL_SYS_WINDOWS) && 0/* more microsoft stupidity? perhaps
-                                       * not? Ben 4/1/99 */
-        if ((i == -1) && (err == 0))
-            return (1);
-# endif
-
         return (BIO_sock_non_fatal_error(err));
     }
     return (0);


More information about the openssl-commits mailing list