summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-03-11 15:25:11 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-03-11 15:25:11 +0300
commit496a43485417afe7c9b5191b683f60ed7bcd4101 (patch)
treed4591e1496f3dbcbe71c6b707ea381d698121213 /src
parent18f9330cd6ce76469d4ffa81040af8d634280fd9 (diff)
downloadnginx-496a43485417afe7c9b5191b683f60ed7bcd4101.tar.gz
nginx-496a43485417afe7c9b5191b683f60ed7bcd4101.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/event/quic/ngx_event_quic.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
index f38b15910..22317db25 100644
--- 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_t *c)
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;
+ b = c->udp->buffer;
+
+ qc->received += (b->last - b->pos);
- rc = ngx_quic_input(c, &b, NULL);
+ rc = ngx_quic_input(c, b, NULL);
if (rc == NGX_ERROR) {
ngx_quic_close_connection(c, NGX_ERROR);