diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.c | 45 | ||||
-rw-r--r-- | src/core/ngx_conf_file.c | 2 | ||||
-rw-r--r-- | src/core/ngx_conf_file.h | 5 | ||||
-rw-r--r-- | src/core/ngx_log.c | 6 | ||||
-rw-r--r-- | src/core/ngx_rbtree.h | 8 |
5 files changed, 47 insertions, 19 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index d52933aa9..e02866e53 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -24,14 +24,14 @@ static ngx_str_t core_name = ngx_string("core"); static ngx_command_t ngx_core_commands[] = { - {ngx_string("daemon"), - NGX_MAIN_CONF|NGX_CONF_TAKE1, - ngx_conf_set_core_flag_slot, - 0, - offsetof(ngx_core_conf_t, daemon), - NULL}, - - ngx_null_command + { ngx_string("daemon"), + NGX_MAIN_CONF|NGX_CONF_TAKE1, + ngx_conf_set_core_flag_slot, + 0, + offsetof(ngx_core_conf_t, daemon), + NULL }, + + ngx_null_command }; @@ -238,6 +238,7 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data); static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log) { int i, n, failed; + ngx_fd_t fd; ngx_str_t conf_file; ngx_conf_t conf; ngx_pool_t *pool; @@ -390,6 +391,26 @@ ngx_log_debug(log, "OPEN: %d:%s" _ file[i].fd _ file[i].name.data); if (ngx_memcmp(nls[n].sockaddr, ls[i].sockaddr, ls[i].socklen) == 0) { + fd = ls[i].fd; +#if (WIN32) + /* + * Winsock assignes a socket number divisible by 4 so + * to find a connection we divide a socket number by 4. + */ + + fd /= 4; +#endif + if (fd >= cycle->connection_n) { + ngx_log_error(NGX_LOG_EMERG, log, 0, + "%d connections is not enough to hold " + "an open listening socket on %s, " + "required at least %d connections", + cycle->connection_n, + ls[i].addr_text.data, fd); + failed = 1; + break; + } + nls[n].fd = ls[i].fd; nls[i].remain = 1; ls[i].remain = 1; @@ -409,8 +430,10 @@ ngx_log_debug(log, "OPEN: %d:%s" _ file[i].fd _ file[i].name.data); } } - if (ngx_open_listening_sockets(cycle, log) == NGX_ERROR) { - failed = 1; + if (!failed) { + if (ngx_open_listening_sockets(cycle, log) == NGX_ERROR) { + failed = 1; + } } } @@ -583,7 +606,7 @@ static int ngx_open_listening_sockets(ngx_cycle_t *cycle, ngx_log_t *log) if (s == -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, - ngx_socket_n " %s falied", ls[i].addr_text.data); + ngx_socket_n " %s failed", ls[i].addr_text.data); return NGX_ERROR; } diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 868945747..249239072 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -230,7 +230,7 @@ ngx_log_debug(cf->log, "rv: %d" _ rv); } else { ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "\"%s\" directive %s in %s:%d", + "the \"%s\" directive %s in %s:%d", name->data, rv, cf->conf_file->file.name.data, cf->conf_file->line); diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index eb5478e61..eb9e63b51 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -179,6 +179,11 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); conf = default; \ } +#define ngx_conf_init_ptr_value(conf, default) \ + if (conf == (void *) NGX_CONF_UNSET) { \ + conf = default; \ + } + #define ngx_conf_init_unsigned_value(conf, default) \ if (conf == (unsigned) NGX_CONF_UNSET) { \ conf = default; \ diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index b615c7ea2..fede0a079 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -323,7 +323,7 @@ static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } d = NGX_LOG_DEBUG_FIRST; - for (n = 0; n < /* STUB */ 3; n++) { + for (n = 0; n < /* STUB */ 4; n++) { if (ngx_strcmp(value[i].data, debug_levels[n]) == 0) { if (cf->cycle->log->log_level & ~NGX_LOG_DEBUG_ALL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, @@ -333,9 +333,9 @@ static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } cf->cycle->log->log_level |= d; - d <<= 1; - continue; } + + d <<= 1; } diff --git a/src/core/ngx_rbtree.h b/src/core/ngx_rbtree.h index db435ff1c..04d762292 100644 --- a/src/core/ngx_rbtree.h +++ b/src/core/ngx_rbtree.h @@ -23,14 +23,14 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel, ngx_rbtree_t *node); -ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *root, +ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *node, ngx_rbtree_t *sentinel) { - while (root->left != sentinel) { - root = root->left; + while (node->left != sentinel) { + node = node->left; } - return root; + return node; } |