mirror of
https://github.com/nginx/nginx.git
synced 2024-12-22 15:13:28 -06:00
prepare to allow various number of connections in child processes
This commit is contained in:
parent
f2a1484347
commit
ce1e64f404
@ -143,15 +143,12 @@ ngx_module_t ngx_epoll_module = {
|
||||
static ngx_int_t
|
||||
ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
||||
{
|
||||
ngx_event_conf_t *ecf;
|
||||
ngx_epoll_conf_t *epcf;
|
||||
|
||||
ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
|
||||
|
||||
epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module);
|
||||
|
||||
if (ep == -1) {
|
||||
ep = epoll_create(ecf->connections / 2);
|
||||
ep = epoll_create(cycle->connection_n / 2);
|
||||
|
||||
if (ep == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
|
@ -436,10 +436,10 @@ ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
|
||||
#if !(NGX_WIN32)
|
||||
|
||||
if ((unsigned) ecf->connections > FD_SETSIZE) {
|
||||
if (cycle->connection_n > FD_SETSIZE) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
||||
"the maximum number of files "
|
||||
"supported by select() is " ngx_value(FD_SETSIZE));
|
||||
"supported by select() is %ud", FD_SETSIZE);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
|
@ -596,23 +596,24 @@ ngx_event_process_init(ngx_cycle_t *cycle)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
cycle->connection_n = ecf->connections;
|
||||
|
||||
for (m = 0; ngx_modules[m]; m++) {
|
||||
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ngx_modules[m]->ctx_index == ecf->use) {
|
||||
if (ngx_modules[m]->ctx_index != ecf->use) {
|
||||
continue;
|
||||
}
|
||||
|
||||
module = ngx_modules[m]->ctx;
|
||||
if (module->actions.init(cycle, ngx_timer_resolution) == NGX_ERROR)
|
||||
{
|
||||
|
||||
if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) {
|
||||
/* fatal */
|
||||
exit(2);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if !(NGX_WIN32)
|
||||
|
||||
@ -661,15 +662,15 @@ ngx_event_process_init(ngx_cycle_t *cycle)
|
||||
|
||||
#endif
|
||||
|
||||
cycle->connections = ngx_alloc(sizeof(ngx_connection_t) * ecf->connections,
|
||||
cycle->log);
|
||||
cycle->connections =
|
||||
ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log);
|
||||
if (cycle->connections == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
c = cycle->connections;
|
||||
|
||||
cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections,
|
||||
cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
|
||||
cycle->log);
|
||||
if (cycle->read_events == NULL) {
|
||||
return NGX_ERROR;
|
||||
@ -685,7 +686,7 @@ ngx_event_process_init(ngx_cycle_t *cycle)
|
||||
#endif
|
||||
}
|
||||
|
||||
cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections,
|
||||
cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
|
||||
cycle->log);
|
||||
if (cycle->write_events == NULL) {
|
||||
return NGX_ERROR;
|
||||
@ -719,7 +720,7 @@ ngx_event_process_init(ngx_cycle_t *cycle)
|
||||
} while (i);
|
||||
|
||||
cycle->free_connections = next;
|
||||
cycle->free_connection_n = ecf->connections;
|
||||
cycle->free_connection_n = cycle->connection_n;
|
||||
|
||||
/* for each listening socket */
|
||||
|
||||
@ -1137,11 +1138,10 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
ngx_uint_t rtsig;
|
||||
ngx_core_conf_t *ccf;
|
||||
#endif
|
||||
ngx_int_t i, connections;
|
||||
ngx_int_t i;
|
||||
ngx_module_t *module;
|
||||
ngx_event_module_t *event_module;
|
||||
|
||||
connections = NGX_CONF_UNSET_UINT;
|
||||
module = NULL;
|
||||
|
||||
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
||||
@ -1150,11 +1150,9 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
module = &ngx_epoll_module;
|
||||
|
||||
} else if (ngx_errno != NGX_ENOSYS) {
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
module = &ngx_epoll_module;
|
||||
}
|
||||
|
||||
@ -1163,7 +1161,6 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
#if (NGX_HAVE_RTSIG)
|
||||
|
||||
if (module == NULL) {
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
module = &ngx_rtsig_module;
|
||||
rtsig = 1;
|
||||
|
||||
@ -1175,14 +1172,12 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
|
||||
#if (NGX_HAVE_DEVPOLL)
|
||||
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
module = &ngx_devpoll_module;
|
||||
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_KQUEUE)
|
||||
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
module = &ngx_kqueue_module;
|
||||
|
||||
#endif
|
||||
@ -1190,12 +1185,6 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
#if (NGX_HAVE_SELECT)
|
||||
|
||||
if (module == NULL) {
|
||||
|
||||
#if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS)
|
||||
connections = DEFAULT_CONNECTIONS;
|
||||
#else
|
||||
connections = FD_SETSIZE;
|
||||
#endif
|
||||
module = &ngx_select_module;
|
||||
}
|
||||
|
||||
@ -1203,11 +1192,14 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
|
||||
if (module == NULL) {
|
||||
for (i = 0; ngx_modules[i]; i++) {
|
||||
if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
|
||||
|
||||
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
event_module = ngx_modules[i]->ctx;
|
||||
|
||||
if (ngx_strcmp(event_module->name->data, event_core_name.data)
|
||||
== 0)
|
||||
if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -1216,14 +1208,13 @@ ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (module == NULL) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found");
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_conf_init_uint_value(ecf->connections, connections);
|
||||
ngx_conf_init_uint_value(ecf->connections, DEFAULT_CONNECTIONS);
|
||||
cycle->connection_n = ecf->connections;
|
||||
|
||||
ngx_conf_init_uint_value(ecf->use, module->ctx_index);
|
||||
|
Loading…
Reference in New Issue
Block a user