13 #define DEFAULT_CONNECTIONS 512
24 static char *ngx_event_init_conf(
ngx_cycle_t *cycle,
void *conf);
35 static void *ngx_event_core_create_conf(
ngx_cycle_t *cycle);
36 static char *ngx_event_core_init_conf(
ngx_cycle_t *cycle,
void *conf);
105 &ngx_events_module_ctx,
126 ngx_event_connections,
133 ngx_event_connections,
168 ngx_event_debug_connection,
179 ngx_event_core_create_conf,
180 ngx_event_core_init_conf,
182 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
189 ngx_event_core_commands,
192 ngx_event_module_init,
193 ngx_event_process_init,
208 if (ngx_timer_resolution) {
254 "timer delta: %M", delta);
430 ngx_event_init_conf(
ngx_cycle_t *cycle,
void *conf)
434 "no \"events\" section in configuration");
454 ecf = (*cf)[ngx_event_core_module.
ctx_index];
458 "using the \"%s\" event method", ecf->
name);
470 if (getrlimit(RLIMIT_NOFILE, &
rlmt) == -1) {
472 "getrlimit(RLIMIT_NOFILE) failed, ignored");
483 "%ui worker_connections exceed "
484 "open file resource limit: %i",
522 shm.
name.
len =
sizeof(
"nginx_shared_zone");
523 shm.
name.
data = (u_char *)
"nginx_shared_zone";
575 ngx_timer_signal_handler(
int signo)
623 if (ngx_posted_events_mutex == NULL) {
655 struct itimerval itv;
658 sa.sa_handler = ngx_timer_signal_handler;
659 sigemptyset(&sa.sa_mask);
661 if (sigaction(SIGALRM, &sa, NULL) == -1) {
663 "sigaction(SIGALRM) failed");
667 itv.it_interval.tv_sec = ngx_timer_resolution / 1000;
668 itv.it_interval.tv_usec = (ngx_timer_resolution % 1000) * 1000;
669 itv.it_value.tv_sec = ngx_timer_resolution / 1000;
670 itv.it_value.tv_usec = (ngx_timer_resolution % 1000 ) * 1000;
672 if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
674 "setitimer() failed");
681 if (getrlimit(RLIMIT_NOFILE, &
rlmt) == -1) {
683 "getrlimit(RLIMIT_NOFILE) failed");
691 if (cycle->
files == NULL) {
717 rev[
i].lock = &c[
i].lock;
718 rev[
i].own_lock = &c[
i].lock;
732 wev[
i].lock = &c[
i].lock;
733 wev[
i].own_lock = &c[
i].lock;
779 #if (NGX_HAVE_DEFERRED_ACCEPT)
784 if (ls[i].previous) {
806 ngx_iocp_conf_t *iocpcf;
808 rev->
handler = ngx_event_acceptex;
821 if (ngx_event_post_acceptex(&ls[i], iocpcf->post_acceptex)
871 #if (NGX_HAVE_LOWAT_EVENT)
884 sndlowat = (int) lowat;
886 if (setsockopt(c->
fd, SOL_SOCKET, SO_SNDLOWAT,
887 (
const void *) &sndlowat,
sizeof(
int))
891 "setsockopt(SO_SNDLOWAT) failed");
910 if (*(
void **) conf) {
911 return "is duplicate";
916 ngx_event_max_module = 0;
935 *(
void **) conf = ctx;
946 if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) {
964 for (i = 0; ngx_modules[
i]; i++) {
969 m = ngx_modules[
i]->ctx;
991 return "is duplicate";
996 "the \"connections\" directive is deprecated, "
997 "use the \"worker_connections\" directive instead");
1004 "invalid number \"%V\"", &value[1]);
1026 return "is duplicate";
1033 ngx_event_core_module);
1039 for (m = 0; ngx_modules[m]; m++) {
1044 module = ngx_modules[m]->ctx;
1047 ecf->
use = ngx_modules[m]->ctx_index;
1052 && old_ecf->
use != ecf->
use)
1055 "when the server runs without a master process "
1056 "the \"%V\" event type must be the same as "
1057 "in previous configuration - \"%s\" "
1058 "and it cannot be changed on the fly, "
1059 "to change it you need to stop server "
1060 "and start it again",
1061 &value[1], old_ecf->
name);
1072 "invalid event type \"%V\"", &value[1]);
1089 struct sockaddr_in *sin;
1090 #if (NGX_HAVE_INET6)
1091 struct sockaddr_in6 *sin6;
1096 #if (NGX_HAVE_UNIX_DOMAIN)
1098 if (
ngx_strcmp(value[1].data,
"unix:") == 0) {
1115 "low address bits of %V are meaningless",
1135 "%s in debug_connection \"%V\"",
1149 for (i = 0; i < u.
naddrs; i++) {
1152 switch (cidr[i].family) {
1154 #if (NGX_HAVE_INET6)
1157 cidr[i].
u.in6.addr = sin6->sin6_addr;
1158 ngx_memset(cidr[i].u.in6.mask.s6_addr, 0xff, 16);
1164 cidr[i].
u.
in.
addr = sin->sin_addr.s_addr;
1165 cidr[i].
u.
in.
mask = 0xffffffff;
1173 "\"debug_connection\" is ignored, you need to rebuild "
1174 "nginx using --with-debug option to enable it");
1201 if (ngx_array_init(&ecf->debug_connection, cycle->
pool, 4,
1214 ngx_event_core_init_conf(
ngx_cycle_t *cycle,
void *conf)
1218 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
1221 #if (NGX_HAVE_RTSIG)
1231 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
1233 fd = epoll_create(100);
1245 #if (NGX_HAVE_RTSIG)
1247 if (module == NULL) {
1257 #if (NGX_HAVE_DEVPOLL)
1263 #if (NGX_HAVE_KQUEUE)
1269 #if (NGX_HAVE_SELECT)
1271 if (module == NULL) {
1277 if (module == NULL) {
1278 for (i = 0; ngx_modules[
i]; i++) {
1284 event_module = ngx_modules[
i]->ctx;
1291 module = ngx_modules[
i];
1296 if (module == NULL) {
1306 event_module = module->
ctx;
1314 #if (NGX_HAVE_RTSIG)
1331 "the \"rtsig\" method requires \"accept_mutex\" to be on");