Mercurial > hg > nginx
diff src/event/ngx_event.c @ 7315:e7b2b907c0f8
Events: moved sockets cloning to ngx_event_init_conf().
Previously, listenings sockets were not cloned if the worker_processes
directive was specified after "listen ... reuseport".
This also simplifies upcoming configuration check on the number
of worker connections, as it needs to know the number of listening
sockets before cloning.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 12 Jul 2018 19:50:02 +0300 |
parents | a8d7c9139831 |
children | 8f152ca81f5f |
line wrap: on
line diff
--- a/src/event/ngx_event.c Wed Jul 11 17:56:51 2018 +0300 +++ b/src/event/ngx_event.c Thu Jul 12 19:50:02 2018 +0300 @@ -410,12 +410,37 @@ static char * ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) { +#if (NGX_HAVE_REUSEPORT) + ngx_uint_t i; + ngx_listening_t *ls; +#endif + if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) { ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no \"events\" section in configuration"); return NGX_CONF_ERROR; } +#if (NGX_HAVE_REUSEPORT) + + ls = cycle->listening.elts; + for (i = 0; i < cycle->listening.nelts; i++) { + + if (!ls[i].reuseport || ls[i].worker != 0) { + continue; + } + + if (ngx_clone_listening(cycle, &ls[i]) != NGX_OK) { + return NGX_CONF_ERROR; + } + + /* cloning may change cycle->listening.elts */ + + ls = cycle->listening.elts; + } + +#endif + return NGX_CONF_OK; }