diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2015-05-20 15:51:56 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2015-05-20 15:51:56 +0300 |
commit | f7f1607bf2b8b7c45834b66cb45f6445bee65587 (patch) | |
tree | 8a458d848d86e6b0e7f9108fd1b792d709091965 /src/core/ngx_cycle.c | |
parent | d5c34785bc55164afb7cfe7de1badcebdb05fb8d (diff) |
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.
Diffstat (limited to 'src/core/ngx_cycle.c')
-rw-r--r-- | src/core/ngx_cycle.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 4852e3bbe..b358f3dbe 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -493,6 +493,10 @@ ngx_init_cycle(ngx_cycle_t *old_cycle) continue; } + if (ls[i].remain) { + continue; + } + if (ngx_cmp_sockaddr(nls[n].sockaddr, nls[n].socklen, ls[i].sockaddr, ls[i].socklen, 1) == NGX_OK) @@ -540,6 +544,13 @@ ngx_init_cycle(ngx_cycle_t *old_cycle) nls[n].add_deferred = 1; } #endif + +#if (NGX_HAVE_REUSEPORT) + if (nls[n].reuseport && !ls[i].reuseport) { + nls[n].add_reuseport = 1; + } +#endif + break; } } |