Mercurial > hg > nginx
changeset 8730:90ae21799f67 quic
QUIC: do not copy input data.
Previously, when a new datagram arrived, data were copied from the UDP layer
to the QUIC layer via c->recv() interface. Now UDP buffer is accessed
directly.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 11 Mar 2021 15:25:11 +0300 |
parents | 0f8565e0fc76 |
children | d62a16fff3a4 |
files | src/event/quic/ngx_event_quic.c |
diffstat | 1 files changed, 7 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic.c Wed Mar 31 21:43:17 2021 +0300 +++ b/src/event/quic/ngx_event_quic.c Thu Mar 11 15:25:11 2021 +0300 @@ -1878,21 +1878,13 @@ static void ngx_quic_input_handler(ngx_event_t *rev) { - ssize_t n; ngx_int_t rc; - ngx_buf_t b; + ngx_buf_t *b; ngx_connection_t *c; ngx_quic_connection_t *qc; - static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, 0, "quic input handler"); - ngx_memzero(&b, sizeof(ngx_buf_t)); - b.start = buf; - b.end = buf + sizeof(buf); - b.pos = b.last = b.start; - b.memory = 1; - c = rev->data; qc = ngx_quic_get_connection(c); @@ -1911,21 +1903,13 @@ return; } - n = c->recv(c, b.start, b.end - b.start); - - if (n == NGX_AGAIN) { + if (!rev->ready) { if (qc->closing) { ngx_quic_close_connection(c, NGX_OK); } return; } - if (n == NGX_ERROR) { - c->read->eof = 1; - ngx_quic_close_connection(c, NGX_ERROR); - return; - } - if (qc->tp.disable_active_migration) { if (c->socklen != qc->socklen || ngx_memcmp(c->sockaddr, qc->sockaddr, c->socklen) != 0) @@ -1936,10 +1920,11 @@ } } - b.last += n; - qc->received += n; - - rc = ngx_quic_input(c, &b, NULL); + b = c->udp->buffer; + + qc->received += (b->last - b->pos); + + rc = ngx_quic_input(c, b, NULL); if (rc == NGX_ERROR) { ngx_quic_close_connection(c, NGX_ERROR);