move condition declarations inside blocks where they are used

This commit is contained in:
Igor Sysoev 2007-12-10 12:09:51 +00:00
parent e600494185
commit 86ef6aaa6b
15 changed files with 70 additions and 88 deletions

View File

@ -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

View File

@ -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,

View File

@ -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
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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\" "

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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 ( ;; ) {