Skip to content

Commit

Permalink
QATAPP-32751: Fix ngx_ssl_shutdown endless epoll operation
Browse files Browse the repository at this point in the history
Fixes #82 & #80, nginx jump into a loop of epoll event delete,
add and mod which lead cpu 100%

Signed-off-by: Hardik Patel <[email protected]>
  • Loading branch information
hardikpatel9 committed Oct 24, 2024
1 parent 0ab25c9 commit 013e6e9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/event/ngx_event_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3575,6 +3575,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
ngx_int_t rc;
ngx_err_t err;
ngx_uint_t tries;
static ngx_uint_t retries_err = 2;
rc = NGX_OK;

if(!c->ssl) {
Expand Down Expand Up @@ -3737,8 +3738,10 @@ ngx_ssl_shutdown(ngx_connection_t *c)
}
}

if(ngx_del_conn && c->read->active) {
ngx_del_conn(c, NGX_DISABLE_EVENT);
if(retries_err) {
if(ngx_del_conn && c->read->active) {
ngx_del_conn(c, NGX_DISABLE_EVENT);
}
}
}

Expand All @@ -3749,9 +3752,14 @@ ngx_ssl_shutdown(ngx_connection_t *c)
goto failed;
}

//Work around: Read write event on shutdown;
c->write->ready = 0;
c->write->active = 0;
if ((n == -1) && (c->asynch) && (retries_err > 0 )) {
retries_err--;
}
else if(( n != -1) && (retries_err > 0 ))
{
c->write->ready = 0;
c->write->active = 0;
}

if (sslerr == SSL_ERROR_WANT_READ) {
c->read->ready = 0;
Expand Down

0 comments on commit 013e6e9

Please sign in to comment.