提交 81161070 编写于 作者: M Matt Caswell

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: NRichard Levitte <levitte@openssl.org>
上级 642befa1
...@@ -149,8 +149,10 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options) ...@@ -149,8 +149,10 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
if (connect(sock, BIO_ADDR_sockaddr(addr), if (connect(sock, BIO_ADDR_sockaddr(addr),
BIO_ADDR_sockaddr_size(addr)) == -1) { BIO_ADDR_sockaddr_size(addr)) == -1) {
SYSerr(SYS_F_CONNECT, get_last_socket_error()); if (!BIO_sock_should_retry(-1)) {
BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR); SYSerr(SYS_F_CONNECT, get_last_socket_error());
BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
}
return 0; return 0;
} }
return 1; return 1;
...@@ -285,8 +287,10 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options) ...@@ -285,8 +287,10 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
accepted_sock = accept(accept_sock, accepted_sock = accept(accept_sock,
BIO_ADDR_sockaddr_noconst(addr), &len); BIO_ADDR_sockaddr_noconst(addr), &len);
if (accepted_sock == -1) { if (accepted_sock == -1) {
SYSerr(SYS_F_ACCEPT, get_last_socket_error()); if (!BIO_sock_should_retry(accepted_sock)) {
BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR); SYSerr(SYS_F_ACCEPT, get_last_socket_error());
BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
}
return INVALID_SOCKET; return INVALID_SOCKET;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册