Klaus Demo nginx / 05029e7
SSL: restore handlers after blocking. It is possible that after SSL_read() will return SSL_ERROR_WANT_WRITE, further calls will return SSL_ERROR_WANT_READ without reading any application data. We have to call ngx_handle_write_event() and switch back to normal write handling much like we do if there are some application data, or the write there will be reported again and again. Similarly, we have to switch back to normal read handling if there is saved read handler and SSL_write() returns SSL_ERROR_WANT_WRITE. Maxim Dounin 3 years ago
1 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
16741674 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
16751675
16761676 if (sslerr == SSL_ERROR_WANT_READ) {
1677
1678 if (c->ssl->saved_write_handler) {
1679
1680 c->write->handler = c->ssl->saved_write_handler;
1681 c->ssl->saved_write_handler = NULL;
1682 c->write->ready = 1;
1683
1684 if (ngx_handle_write_event(c->write, 0) != NGX_OK) {
1685 return NGX_ERROR;
1686 }
1687
1688 ngx_post_event(c->write, &ngx_posted_events);
1689 }
1690
16771691 c->read->ready = 0;
16781692 return NGX_AGAIN;
16791693 }
19331947 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
19341948
19351949 if (sslerr == SSL_ERROR_WANT_WRITE) {
1950
1951 if (c->ssl->saved_read_handler) {
1952
1953 c->read->handler = c->ssl->saved_read_handler;
1954 c->ssl->saved_read_handler = NULL;
1955 c->read->ready = 1;
1956
1957 if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
1958 return NGX_ERROR;
1959 }
1960
1961 ngx_post_event(c->read, &ngx_posted_events);
1962 }
1963
19361964 c->write->ready = 0;
19371965 return NGX_AGAIN;
19381966 }