mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 06:03:31 -06:00
SSL_shutdown() never returns -1, on error it returns 0.
This fixes incidental "bad write retry" errors.
This commit is contained in:
parent
afc57e0e5c
commit
94b3ea319b
@ -980,7 +980,6 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
|||||||
{
|
{
|
||||||
int n, sslerr, mode;
|
int n, sslerr, mode;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_uint_t again;
|
|
||||||
|
|
||||||
if (c->timedout) {
|
if (c->timedout) {
|
||||||
mode = SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN;
|
mode = SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN;
|
||||||
@ -999,40 +998,32 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
|||||||
|
|
||||||
SSL_set_shutdown(c->ssl->connection, mode);
|
SSL_set_shutdown(c->ssl->connection, mode);
|
||||||
|
|
||||||
again = 0;
|
|
||||||
sslerr = 0;
|
|
||||||
|
|
||||||
for ( ;; ) {
|
|
||||||
n = SSL_shutdown(c->ssl->connection);
|
n = SSL_shutdown(c->ssl->connection);
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_shutdown: %d", n);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_shutdown: %d", n);
|
||||||
|
|
||||||
if (n == 1 || (n == 0 && c->timedout)) {
|
sslerr = 0;
|
||||||
SSL_free(c->ssl->connection);
|
|
||||||
c->ssl = NULL;
|
|
||||||
|
|
||||||
return NGX_OK;
|
/* SSL_shutdown() never return -1, on error it return 0 */
|
||||||
}
|
|
||||||
|
|
||||||
if (n == 0) {
|
if (n != 1) {
|
||||||
again = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!again) {
|
|
||||||
sslerr = SSL_get_error(c->ssl->connection, n);
|
sslerr = SSL_get_error(c->ssl->connection, n);
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
"SSL_get_error: %d", sslerr);
|
"SSL_get_error: %d", sslerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (again
|
if (n == 1
|
||||||
|| sslerr == SSL_ERROR_WANT_READ
|
|| sslerr == SSL_ERROR_ZERO_RETURN
|
||||||
|| sslerr == SSL_ERROR_WANT_WRITE)
|
|| (sslerr == 0 && c->timedout))
|
||||||
{
|
{
|
||||||
|
SSL_free(c->ssl->connection);
|
||||||
|
c->ssl = NULL;
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sslerr == SSL_ERROR_WANT_READ || sslerr == SSL_ERROR_WANT_WRITE) {
|
||||||
c->read->handler = ngx_ssl_shutdown_handler;
|
c->read->handler = ngx_ssl_shutdown_handler;
|
||||||
c->write->handler = ngx_ssl_shutdown_handler;
|
c->write->handler = ngx_ssl_shutdown_handler;
|
||||||
|
|
||||||
@ -1044,7 +1035,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (again || sslerr == SSL_ERROR_WANT_READ) {
|
if (sslerr == SSL_ERROR_WANT_READ) {
|
||||||
ngx_add_timer(c->read, 30000);
|
ngx_add_timer(c->read, 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user