Mercurial > hg > nginx-vendor-0-7
comparison src/event/ngx_event.c @ 384:12defd37f578 NGINX_0_7_4
nginx 0.7.4
*) Feature: variables support in the "access_log" directive.
*) Feature: the "open_log_file_cache" directive.
*) Feature: the -g switch.
*) Feature: the "Expect" request header line support.
*) Bugfix: large SSI inclusions might be truncated.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 30 Jun 2008 00:00:00 +0400 |
parents | 820f6378fc00 |
children | 6ebbca3d5ed7 |
comparison
equal
deleted
inserted
replaced
383:6ee3ada01457 | 384:12defd37f578 |
---|---|
594 | 594 |
595 if (ngx_event_timer_init(cycle->log) == NGX_ERROR) { | 595 if (ngx_event_timer_init(cycle->log) == NGX_ERROR) { |
596 return NGX_ERROR; | 596 return NGX_ERROR; |
597 } | 597 } |
598 | 598 |
599 cycle->connection_n = ecf->connections; | |
600 | |
601 for (m = 0; ngx_modules[m]; m++) { | 599 for (m = 0; ngx_modules[m]; m++) { |
602 if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | 600 if (ngx_modules[m]->type != NGX_EVENT_MODULE) { |
603 continue; | 601 continue; |
604 } | 602 } |
605 | 603 |
606 if (ngx_modules[m]->ctx_index == ecf->use) { | 604 if (ngx_modules[m]->ctx_index != ecf->use) { |
607 module = ngx_modules[m]->ctx; | 605 continue; |
608 if (module->actions.init(cycle, ngx_timer_resolution) == NGX_ERROR) | 606 } |
609 { | 607 |
610 /* fatal */ | 608 module = ngx_modules[m]->ctx; |
611 exit(2); | 609 |
612 } | 610 if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) { |
613 break; | 611 /* fatal */ |
614 } | 612 exit(2); |
613 } | |
614 | |
615 break; | |
615 } | 616 } |
616 | 617 |
617 #if !(NGX_WIN32) | 618 #if !(NGX_WIN32) |
618 | 619 |
619 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { | 620 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { |
659 } | 660 } |
660 } | 661 } |
661 | 662 |
662 #endif | 663 #endif |
663 | 664 |
664 cycle->connections = ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, | 665 cycle->connections = |
665 cycle->log); | 666 ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log); |
666 if (cycle->connections == NULL) { | 667 if (cycle->connections == NULL) { |
667 return NGX_ERROR; | 668 return NGX_ERROR; |
668 } | 669 } |
669 | 670 |
670 c = cycle->connections; | 671 c = cycle->connections; |
671 | 672 |
672 cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, | 673 cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, |
673 cycle->log); | 674 cycle->log); |
674 if (cycle->read_events == NULL) { | 675 if (cycle->read_events == NULL) { |
675 return NGX_ERROR; | 676 return NGX_ERROR; |
676 } | 677 } |
677 | 678 |
683 rev[i].lock = &c[i].lock; | 684 rev[i].lock = &c[i].lock; |
684 rev[i].own_lock = &c[i].lock; | 685 rev[i].own_lock = &c[i].lock; |
685 #endif | 686 #endif |
686 } | 687 } |
687 | 688 |
688 cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, | 689 cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n, |
689 cycle->log); | 690 cycle->log); |
690 if (cycle->write_events == NULL) { | 691 if (cycle->write_events == NULL) { |
691 return NGX_ERROR; | 692 return NGX_ERROR; |
692 } | 693 } |
693 | 694 |
717 c[i].lock = 0; | 718 c[i].lock = 0; |
718 #endif | 719 #endif |
719 } while (i); | 720 } while (i); |
720 | 721 |
721 cycle->free_connections = next; | 722 cycle->free_connections = next; |
722 cycle->free_connection_n = ecf->connections; | 723 cycle->free_connection_n = cycle->connection_n; |
723 | 724 |
724 /* for each listening socket */ | 725 /* for each listening socket */ |
725 | 726 |
726 ls = cycle->listening.elts; | 727 ls = cycle->listening.elts; |
727 for (i = 0; i < cycle->listening.nelts; i++) { | 728 for (i = 0; i < cycle->listening.nelts; i++) { |
1135 #endif | 1136 #endif |
1136 #if (NGX_HAVE_RTSIG) | 1137 #if (NGX_HAVE_RTSIG) |
1137 ngx_uint_t rtsig; | 1138 ngx_uint_t rtsig; |
1138 ngx_core_conf_t *ccf; | 1139 ngx_core_conf_t *ccf; |
1139 #endif | 1140 #endif |
1140 ngx_int_t i, connections; | 1141 ngx_int_t i; |
1141 ngx_module_t *module; | 1142 ngx_module_t *module; |
1142 ngx_event_module_t *event_module; | 1143 ngx_event_module_t *event_module; |
1143 | 1144 |
1144 connections = NGX_CONF_UNSET_UINT; | |
1145 module = NULL; | 1145 module = NULL; |
1146 | 1146 |
1147 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) | 1147 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) |
1148 | 1148 |
1149 fd = epoll_create(100); | 1149 fd = epoll_create(100); |
1150 | 1150 |
1151 if (fd != -1) { | 1151 if (fd != -1) { |
1152 close(fd); | 1152 close(fd); |
1153 connections = DEFAULT_CONNECTIONS; | |
1154 module = &ngx_epoll_module; | 1153 module = &ngx_epoll_module; |
1155 | 1154 |
1156 } else if (ngx_errno != NGX_ENOSYS) { | 1155 } else if (ngx_errno != NGX_ENOSYS) { |
1157 connections = DEFAULT_CONNECTIONS; | |
1158 module = &ngx_epoll_module; | 1156 module = &ngx_epoll_module; |
1159 } | 1157 } |
1160 | 1158 |
1161 #endif | 1159 #endif |
1162 | 1160 |
1163 #if (NGX_HAVE_RTSIG) | 1161 #if (NGX_HAVE_RTSIG) |
1164 | 1162 |
1165 if (module == NULL) { | 1163 if (module == NULL) { |
1166 connections = DEFAULT_CONNECTIONS; | |
1167 module = &ngx_rtsig_module; | 1164 module = &ngx_rtsig_module; |
1168 rtsig = 1; | 1165 rtsig = 1; |
1169 | 1166 |
1170 } else { | 1167 } else { |
1171 rtsig = 0; | 1168 rtsig = 0; |
1173 | 1170 |
1174 #endif | 1171 #endif |
1175 | 1172 |
1176 #if (NGX_HAVE_DEVPOLL) | 1173 #if (NGX_HAVE_DEVPOLL) |
1177 | 1174 |
1178 connections = DEFAULT_CONNECTIONS; | |
1179 module = &ngx_devpoll_module; | 1175 module = &ngx_devpoll_module; |
1180 | 1176 |
1181 #endif | 1177 #endif |
1182 | 1178 |
1183 #if (NGX_HAVE_KQUEUE) | 1179 #if (NGX_HAVE_KQUEUE) |
1184 | 1180 |
1185 connections = DEFAULT_CONNECTIONS; | |
1186 module = &ngx_kqueue_module; | 1181 module = &ngx_kqueue_module; |
1187 | 1182 |
1188 #endif | 1183 #endif |
1189 | 1184 |
1190 #if (NGX_HAVE_SELECT) | 1185 #if (NGX_HAVE_SELECT) |
1191 | 1186 |
1192 if (module == NULL) { | 1187 if (module == NULL) { |
1193 | |
1194 #if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS) | |
1195 connections = DEFAULT_CONNECTIONS; | |
1196 #else | |
1197 connections = FD_SETSIZE; | |
1198 #endif | |
1199 module = &ngx_select_module; | 1188 module = &ngx_select_module; |
1200 } | 1189 } |
1201 | 1190 |
1202 #endif | 1191 #endif |
1203 | 1192 |
1204 if (module == NULL) { | 1193 if (module == NULL) { |
1205 for (i = 0; ngx_modules[i]; i++) { | 1194 for (i = 0; ngx_modules[i]; i++) { |
1206 if (ngx_modules[i]->type == NGX_EVENT_MODULE) { | 1195 |
1207 event_module = ngx_modules[i]->ctx; | 1196 if (ngx_modules[i]->type != NGX_EVENT_MODULE) { |
1208 | 1197 continue; |
1209 if (ngx_strcmp(event_module->name->data, event_core_name.data) | 1198 } |
1210 == 0) | 1199 |
1211 { | 1200 event_module = ngx_modules[i]->ctx; |
1212 continue; | 1201 |
1213 } | 1202 if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0) |
1214 | 1203 { |
1215 module = ngx_modules[i]; | 1204 continue; |
1216 break; | 1205 } |
1217 } | 1206 |
1207 module = ngx_modules[i]; | |
1208 break; | |
1218 } | 1209 } |
1219 } | 1210 } |
1220 | 1211 |
1221 if (module == NULL) { | 1212 if (module == NULL) { |
1222 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found"); | 1213 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found"); |
1223 return NGX_CONF_ERROR; | 1214 return NGX_CONF_ERROR; |
1224 } | 1215 } |
1225 | 1216 |
1226 ngx_conf_init_uint_value(ecf->connections, connections); | 1217 ngx_conf_init_uint_value(ecf->connections, DEFAULT_CONNECTIONS); |
1227 cycle->connection_n = ecf->connections; | 1218 cycle->connection_n = ecf->connections; |
1228 | 1219 |
1229 ngx_conf_init_uint_value(ecf->use, module->ctx_index); | 1220 ngx_conf_init_uint_value(ecf->use, module->ctx_index); |
1230 | 1221 |
1231 event_module = module->ctx; | 1222 event_module = module->ctx; |