Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic.c @ 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 | fc64ab301bad |
children | c61fcdc1b8e3 |
comparison
equal
deleted
inserted
replaced
8729:0f8565e0fc76 | 8730:90ae21799f67 |
---|---|
1876 | 1876 |
1877 | 1877 |
1878 static void | 1878 static void |
1879 ngx_quic_input_handler(ngx_event_t *rev) | 1879 ngx_quic_input_handler(ngx_event_t *rev) |
1880 { | 1880 { |
1881 ssize_t n; | |
1882 ngx_int_t rc; | 1881 ngx_int_t rc; |
1883 ngx_buf_t b; | 1882 ngx_buf_t *b; |
1884 ngx_connection_t *c; | 1883 ngx_connection_t *c; |
1885 ngx_quic_connection_t *qc; | 1884 ngx_quic_connection_t *qc; |
1886 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; | |
1887 | 1885 |
1888 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, 0, "quic input handler"); | 1886 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, 0, "quic input handler"); |
1889 | |
1890 ngx_memzero(&b, sizeof(ngx_buf_t)); | |
1891 b.start = buf; | |
1892 b.end = buf + sizeof(buf); | |
1893 b.pos = b.last = b.start; | |
1894 b.memory = 1; | |
1895 | 1887 |
1896 c = rev->data; | 1888 c = rev->data; |
1897 qc = ngx_quic_get_connection(c); | 1889 qc = ngx_quic_get_connection(c); |
1898 | 1890 |
1899 c->log->action = "handling quic input"; | 1891 c->log->action = "handling quic input"; |
1909 qc->error_reason = "graceful shutdown"; | 1901 qc->error_reason = "graceful shutdown"; |
1910 ngx_quic_close_connection(c, NGX_OK); | 1902 ngx_quic_close_connection(c, NGX_OK); |
1911 return; | 1903 return; |
1912 } | 1904 } |
1913 | 1905 |
1914 n = c->recv(c, b.start, b.end - b.start); | 1906 if (!rev->ready) { |
1915 | |
1916 if (n == NGX_AGAIN) { | |
1917 if (qc->closing) { | 1907 if (qc->closing) { |
1918 ngx_quic_close_connection(c, NGX_OK); | 1908 ngx_quic_close_connection(c, NGX_OK); |
1919 } | 1909 } |
1920 return; | |
1921 } | |
1922 | |
1923 if (n == NGX_ERROR) { | |
1924 c->read->eof = 1; | |
1925 ngx_quic_close_connection(c, NGX_ERROR); | |
1926 return; | 1910 return; |
1927 } | 1911 } |
1928 | 1912 |
1929 if (qc->tp.disable_active_migration) { | 1913 if (qc->tp.disable_active_migration) { |
1930 if (c->socklen != qc->socklen | 1914 if (c->socklen != qc->socklen |
1934 "quic dropping packet from new address"); | 1918 "quic dropping packet from new address"); |
1935 return; | 1919 return; |
1936 } | 1920 } |
1937 } | 1921 } |
1938 | 1922 |
1939 b.last += n; | 1923 b = c->udp->buffer; |
1940 qc->received += n; | 1924 |
1941 | 1925 qc->received += (b->last - b->pos); |
1942 rc = ngx_quic_input(c, &b, NULL); | 1926 |
1927 rc = ngx_quic_input(c, b, NULL); | |
1943 | 1928 |
1944 if (rc == NGX_ERROR) { | 1929 if (rc == NGX_ERROR) { |
1945 ngx_quic_close_connection(c, NGX_ERROR); | 1930 ngx_quic_close_connection(c, NGX_ERROR); |
1946 return; | 1931 return; |
1947 } | 1932 } |