diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-12-10 15:09:51 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-12-10 15:09:51 +0300 |
commit | 86ef6aaa6b574f2015a5094670b7123c425a63af (patch) | |
tree | e0b78dcc48085162b29fbff2c0aeb7e5bd75c654 /src | |
parent | e60049418525a5e605765aa2b8f9c6796eb390a6 (diff) |
move condition declarations inside blocks where they are used
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nginx.c | 12 | ||||
-rw-r--r-- | src/core/ngx_cycle.c | 4 | ||||
-rw-r--r-- | src/core/ngx_file.c | 7 | ||||
-rw-r--r-- | src/event/modules/ngx_select_module.c | 5 | ||||
-rw-r--r-- | src/event/ngx_event.c | 25 | ||||
-rw-r--r-- | src/http/modules/ngx_http_referer_module.c | 8 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssi_filter_module.c | 9 | ||||
-rw-r--r-- | src/http/ngx_http.c | 7 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 17 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 26 | ||||
-rw-r--r-- | src/mail/ngx_mail_handler.c | 8 | ||||
-rw-r--r-- | src/mail/ngx_mail_imap_handler.c | 7 | ||||
-rw-r--r-- | src/mail/ngx_mail_pop3_handler.c | 7 | ||||
-rw-r--r-- | src/mail/ngx_mail_smtp_handler.c | 5 | ||||
-rw-r--r-- | src/os/unix/ngx_process_cycle.c | 11 |
15 files changed, 70 insertions, 88 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index ae68605ef..ee636825b 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -758,12 +758,6 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_core_conf_t *ccf = conf; -#if !(NGX_WIN32) - ngx_str_t lock_file; - struct group *grp; - struct passwd *pwd; -#endif - ngx_conf_init_value(ccf->daemon, 1); ngx_conf_init_value(ccf->master, 1); ngx_conf_init_msec_value(ccf->timer_resolution, 0); @@ -796,6 +790,8 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) #if !(NGX_WIN32) if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { + struct group *grp; + struct passwd *pwd; ngx_set_errno(0); pwd = getpwnam(NGX_USER); @@ -848,6 +844,9 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) return NGX_CONF_ERROR; } + { + ngx_str_t lock_file; + lock_file = cycle->old_cycle->lock_file; if (lock_file.len) { @@ -881,6 +880,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) ccf->lock_file.len), ".accept", sizeof(".accept")); } + } #endif diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index f900a2824..f0e86eb94 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -938,9 +938,6 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) ngx_uint_t i; ngx_list_part_t *part; ngx_open_file_t *file; -#if !(NGX_WIN32) - ngx_file_info_t fi; -#endif part = &cycle->open_files.part; file = part->elts; @@ -996,6 +993,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) } #else if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) { + ngx_file_info_t fi; if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index c945b558d..8edd3e14e 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -425,9 +425,6 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) ngx_err_t err; ngx_uint_t i; ngx_path_t **path; -#if !(NGX_WIN32) - ngx_file_info_t fi; -#endif path = cycle->pathes.elts; for (i = 0; i < cycle->pathes.nelts; i++) { @@ -447,6 +444,8 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) } #if !(NGX_WIN32) + { + ngx_file_info_t fi; if (ngx_file_info((const char *) path[i]->name.data, &fi) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, @@ -474,7 +473,7 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) return NGX_ERROR; } } - + } #endif } diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c index 1e704c2f6..19215a79c 100644 --- a/src/event/modules/ngx_select_module.c +++ b/src/event/modules/ngx_select_module.c @@ -254,9 +254,6 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_event_t *ev, **queue; ngx_connection_t *c; struct timeval tv, *tp; -#if !(NGX_WIN32) - ngx_uint_t level; -#endif #if !(NGX_WIN32) @@ -348,6 +345,8 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, #else if (err) { + ngx_uint_t level; + if (err == NGX_EINTR) { if (ngx_event_timer_alarm) { diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c index 7a856d409..d34710742 100644 --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -428,13 +428,9 @@ ngx_event_module_init(ngx_cycle_t *cycle) void ***cf; u_char *shared; size_t size, cl; - ngx_event_conf_t *ecf; - ngx_core_conf_t *ccf; ngx_shm_t shm; -#if !(NGX_WIN32) - ngx_int_t limit; - struct rlimit rlmt; -#endif + ngx_core_conf_t *ccf; + ngx_event_conf_t *ecf; cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); @@ -456,6 +452,9 @@ ngx_event_module_init(ngx_cycle_t *cycle) ngx_timer_resolution = ccf->timer_resolution; #if !(NGX_WIN32) + { + ngx_int_t limit; + struct rlimit rlmt; if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, @@ -475,7 +474,7 @@ ngx_event_module_init(ngx_cycle_t *cycle) ecf->connections, limit); } } - + } #endif /* !(NGX_WIN32) */ @@ -573,13 +572,6 @@ ngx_event_process_init(ngx_cycle_t *cycle) ngx_core_conf_t *ccf; ngx_event_conf_t *ecf; ngx_event_module_t *module; -#if (NGX_WIN32) - ngx_iocp_conf_t *iocpcf; -#else - struct rlimit rlmt; - struct sigaction sa; - struct itimerval itv; -#endif ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); @@ -625,6 +617,8 @@ ngx_event_process_init(ngx_cycle_t *cycle) #if !(NGX_WIN32) if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { + struct sigaction sa; + struct itimerval itv; ngx_memzero(&sa, sizeof(struct sigaction)); sa.sa_handler = ngx_timer_signal_handler; @@ -648,6 +642,7 @@ ngx_event_process_init(ngx_cycle_t *cycle) } if (ngx_event_flags & NGX_USE_FD_EVENT) { + struct rlimit rlmt; if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, @@ -774,6 +769,8 @@ ngx_event_process_init(ngx_cycle_t *cycle) #if (NGX_WIN32) if (ngx_event_flags & NGX_USE_IOCP_EVENT) { + ngx_iocp_conf_t *iocpcf; + rev->handler = ngx_event_acceptex; if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) { diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c index d5e8d6482..0076e9472 100644 --- a/src/http/modules/ngx_http_referer_module.c +++ b/src/http/modules/ngx_http_referer_module.c @@ -106,11 +106,6 @@ ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, ngx_uint_t i, key; ngx_http_referer_conf_t *rlcf; u_char buf[256]; -#if (NGX_PCRE) - ngx_int_t n; - ngx_str_t referer; - ngx_http_referer_regex_t *regex; -#endif rlcf = ngx_http_get_module_loc_conf(r, ngx_http_referer_module); @@ -173,6 +168,9 @@ ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, #if (NGX_PCRE) if (rlcf->regex) { + ngx_int_t n; + ngx_str_t referer; + ngx_http_referer_regex_t *regex; referer.len = len - 7; referer.data = ref; diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index ae72ee379..5e17cb59f 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -2373,11 +2373,6 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, ngx_str_t *expr, left, right; ngx_int_t rc; ngx_uint_t negative, noregex, flags; -#if (NGX_PCRE) - ngx_str_t err; - ngx_regex_t *regex; - u_char errstr[NGX_MAX_CONF_ERRSTR]; -#endif if (ctx->command.len == 2) { if (ctx->conditional) { @@ -2511,6 +2506,10 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, } else { #if (NGX_PCRE) + ngx_str_t err; + ngx_regex_t *regex; + u_char errstr[NGX_MAX_CONF_ERRSTR]; + err.len = NGX_MAX_CONF_ERRSTR; err.data = errstr; diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 59b43d054..e3583a4f8 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -101,9 +101,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) #if (NGX_PCRE) ngx_uint_t regex; #endif -#if (NGX_WIN32) - ngx_iocp_conf_t *iocpcf; -#endif /* the main http context */ @@ -821,10 +818,14 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ls->log.handler = ngx_accept_log_error; #if (NGX_WIN32) + { + ngx_iocp_conf_t *iocpcf; + iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module); if (iocpcf->acceptex_read) { ls->post_accept_buffer_size = cscf->client_header_buffer_size; } + } #endif ls->backlog = in_addr[a].listen_conf->backlog; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index b882f1c2f..dbfa91ac6 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1803,10 +1803,6 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) ngx_http_conf_ctx_t *ctx, *pctx; ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp; -#if (NGX_PCRE) - ngx_str_t err; - u_char errstr[NGX_MAX_CONF_ERRSTR]; -#endif ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)); if (ctx == NULL) { @@ -1861,6 +1857,9 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) && value[1].data[1] == '*')) { #if (NGX_PCRE) + ngx_str_t err; + u_char errstr[NGX_MAX_CONF_ERRSTR]; + err.len = NGX_MAX_CONF_ERRSTR; err.data = errstr; @@ -2803,10 +2802,6 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_str_t *value, name; ngx_uint_t i; ngx_http_server_name_t *sn; -#if (NGX_PCRE) - ngx_str_t err; - u_char errstr[NGX_MAX_CONF_ERRSTR]; -#endif value = cf->args->elts; @@ -2882,6 +2877,10 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } #if (NGX_PCRE) + { + ngx_str_t err; + u_char errstr[NGX_MAX_CONF_ERRSTR]; + err.len = NGX_MAX_CONF_ERRSTR; err.data = errstr; @@ -2898,7 +2897,7 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) sn->name.len = value[i].len; sn->name.data = value[i].data; - + } #else ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "the using of the regex \"%V\" " diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 3d06f964f..51ec46ce7 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -232,9 +232,6 @@ ngx_http_init_request(ngx_event_t *rev) ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf; ngx_http_core_main_conf_t *cmcf; -#if (NGX_HTTP_SSL) - ngx_http_ssl_srv_conf_t *sscf; -#endif #if (NGX_STAT_STUB) ngx_atomic_fetch_add(ngx_stat_reading, -1); @@ -354,6 +351,9 @@ ngx_http_init_request(ngx_event_t *rev) #if (NGX_HTTP_SSL) + { + ngx_http_ssl_srv_conf_t *sscf; + sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); if (sscf->enable) { @@ -370,6 +370,7 @@ ngx_http_init_request(ngx_event_t *rev) r->main_filter_need_in_memory = 1; } + } #endif @@ -1398,11 +1399,7 @@ ngx_http_process_request_header(ngx_http_request_t *r) static void ngx_http_process_request(ngx_http_request_t *r) { - ngx_connection_t *c; -#if (NGX_HTTP_SSL) - long rc; - ngx_http_ssl_srv_conf_t *sscf; -#endif + ngx_connection_t *c; c = r->connection; @@ -1416,6 +1413,9 @@ ngx_http_process_request(ngx_http_request_t *r) #if (NGX_HTTP_SSL) if (c->ssl) { + long rc; + ngx_http_ssl_srv_conf_t *sscf; + sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); if (sscf->verify) { @@ -1469,12 +1469,6 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, { ngx_http_core_loc_conf_t *clcf; ngx_http_core_srv_conf_t *cscf; -#if (NGX_PCRE) - ngx_int_t n; - ngx_uint_t i; - ngx_str_t name; - ngx_http_server_name_t *sn; -#endif cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len); @@ -1485,6 +1479,10 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, #if (NGX_PCRE) if (r->virtual_names->nregex) { + ngx_int_t n; + ngx_uint_t i; + ngx_str_t name; + ngx_http_server_name_t *sn; name.len = len; name.data = host; diff --git a/src/mail/ngx_mail_handler.c b/src/mail/ngx_mail_handler.c index e4985d3d2..0cb67a237 100644 --- a/src/mail/ngx_mail_handler.c +++ b/src/mail/ngx_mail_handler.c @@ -29,10 +29,6 @@ ngx_mail_init_connection(ngx_connection_t *c) ngx_mail_in_port_t *imip; ngx_mail_in_addr_t *imia; ngx_mail_session_t *s; -#if (NGX_MAIL_SSL) - ngx_mail_ssl_conf_t *sslcf; -#endif - /* find the server configuration for the address:port */ @@ -116,6 +112,8 @@ ngx_mail_init_connection(ngx_connection_t *c) c->log_error = NGX_ERROR_INFO; #if (NGX_MAIL_SSL) + { + ngx_mail_ssl_conf_t *sslcf; sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); @@ -123,7 +121,7 @@ ngx_mail_init_connection(ngx_connection_t *c) ngx_mail_ssl_init_connection(&sslcf->ssl, c); return; } - + } #endif ngx_mail_init_session(c); diff --git a/src/mail/ngx_mail_imap_handler.c b/src/mail/ngx_mail_imap_handler.c index 949e96e2e..62ba17da8 100644 --- a/src/mail/ngx_mail_imap_handler.c +++ b/src/mail/ngx_mail_imap_handler.c @@ -302,7 +302,7 @@ ngx_mail_imap_auth_state(ngx_event_t *rev) static ngx_int_t ngx_mail_imap_login(ngx_mail_session_t *s, ngx_connection_t *c) { - ngx_str_t *arg; + ngx_str_t *arg; #if (NGX_MAIL_SSL) if (ngx_mail_starttls_only(s, c)) { @@ -410,15 +410,14 @@ static ngx_int_t ngx_mail_imap_capability(ngx_mail_session_t *s, ngx_connection_t *c) { ngx_mail_imap_srv_conf_t *iscf; -#if (NGX_MAIL_SSL) - ngx_mail_ssl_conf_t *sslcf; -#endif iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); #if (NGX_MAIL_SSL) if (c->ssl == NULL) { + ngx_mail_ssl_conf_t *sslcf; + sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { diff --git a/src/mail/ngx_mail_pop3_handler.c b/src/mail/ngx_mail_pop3_handler.c index 966345a5a..c486fbebd 100644 --- a/src/mail/ngx_mail_pop3_handler.c +++ b/src/mail/ngx_mail_pop3_handler.c @@ -283,7 +283,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *rev) static ngx_int_t ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c) { - ngx_str_t *arg; + ngx_str_t *arg; #if (NGX_MAIL_SSL) if (ngx_mail_starttls_only(s, c)) { @@ -344,15 +344,14 @@ static ngx_int_t ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls) { ngx_mail_pop3_srv_conf_t *pscf; -#if (NGX_MAIL_SSL) - ngx_mail_ssl_conf_t *sslcf; -#endif pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); #if (NGX_MAIL_SSL) if (stls && c->ssl == NULL) { + ngx_mail_ssl_conf_t *sslcf; + sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { diff --git a/src/mail/ngx_mail_smtp_handler.c b/src/mail/ngx_mail_smtp_handler.c index 96cb762ed..84722f4ee 100644 --- a/src/mail/ngx_mail_smtp_handler.c +++ b/src/mail/ngx_mail_smtp_handler.c @@ -319,9 +319,6 @@ ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c) { ngx_str_t *arg; ngx_mail_smtp_srv_conf_t *sscf; -#if (NGX_MAIL_SSL) - ngx_mail_ssl_conf_t *sslcf; -#endif if (s->args.nelts != 1) { s->out.len = sizeof(smtp_invalid_argument) - 1; @@ -352,6 +349,8 @@ ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c) #if (NGX_MAIL_SSL) if (c->ssl == NULL) { + ngx_mail_ssl_conf_t *sslcf; + sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index 631597ef4..aa95e81d9 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -687,17 +687,16 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) { ngx_uint_t i; ngx_connection_t *c; -#if (NGX_THREADS) - ngx_int_t n; - ngx_err_t err; - ngx_core_conf_t *ccf; -#endif ngx_worker_process_init(cycle, 1); ngx_setproctitle("worker process"); #if (NGX_THREADS) + { + ngx_int_t n; + ngx_err_t err; + ngx_core_conf_t *ccf; ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); @@ -736,7 +735,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) } } } - + } #endif for ( ;; ) { |