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/stream/ngx_stream_core_module.c | |
parent | d5c34785bc55164afb7cfe7de1badcebdb05fb8d (diff) | |
download | nginx-f7f1607bf2b8b7c45834b66cb45f6445bee65587.tar.gz nginx-f7f1607bf2b8b7c45834b66cb45f6445bee65587.zip |
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/stream/ngx_stream_core_module.c')
-rw-r--r-- | src/stream/ngx_stream_core_module.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c index c0df412a5..c8d8e66bc 100644 --- a/src/stream/ngx_stream_core_module.c +++ b/src/stream/ngx_stream_core_module.c @@ -384,6 +384,18 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) #endif } + if (ngx_strcmp(value[i].data, "reuseport") == 0) { +#if (NGX_HAVE_REUSEPORT) + ls->reuseport = 1; + ls->bind = 1; +#else + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "reuseport is not supported " + "on this platform, ignored"); +#endif + continue; + } + if (ngx_strcmp(value[i].data, "ssl") == 0) { #if (NGX_STREAM_SSL) ls->ssl = 1; |