Mercurial > hg > nginx-quic
comparison src/core/ngx_connection.h @ 6153:4f6efabcb09b
The "reuseport" option of the "listen" directive.
When configured, an individual listen socket on a given address is
created for each worker process. This allows to reduce in-kernel lock
contention on configurations with high accept rates, resulting in better
performance. As of now it works on Linux and DragonFly BSD.
Note that on Linux incoming connection requests are currently tied up
to a specific listen socket, and if some sockets are closed, connection
requests will be reset, see https://lwn.net/Articles/542629/. With
nginx, this may happen if the number of worker processes is reduced.
There is no such problem on DragonFly BSD.
Based on previous work by Sepherosa Ziehau and Yingqi Lu.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 20 May 2015 15:51:56 +0300 |
parents | 187aa751ad62 |
children | 5e6142609e48 |
comparison
equal
deleted
inserted
replaced
6152:3c344ea7d88b | 6153:4f6efabcb09b |
---|---|
49 ngx_msec_t post_accept_timeout; | 49 ngx_msec_t post_accept_timeout; |
50 | 50 |
51 ngx_listening_t *previous; | 51 ngx_listening_t *previous; |
52 ngx_connection_t *connection; | 52 ngx_connection_t *connection; |
53 | 53 |
54 ngx_uint_t worker; | |
55 | |
54 unsigned open:1; | 56 unsigned open:1; |
55 unsigned remain:1; | 57 unsigned remain:1; |
56 unsigned ignore:1; | 58 unsigned ignore:1; |
57 | 59 |
58 unsigned bound:1; /* already bound */ | 60 unsigned bound:1; /* already bound */ |
63 unsigned shared:1; /* shared between threads or processes */ | 65 unsigned shared:1; /* shared between threads or processes */ |
64 unsigned addr_ntop:1; | 66 unsigned addr_ntop:1; |
65 | 67 |
66 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) | 68 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) |
67 unsigned ipv6only:1; | 69 unsigned ipv6only:1; |
70 #endif | |
71 #if (NGX_HAVE_REUSEPORT) | |
72 unsigned reuseport:1; | |
73 unsigned add_reuseport:1; | |
68 #endif | 74 #endif |
69 unsigned keepalive:2; | 75 unsigned keepalive:2; |
70 | 76 |
71 #if (NGX_HAVE_DEFERRED_ACCEPT) | 77 #if (NGX_HAVE_DEFERRED_ACCEPT) |
72 unsigned deferred_accept:1; | 78 unsigned deferred_accept:1; |
201 } | 207 } |
202 | 208 |
203 | 209 |
204 ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr, | 210 ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr, |
205 socklen_t socklen); | 211 socklen_t socklen); |
212 ngx_int_t ngx_clone_listening(ngx_conf_t *cf, ngx_listening_t *ls); | |
206 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle); | 213 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle); |
207 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle); | 214 ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle); |
208 void ngx_configure_listening_sockets(ngx_cycle_t *cycle); | 215 void ngx_configure_listening_sockets(ngx_cycle_t *cycle); |
209 void ngx_close_listening_sockets(ngx_cycle_t *cycle); | 216 void ngx_close_listening_sockets(ngx_cycle_t *cycle); |
210 void ngx_close_connection(ngx_connection_t *c); | 217 void ngx_close_connection(ngx_connection_t *c); |