From 68d4325de08053f4cb0db590dc72ef9494c33bd6 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 8 Jul 2021 21:52:47 +0300 Subject: HTTP/3: bulk parse functions. Previously HTTP/3 streams were parsed by one character. Now all parse functions receive buffers. This should optimize parsing time and CPU load. --- src/http/v3/ngx_http_v3_request.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/http/v3/ngx_http_v3_request.c') diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c index 0bd585317..fb9ea8ff1 100644 --- a/src/http/v3/ngx_http_v3_request.c +++ b/src/http/v3/ngx_http_v3_request.c @@ -207,6 +207,7 @@ ngx_http_v3_cleanup_request(void *data) static void ngx_http_v3_process_request(ngx_event_t *rev) { + u_char *p; ssize_t n; ngx_buf_t *b; ngx_int_t rc; @@ -273,7 +274,9 @@ ngx_http_v3_process_request(ngx_event_t *rev) b->last = b->start + n; } - rc = ngx_http_v3_parse_headers(c, st, *b->pos); + p = b->pos; + + rc = ngx_http_v3_parse_headers(c, st, b); if (rc > 0) { ngx_http_v3_finalize_connection(c, rc, @@ -302,8 +305,7 @@ ngx_http_v3_process_request(ngx_event_t *rev) break; } - b->pos++; - r->request_length++; + r->request_length += b->pos - p; if (rc == NGX_AGAIN) { continue; @@ -1024,6 +1026,7 @@ ngx_http_v3_request_body_filter(ngx_http_request_t *r, ngx_chain_t *in) { off_t max; size_t size; + u_char *p; ngx_int_t rc; ngx_buf_t *b; ngx_uint_t last; @@ -1078,9 +1081,11 @@ ngx_http_v3_request_body_filter(ngx_http_request_t *r, ngx_chain_t *in) while (cl->buf->pos < cl->buf->last) { if (st->length == 0) { - r->request_length++; + p = cl->buf->pos; + + rc = ngx_http_v3_parse_data(r->connection, st, cl->buf); - rc = ngx_http_v3_parse_data(r->connection, st, *cl->buf->pos++); + r->request_length += cl->buf->pos - p; if (rc == NGX_AGAIN) { continue; -- cgit v1.2.3