diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-05-24 01:33:06 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-08-27 02:16:53 -0400 |
commit | 4a246a875424ab53a8d39975cdb83bf35ffa35ce (patch) | |
tree | 6f81a0b0944d93bb03bbef3743092236a4d74c7a /src/mod_wolfssl.c | |
parent | 8b96169b68ad313b30dffe7368d29d83fce77cf9 (diff) | |
download | lighttpd-git-4a246a875424ab53a8d39975cdb83bf35ffa35ce.tar.gz |
[TLS] write_cq_ssl defer remove_finished_chunks
not expecting 0-length chunks, but handle within loops as cold path
mark some cold paths in read_cq_ssl and write_cq_ssl callback funcs
Diffstat (limited to 'src/mod_wolfssl.c')
-rw-r--r-- | src/mod_wolfssl.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/mod_wolfssl.c b/src/mod_wolfssl.c index 815b9330..40785491 100644 --- a/src/mod_wolfssl.c +++ b/src/mod_wolfssl.c @@ -2738,15 +2738,14 @@ mod_openssl_close_notify(handler_ctx *hctx); static int -connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes) +connection_write_cq_ssl (connection * const con, chunkqueue * const cq, off_t max_bytes) { - handler_ctx *hctx = con->plugin_ctx[plugin_data_singleton->id]; - SSL *ssl = hctx->ssl; + handler_ctx * const hctx = con->plugin_ctx[plugin_data_singleton->id]; + SSL * const ssl = hctx->ssl; log_error_st * const errh = hctx->errh; - if (0 != hctx->close_notify) return mod_openssl_close_notify(hctx); - - chunkqueue_remove_finished_chunks(cq); + if (__builtin_expect( (0 != hctx->close_notify), 0)) + return mod_openssl_close_notify(hctx); while (max_bytes > 0 && !chunkqueue_is_empty(cq)) { char *data = local_send_buffer; @@ -2756,6 +2755,10 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes) int wr; if (0 != chunkqueue_peek_data(cq, &data, &data_len, errh)) return -1; + if (__builtin_expect( (0 == data_len), 0)) { + chunkqueue_remove_finished_chunks(cq); + continue; + } /** * SSL_write man-page @@ -2769,7 +2772,7 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes) ERR_clear_error(); wr = SSL_write(ssl, data, data_len); - if (hctx->renegotiations > 1 + if (__builtin_expect( (hctx->renegotiations > 1), 0) && hctx->conf.ssl_disable_client_renegotiation) { log_error(errh, __FILE__, __LINE__, "SSL: renegotiation initiated by client, killing connection"); @@ -2839,16 +2842,17 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes) static int -connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes) +connection_read_cq_ssl (connection * const con, chunkqueue * const cq, off_t max_bytes) { - handler_ctx *hctx = con->plugin_ctx[plugin_data_singleton->id]; + handler_ctx * const hctx = con->plugin_ctx[plugin_data_singleton->id]; int len; char *mem = NULL; size_t mem_len = 0; UNUSED(max_bytes); - if (0 != hctx->close_notify) return mod_openssl_close_notify(hctx); + if (__builtin_expect( (0 != hctx->close_notify), 0)) + return mod_openssl_close_notify(hctx); ERR_clear_error(); do { |