From fabab386ed0e2cb439bd1d990ab75c8e6386e4f5 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Fri, 1 Feb 2013 14:37:43 +0000 Subject: [PATCH] SSL: fixed ngx_ssl_handshake() with level-triggered event methods. Missing calls to ngx_handle_write_event() and ngx_handle_read_event() resulted in a CPU hog during SSL handshake if an level-triggered event method (e.g. select) was used. --- src/event/ngx_event_openssl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c index 1a1498cae..b8f1cae91 100644 --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -808,6 +808,10 @@ ngx_ssl_handshake(ngx_connection_t *c) return NGX_ERROR; } + if (ngx_handle_write_event(c->write, 0) != NGX_OK) { + return NGX_ERROR; + } + return NGX_AGAIN; } @@ -816,6 +820,10 @@ ngx_ssl_handshake(ngx_connection_t *c) c->read->handler = ngx_ssl_handshake_handler; c->write->handler = ngx_ssl_handshake_handler; + if (ngx_handle_read_event(c->read, 0) != NGX_OK) { + return NGX_ERROR; + } + if (ngx_handle_write_event(c->write, 0) != NGX_OK) { return NGX_ERROR; }