Mercurial > hg > nginx-quic
annotate src/event/ngx_event_udp.h @ 8759:56dec0d4e5b1 quic
QUIC: avoid excessive buffer allocations in stream output.
Previously, when a few bytes were send to a QUIC stream by the application, a
4K buffer was allocated for these bytes. Then a STREAM frame was created and
that entire buffer was used as data for that frame. The frame with the buffer
were in use up until the frame was acked by client. Meanwhile, when more
bytes were send to the stream, more buffers were allocated and assigned as
data to newer STREAM frames. In this scenario most buffer memory is unused.
Now the unused part of the stream output buffer is available for further
stream output while earlier parts of the buffer are waiting to be acked.
This is achieved by splitting the output buffer.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 24 Dec 2021 18:13:51 +0300 |
parents | e7a2d3914877 |
children | ce6d9cf0f567 |
rev | line source |
---|---|
8510
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_EVENT_UDP_H_INCLUDED_ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_EVENT_UDP_H_INCLUDED_ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 #if !(NGX_WIN32) |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 |
8511
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
17 #if ((NGX_HAVE_MSGHDR_MSG_CONTROL) \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
18 && (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
19 || NGX_HAVE_IP_PKTINFO \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
20 || (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO))) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
21 #define NGX_HAVE_ADDRINFO_CMSG 1 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
22 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
23 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
24 |
8510
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 typedef struct { |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 ngx_buf_t *buffer; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 struct sockaddr *sockaddr; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 socklen_t socklen; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 } ngx_udp_dgram_t; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 struct ngx_udp_connection_s { |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 ngx_rbtree_node_t node; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 ngx_connection_t *connection; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 ngx_str_t key; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 ngx_udp_dgram_t *dgram; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 }; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 |
8511
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
40 #if (NGX_HAVE_ADDRINFO_CMSG) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
41 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
42 typedef union { |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
43 #if (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
44 struct in_addr addr; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
45 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
46 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
47 #if (NGX_HAVE_IP_PKTINFO) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
48 struct in_pktinfo pkt; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
49 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
50 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
51 #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
52 struct in6_pktinfo pkt6; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
53 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
54 } ngx_addrinfo_t; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
55 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
56 size_t ngx_set_srcaddr_cmsg(struct cmsghdr *cmsg, |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
57 struct sockaddr *local_sockaddr); |
8513
e7a2d3914877
Core: added separate function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8511
diff
changeset
|
58 ngx_int_t ngx_get_srcaddr_cmsg(struct cmsghdr *cmsg, |
e7a2d3914877
Core: added separate function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8511
diff
changeset
|
59 struct sockaddr *local_sockaddr); |
8511
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
60 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
61 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
62 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
63 |
8510
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 void ngx_event_recvmsg(ngx_event_t *ev); |
8511
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8510
diff
changeset
|
65 ssize_t ngx_sendmsg(ngx_connection_t *c, struct msghdr *msg, int flags); |
8510
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 void ngx_udp_rbtree_insert_value(ngx_rbtree_node_t *temp, |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
68 void ngx_insert_udp_connection(ngx_connection_t *c, ngx_udp_connection_t *udp, |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 ngx_str_t *key); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 #endif |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 void ngx_delete_udp_connection(void *data); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 #endif /* _NGX_EVENT_UDP_H_INCLUDED_ */ |