aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-07-08 21:52:47 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-07-08 21:52:47 +0300
commit68d4325de08053f4cb0db590dc72ef9494c33bd6 (patch)
treec39f285fe4909eee1176353e93ffa8f044a4b92d /src/http/v3/ngx_http_v3_request.c
parent3749805864fb2f7bb0eae7b82cfda383db970d8b (diff)
downloadnginx-68d4325de08053f4cb0db590dc72ef9494c33bd6.tar.gz
nginx-68d4325de08053f4cb0db590dc72ef9494c33bd6.zip
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.
Diffstat (limited to 'src/http/v3/ngx_http_v3_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c15
1 files changed, 10 insertions, 5 deletions
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;