err = (sslerr == SSL_ERROR_SYSCALL) ? ngx_errno : 0;
+ if (sslerr == SSL_ERROR_SYSCALL && ERR_peek_error() == 0 && err == 0) {
+
+ /*
+ * OpenSSL up to 3.0 returns SSL_ERROR_SYSCALL
+ * without an error queue and with errno set to 0
+ * if connection is closed cleanly
+ */
+
+ sslerr = SSL_ERROR_ZERO_RETURN;
+ }
+
c->ssl->no_wait_shutdown = 1;
c->ssl->no_send_shutdown = 1;
c->read->eof = 1;
- if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
+ if (sslerr == SSL_ERROR_ZERO_RETURN) {
ngx_connection_error(c, err,
"peer closed connection in SSL handshake");
err = (sslerr == SSL_ERROR_SYSCALL) ? ngx_errno : 0;
+ if (sslerr == SSL_ERROR_SYSCALL && ERR_peek_error() == 0 && err == 0) {
+
+ /*
+ * OpenSSL up to 3.0 returns SSL_ERROR_SYSCALL
+ * without an error queue and with errno set to 0
+ * if connection is closed cleanly
+ */
+
+ sslerr = SSL_ERROR_ZERO_RETURN;
+ }
+
c->ssl->no_wait_shutdown = 1;
c->ssl->no_send_shutdown = 1;
c->read->eof = 1;
- if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
+ if (sslerr == SSL_ERROR_ZERO_RETURN) {
ngx_connection_error(c, err,
"peer closed connection in SSL handshake");
return NGX_AGAIN;
}
+ if (sslerr == SSL_ERROR_SYSCALL && ERR_peek_error() == 0 && err == 0) {
+
+ /*
+ * OpenSSL up to 3.0 returns SSL_ERROR_SYSCALL
+ * without an error queue and with errno set to 0
+ * if connection is closed cleanly
+ */
+
+ sslerr = SSL_ERROR_ZERO_RETURN;
+ }
+
c->ssl->no_wait_shutdown = 1;
c->ssl->no_send_shutdown = 1;
- if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
+ if (sslerr == SSL_ERROR_ZERO_RETURN) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"peer shutdown SSL cleanly");
return NGX_DONE;
return NGX_AGAIN;
}
- if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
- goto done;
+ err = (sslerr == SSL_ERROR_SYSCALL) ? ngx_errno : 0;
+
+ if (sslerr == SSL_ERROR_SYSCALL && ERR_peek_error() == 0 && err == 0) {
+
+ /*
+ * OpenSSL up to 3.0 returns SSL_ERROR_SYSCALL
+ * without an error queue and with errno set to 0
+ * if connection is closed cleanly
+ */
+
+ sslerr = SSL_ERROR_ZERO_RETURN;
}
- err = (sslerr == SSL_ERROR_SYSCALL) ? ngx_errno : 0;
+ if (sslerr == SSL_ERROR_ZERO_RETURN) {
+ goto done;
+ }
ngx_ssl_connection_error(c, sslerr, err, "SSL_shutdown() failed");