comparison 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
comparison
equal deleted inserted replaced
7314:3dfc1584ad75 7315:e7b2b907c0f8
408 408
409 409
410 static char * 410 static char *
411 ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) 411 ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
412 { 412 {
413 #if (NGX_HAVE_REUSEPORT)
414 ngx_uint_t i;
415 ngx_listening_t *ls;
416 #endif
417
413 if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) { 418 if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) {
414 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, 419 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
415 "no \"events\" section in configuration"); 420 "no \"events\" section in configuration");
416 return NGX_CONF_ERROR; 421 return NGX_CONF_ERROR;
417 } 422 }
423
424 #if (NGX_HAVE_REUSEPORT)
425
426 ls = cycle->listening.elts;
427 for (i = 0; i < cycle->listening.nelts; i++) {
428
429 if (!ls[i].reuseport || ls[i].worker != 0) {
430 continue;
431 }
432
433 if (ngx_clone_listening(cycle, &ls[i]) != NGX_OK) {
434 return NGX_CONF_ERROR;
435 }
436
437 /* cloning may change cycle->listening.elts */
438
439 ls = cycle->listening.elts;
440 }
441
442 #endif
418 443
419 return NGX_CONF_OK; 444 return NGX_CONF_OK;
420 } 445 }
421 446
422 447