Mercurial > hg > nginx
comparison src/core/ngx_connection.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 | 5c2ac36fcf56 |
children | 9c038f5e0464 a5a1b3fad834 |
comparison
equal
deleted
inserted
replaced
7314:3dfc1584ad75 | 7315:e7b2b907c0f8 |
---|---|
94 return ls; | 94 return ls; |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 ngx_int_t | 98 ngx_int_t |
99 ngx_clone_listening(ngx_conf_t *cf, ngx_listening_t *ls) | 99 ngx_clone_listening(ngx_cycle_t *cycle, ngx_listening_t *ls) |
100 { | 100 { |
101 #if (NGX_HAVE_REUSEPORT) | 101 #if (NGX_HAVE_REUSEPORT) |
102 | 102 |
103 ngx_int_t n; | 103 ngx_int_t n; |
104 ngx_core_conf_t *ccf; | 104 ngx_core_conf_t *ccf; |
105 ngx_listening_t ols; | 105 ngx_listening_t ols; |
106 | 106 |
107 if (!ls->reuseport) { | 107 if (!ls->reuseport || ls->worker != 0) { |
108 return NGX_OK; | 108 return NGX_OK; |
109 } | 109 } |
110 | 110 |
111 ols = *ls; | 111 ols = *ls; |
112 | 112 |
113 ccf = (ngx_core_conf_t *) ngx_get_conf(cf->cycle->conf_ctx, | 113 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
114 ngx_core_module); | |
115 | 114 |
116 for (n = 1; n < ccf->worker_processes; n++) { | 115 for (n = 1; n < ccf->worker_processes; n++) { |
117 | 116 |
118 /* create a socket for each worker process */ | 117 /* create a socket for each worker process */ |
119 | 118 |
120 ls = ngx_array_push(&cf->cycle->listening); | 119 ls = ngx_array_push(&cycle->listening); |
121 if (ls == NULL) { | 120 if (ls == NULL) { |
122 return NGX_ERROR; | 121 return NGX_ERROR; |
123 } | 122 } |
124 | 123 |
125 *ls = ols; | 124 *ls = ols; |