Klaus Demo nginx / 86ef6aa
move condition declarations inside blocks where they are used Igor Sysoev 14 years ago
15 changed file(s) with 81 addition(s) and 99 deletion(s). Raw diff Collapse all Expand all
757757 {
758758 ngx_core_conf_t *ccf = conf;
759759
760 #if !(NGX_WIN32)
761 ngx_str_t lock_file;
762 struct group *grp;
763 struct passwd *pwd;
764 #endif
765
766760 ngx_conf_init_value(ccf->daemon, 1);
767761 ngx_conf_init_value(ccf->master, 1);
768762 ngx_conf_init_msec_value(ccf->timer_resolution, 0);
795789 #if !(NGX_WIN32)
796790
797791 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) {
792 struct group *grp;
793 struct passwd *pwd;
798794
799795 ngx_set_errno(0);
800796 pwd = getpwnam(NGX_USER);
847843 return NGX_CONF_ERROR;
848844 }
849845
846 {
847 ngx_str_t lock_file;
848
850849 lock_file = cycle->old_cycle->lock_file;
851850
852851 if (lock_file.len) {
880879 ccf->lock_file.len),
881880 ".accept", sizeof(".accept"));
882881 }
882 }
883883
884884 #endif
885885
937937 ngx_uint_t i;
938938 ngx_list_part_t *part;
939939 ngx_open_file_t *file;
940 #if !(NGX_WIN32)
941 ngx_file_info_t fi;
942 #endif
943940
944941 part = &cycle->open_files.part;
945942 file = part->elts;
995992 }
996993 #else
997994 if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
995 ngx_file_info_t fi;
998996
999997 if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) {
1000998 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
424424 ngx_err_t err;
425425 ngx_uint_t i;
426426 ngx_path_t **path;
427 #if !(NGX_WIN32)
428 ngx_file_info_t fi;
429 #endif
430427
431428 path = cycle->pathes.elts;
432429 for (i = 0; i < cycle->pathes.nelts; i++) {
446443 }
447444
448445 #if !(NGX_WIN32)
446 {
447 ngx_file_info_t fi;
449448
450449 if (ngx_file_info((const char *) path[i]->name.data, &fi) == -1) {
451450 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
473472 return NGX_ERROR;
474473 }
475474 }
476
475 }
477476 #endif
478477 }
479478
253253 ngx_event_t *ev, **queue;
254254 ngx_connection_t *c;
255255 struct timeval tv, *tp;
256 #if !(NGX_WIN32)
257 ngx_uint_t level;
258 #endif
259256
260257 #if !(NGX_WIN32)
261258
347344 #else
348345
349346 if (err) {
347 ngx_uint_t level;
348
350349 if (err == NGX_EINTR) {
351350
352351 if (ngx_event_timer_alarm) {
427427 void ***cf;
428428 u_char *shared;
429429 size_t size, cl;
430 ngx_shm_t shm;
431 ngx_core_conf_t *ccf;
430432 ngx_event_conf_t *ecf;
431 ngx_core_conf_t *ccf;
432 ngx_shm_t shm;
433 #if !(NGX_WIN32)
434 ngx_int_t limit;
435 struct rlimit rlmt;
436 #endif
437433
438434 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
439435
455451 ngx_timer_resolution = ccf->timer_resolution;
456452
457453 #if !(NGX_WIN32)
454 {
455 ngx_int_t limit;
456 struct rlimit rlmt;
458457
459458 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
460459 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
474473 ecf->connections, limit);
475474 }
476475 }
477
476 }
478477 #endif /* !(NGX_WIN32) */
479478
480479
572571 ngx_core_conf_t *ccf;
573572 ngx_event_conf_t *ecf;
574573 ngx_event_module_t *module;
575 #if (NGX_WIN32)
576 ngx_iocp_conf_t *iocpcf;
577 #else
578 struct rlimit rlmt;
579 struct sigaction sa;
580 struct itimerval itv;
581 #endif
582574
583575 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
584576 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
624616 #if !(NGX_WIN32)
625617
626618 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) {
619 struct sigaction sa;
620 struct itimerval itv;
627621
628622 ngx_memzero(&sa, sizeof(struct sigaction));
629623 sa.sa_handler = ngx_timer_signal_handler;
647641 }
648642
649643 if (ngx_event_flags & NGX_USE_FD_EVENT) {
644 struct rlimit rlmt;
650645
651646 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
652647 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
773768 #if (NGX_WIN32)
774769
775770 if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
771 ngx_iocp_conf_t *iocpcf;
772
776773 rev->handler = ngx_event_acceptex;
777774
778775 if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) {
105105 ngx_uint_t i, key;
106106 ngx_http_referer_conf_t *rlcf;
107107 u_char buf[256];
108 #if (NGX_PCRE)
109 ngx_int_t n;
110 ngx_str_t referer;
111 ngx_http_referer_regex_t *regex;
112 #endif
113108
114109 rlcf = ngx_http_get_module_loc_conf(r, ngx_http_referer_module);
115110
172167 #if (NGX_PCRE)
173168
174169 if (rlcf->regex) {
170 ngx_int_t n;
171 ngx_str_t referer;
172 ngx_http_referer_regex_t *regex;
175173
176174 referer.len = len - 7;
177175 referer.data = ref;
23722372 ngx_str_t *expr, left, right;
23732373 ngx_int_t rc;
23742374 ngx_uint_t negative, noregex, flags;
2375 #if (NGX_PCRE)
2376 ngx_str_t err;
2377 ngx_regex_t *regex;
2378 u_char errstr[NGX_MAX_CONF_ERRSTR];
2379 #endif
23802375
23812376 if (ctx->command.len == 2) {
23822377 if (ctx->conditional) {
25102505
25112506 } else {
25122507 #if (NGX_PCRE)
2508 ngx_str_t err;
2509 ngx_regex_t *regex;
2510 u_char errstr[NGX_MAX_CONF_ERRSTR];
2511
25132512 err.len = NGX_MAX_CONF_ERRSTR;
25142513 err.data = errstr;
25152514
100100 #if (NGX_PCRE)
101101 ngx_uint_t regex;
102102 #endif
103 #if (NGX_WIN32)
104 ngx_iocp_conf_t *iocpcf;
105 #endif
106103
107104 /* the main http context */
108105
820817 ls->log.handler = ngx_accept_log_error;
821818
822819 #if (NGX_WIN32)
820 {
821 ngx_iocp_conf_t *iocpcf;
822
823823 iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module);
824824 if (iocpcf->acceptex_read) {
825825 ls->post_accept_buffer_size = cscf->client_header_buffer_size;
826 }
826827 }
827828 #endif
828829
18021802 ngx_http_conf_ctx_t *ctx, *pctx;
18031803 ngx_http_core_srv_conf_t *cscf;
18041804 ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
1805 #if (NGX_PCRE)
1806 ngx_str_t err;
1807 u_char errstr[NGX_MAX_CONF_ERRSTR];
1808 #endif
18091805
18101806 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
18111807 if (ctx == NULL) {
18601856 && value[1].data[1] == '*'))
18611857 {
18621858 #if (NGX_PCRE)
1859 ngx_str_t err;
1860 u_char errstr[NGX_MAX_CONF_ERRSTR];
1861
18631862 err.len = NGX_MAX_CONF_ERRSTR;
18641863 err.data = errstr;
18651864
28022801 ngx_str_t *value, name;
28032802 ngx_uint_t i;
28042803 ngx_http_server_name_t *sn;
2805 #if (NGX_PCRE)
2806 ngx_str_t err;
2807 u_char errstr[NGX_MAX_CONF_ERRSTR];
2808 #endif
28092804
28102805 value = cf->args->elts;
28112806
28812876 }
28822877
28832878 #if (NGX_PCRE)
2879 {
2880 ngx_str_t err;
2881 u_char errstr[NGX_MAX_CONF_ERRSTR];
2882
28842883 err.len = NGX_MAX_CONF_ERRSTR;
28852884 err.data = errstr;
28862885
28972896
28982897 sn->name.len = value[i].len;
28992898 sn->name.data = value[i].data;
2900
2899 }
29012900 #else
29022901 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
29032902 "the using of the regex \"%V\" "
231231 ngx_http_core_srv_conf_t *cscf;
232232 ngx_http_core_loc_conf_t *clcf;
233233 ngx_http_core_main_conf_t *cmcf;
234 #if (NGX_HTTP_SSL)
235 ngx_http_ssl_srv_conf_t *sscf;
236 #endif
237234
238235 #if (NGX_STAT_STUB)
239236 ngx_atomic_fetch_add(ngx_stat_reading, -1);
353350
354351 #if (NGX_HTTP_SSL)
355352
353 {
354 ngx_http_ssl_srv_conf_t *sscf;
355
356356 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
357357 if (sscf->enable) {
358358
368368 }
369369
370370 r->main_filter_need_in_memory = 1;
371 }
371372 }
372373
373374 #endif
13971398 static void
13981399 ngx_http_process_request(ngx_http_request_t *r)
13991400 {
1400 ngx_connection_t *c;
1401 #if (NGX_HTTP_SSL)
1402 long rc;
1403 ngx_http_ssl_srv_conf_t *sscf;
1404 #endif
1401 ngx_connection_t *c;
14051402
14061403 c = r->connection;
14071404
14151412 #if (NGX_HTTP_SSL)
14161413
14171414 if (c->ssl) {
1415 long rc;
1416 ngx_http_ssl_srv_conf_t *sscf;
1417
14181418 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
14191419
14201420 if (sscf->verify) {
14681468 {
14691469 ngx_http_core_loc_conf_t *clcf;
14701470 ngx_http_core_srv_conf_t *cscf;
1471 #if (NGX_PCRE)
1472 ngx_int_t n;
1473 ngx_uint_t i;
1474 ngx_str_t name;
1475 ngx_http_server_name_t *sn;
1476 #endif
14771471
14781472 cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len);
14791473
14841478 #if (NGX_PCRE)
14851479
14861480 if (r->virtual_names->nregex) {
1481 ngx_int_t n;
1482 ngx_uint_t i;
1483 ngx_str_t name;
1484 ngx_http_server_name_t *sn;
14871485
14881486 name.len = len;
14891487 name.data = host;
2828 ngx_mail_in_port_t *imip;
2929 ngx_mail_in_addr_t *imia;
3030 ngx_mail_session_t *s;
31 #if (NGX_MAIL_SSL)
32 ngx_mail_ssl_conf_t *sslcf;
33 #endif
34
3531
3632 /* find the server configuration for the address:port */
3733
115111 c->log_error = NGX_ERROR_INFO;
116112
117113 #if (NGX_MAIL_SSL)
114 {
115 ngx_mail_ssl_conf_t *sslcf;
118116
119117 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
120118
122120 ngx_mail_ssl_init_connection(&sslcf->ssl, c);
123121 return;
124122 }
125
123 }
126124 #endif
127125
128126 ngx_mail_init_session(c);
301301 static ngx_int_t
302302 ngx_mail_imap_login(ngx_mail_session_t *s, ngx_connection_t *c)
303303 {
304 ngx_str_t *arg;
304 ngx_str_t *arg;
305305
306306 #if (NGX_MAIL_SSL)
307307 if (ngx_mail_starttls_only(s, c)) {
409409 ngx_mail_imap_capability(ngx_mail_session_t *s, ngx_connection_t *c)
410410 {
411411 ngx_mail_imap_srv_conf_t *iscf;
412
413 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module);
414
412415 #if (NGX_MAIL_SSL)
413 ngx_mail_ssl_conf_t *sslcf;
414 #endif
415
416 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module);
417
418 #if (NGX_MAIL_SSL)
419416
420417 if (c->ssl == NULL) {
418 ngx_mail_ssl_conf_t *sslcf;
419
421420 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
422421
423422 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
282282 static ngx_int_t
283283 ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c)
284284 {
285 ngx_str_t *arg;
285 ngx_str_t *arg;
286286
287287 #if (NGX_MAIL_SSL)
288288 if (ngx_mail_starttls_only(s, c)) {
343343 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls)
344344 {
345345 ngx_mail_pop3_srv_conf_t *pscf;
346
347 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
348
346349 #if (NGX_MAIL_SSL)
347 ngx_mail_ssl_conf_t *sslcf;
348 #endif
349
350 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
351
352 #if (NGX_MAIL_SSL)
353350
354351 if (stls && c->ssl == NULL) {
352 ngx_mail_ssl_conf_t *sslcf;
353
355354 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
356355
357356 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
318318 {
319319 ngx_str_t *arg;
320320 ngx_mail_smtp_srv_conf_t *sscf;
321 #if (NGX_MAIL_SSL)
322 ngx_mail_ssl_conf_t *sslcf;
323 #endif
324321
325322 if (s->args.nelts != 1) {
326323 s->out.len = sizeof(smtp_invalid_argument) - 1;
351348 #if (NGX_MAIL_SSL)
352349
353350 if (c->ssl == NULL) {
351 ngx_mail_ssl_conf_t *sslcf;
352
354353 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
355354
356355 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
686686 {
687687 ngx_uint_t i;
688688 ngx_connection_t *c;
689
690 ngx_worker_process_init(cycle, 1);
691
692 ngx_setproctitle("worker process");
693
689694 #if (NGX_THREADS)
690 ngx_int_t n;
691 ngx_err_t err;
692 ngx_core_conf_t *ccf;
693 #endif
694
695 ngx_worker_process_init(cycle, 1);
696
697 ngx_setproctitle("worker process");
698
699 #if (NGX_THREADS)
695 {
696 ngx_int_t n;
697 ngx_err_t err;
698 ngx_core_conf_t *ccf;
700699
701700 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
702701
735734 }
736735 }
737736 }
738
737 }
739738 #endif
740739
741740 for ( ;; ) {