# HG changeset patch # User Roman Arutyunyan # Date 1615465511 -10800 # Node ID 90ae21799f67c3d67c32033a10c1645653e7864b # Parent 0f8565e0fc76e2d5ca90e2929e40fd3fb3bdcb1b 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. diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c --- a/src/event/quic/ngx_event_quic.c +++ b/src/event/quic/ngx_event_quic.c @@ -1878,21 +1878,13 @@ ngx_quic_max_udp_payload(ngx_connection_ 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 @@ ngx_quic_input_handler(ngx_event_t *rev) 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 @@ ngx_quic_input_handler(ngx_event_t *rev) } } - 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);