Skip to content

Commit

Permalink
Changes with nginx 1.5.2 02 Jul 2013
Browse files Browse the repository at this point in the history
*) Feature: now several "error_log" directives can be used.

*) Bugfix: the $r->header_in() embedded perl method did not return value
of the "Cookie" and "X-Forwarded-For" request header lines; the bug
had appeared in 1.3.14.

*) Bugfix: in the ngx_http_spdy_module.
Thanks to Jim Radford.

*) Bugfix: nginx could not be built on Linux with x32 ABI.
Thanks to Serguei Ivantsov.
  • Loading branch information
nginx authored and kolbyjack committed Jul 2, 2013
1 parent e876b18 commit 76075f5
Show file tree
Hide file tree
Showing 21 changed files with 226 additions and 108 deletions.
15 changes: 15 additions & 0 deletions CHANGES
@@ -1,4 +1,19 @@

Changes with nginx 1.5.2 02 Jul 2013

*) Feature: now several "error_log" directives can be used.

*) Bugfix: the $r->header_in() embedded perl method did not return value
of the "Cookie" and "X-Forwarded-For" request header lines; the bug
had appeared in 1.3.14.

*) Bugfix: in the ngx_http_spdy_module.
Thanks to Jim Radford.

*) Bugfix: nginx could not be built on Linux with x32 ABI.
Thanks to Serguei Ivantsov.


Changes with nginx 1.5.1 04 Jun 2013

*) Feature: the "ssi_last_modified", "sub_filter_last_modified", and
Expand Down
15 changes: 15 additions & 0 deletions CHANGES.ru
@@ -1,4 +1,19 @@

Изменения в nginx 1.5.2 02.07.2013

*) Добавление: теперь можно использовать несколько директив error_log.

*) Исправление: метод $r->header_in() встроенного перла не возвращал
значения строк "Cookie" и "X-Forwarded-For" из заголовка запроса;
ошибка появилась в 1.3.14.

*) Исправление: в модуле ngx_http_spdy_module.
Спасибо Jim Radford.

*) Исправление: nginx не собирался на Linux при использовании x32 ABI.
Спасибо Сергею Иванцову.


Изменения в nginx 1.5.1 04.06.2013

*) Добавление: директивы ssi_last_modified, sub_filter_last_modified и
Expand Down
2 changes: 1 addition & 1 deletion src/core/nginx.c
Expand Up @@ -387,7 +387,7 @@ main(int argc, char *const *argv)
return 1;
}

if (cycle->log->file->fd != ngx_stderr) {
if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {

if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
Expand Down
4 changes: 2 additions & 2 deletions src/core/nginx.h
Expand Up @@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_


#define nginx_version 1005001
#define NGINX_VERSION "1.5.1"
#define nginx_version 1005002
#define NGINX_VERSION "1.5.2"
#define NGINX_VER "nginx/" NGINX_VERSION

#define NGINX_VAR "NGINX"
Expand Down
19 changes: 9 additions & 10 deletions src/core/ngx_cycle.c
Expand Up @@ -84,7 +84,6 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)

cycle->pool = pool;
cycle->log = log;
cycle->new_log.log_level = NGX_LOG_ERR;
cycle->old_cycle = old_cycle;

cycle->conf_prefix.len = old_cycle->conf_prefix.len;
Expand Down Expand Up @@ -344,6 +343,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
if (cycle->new_log.file == NULL) {
goto failed;
}

cycle->new_log.log_level = NGX_LOG_ERR;
}

/* open the new files */
Expand Down Expand Up @@ -582,8 +583,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)

/* commit the new cycle configuration */

if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {

if (!ngx_use_stderr && !cycle->log_use_stderr
&& cycle->log->file->fd != ngx_stderr)
{
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_set_stderr_n " failed");
Expand Down Expand Up @@ -1228,16 +1230,13 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
file[i].fd = fd;
}

#if !(NGX_WIN32)
if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {

if (cycle->log->file->fd != STDERR_FILENO) {
if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"dup2(STDERR) failed");
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_set_stderr_n " failed");
}
}

#endif
}


Expand Down
2 changes: 2 additions & 0 deletions src/core/ngx_cycle.h
Expand Up @@ -41,6 +41,8 @@ struct ngx_cycle_s {
ngx_log_t *log;
ngx_log_t new_log;

ngx_uint_t log_use_stderr; /* unsigned log_use_stderr:1; */

ngx_connection_t **files;
ngx_connection_t *free_connections;
ngx_uint_t free_connection_n;
Expand Down
10 changes: 1 addition & 9 deletions src/core/ngx_list.c
Expand Up @@ -19,18 +19,10 @@ ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size)
return NULL;
}

list->part.elts = ngx_palloc(pool, n * size);
if (list->part.elts == NULL) {
if (ngx_list_init(list, pool, n, size) != NGX_OK) {
return NULL;
}

list->part.nelts = 0;
list->part.next = NULL;
list->last = &list->part;
list->size = size;
list->nalloc = n;
list->pool = pool;

return list;
}

Expand Down
138 changes: 99 additions & 39 deletions src/core/ngx_log.c
Expand Up @@ -10,6 +10,8 @@


static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
static void ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log);


static ngx_command_t ngx_errlog_commands[] = {
Expand Down Expand Up @@ -86,14 +88,11 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
#endif
{
#if (NGX_HAVE_VARIADIC_MACROS)
va_list args;
va_list args;
#endif
u_char *p, *last, *msg;
u_char errstr[NGX_MAX_ERROR_STR];

if (log->file->fd == NGX_INVALID_FILE) {
return;
}
u_char *p, *last, *msg;
u_char errstr[NGX_MAX_ERROR_STR];
ngx_uint_t wrote_stderr, debug_connection;

last = errstr + NGX_MAX_ERROR_STR;

Expand Down Expand Up @@ -140,11 +139,27 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,

ngx_linefeed(p);

(void) ngx_write_fd(log->file->fd, errstr, p - errstr);
wrote_stderr = 0;
debug_connection = (log->log_level & NGX_LOG_DEBUG_CONNECTION) != 0;

while (log) {

if (log->log_level < level && !debug_connection) {
break;
}

(void) ngx_write_fd(log->file->fd, errstr, p - errstr);

if (log->file->fd == ngx_stderr) {
wrote_stderr = 1;
}

log = log->next;
}

if (!ngx_use_stderr
|| level > NGX_LOG_WARN
|| log->file->fd == ngx_stderr)
|| wrote_stderr)
{
return;
}
Expand Down Expand Up @@ -348,31 +363,17 @@ ngx_log_init(u_char *prefix)
}


ngx_log_t *
ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name)
{
ngx_log_t *log;

log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t));
if (log == NULL) {
return NULL;
}

log->file = ngx_conf_open_file(cycle, name);
if (log->file == NULL) {
return NULL;
}

return log;
}


char *
static char *
ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
{
ngx_uint_t i, n, d, found;
ngx_str_t *value;

if (cf->args->nelts == 2) {
log->log_level = NGX_LOG_ERR;
return NGX_CONF_OK;
}

value = cf->args->elts;

for (i = 2; i < cf->args->nelts; i++) {
Expand Down Expand Up @@ -428,32 +429,91 @@ ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
static char *
ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_log_t *dummy;

dummy = &cf->cycle->new_log;

return ngx_log_set_log(cf, &dummy);
}


char *
ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head)
{
ngx_log_t *new_log;
ngx_str_t *value, name;

if (cf->cycle->new_log.file) {
return "is duplicate";
if (*head != NULL && (*head)->log_level == 0) {
new_log = *head;

} else {

new_log = ngx_pcalloc(cf->pool, sizeof(ngx_log_t));
if (new_log == NULL) {
return NGX_CONF_ERROR;
}

if (*head == NULL) {
*head = new_log;
}
}

value = cf->args->elts;

if (ngx_strcmp(value[1].data, "stderr") == 0) {
ngx_str_null(&name);
cf->cycle->log_use_stderr = 1;

} else {
name = value[1];
}

cf->cycle->new_log.file = ngx_conf_open_file(cf->cycle, &name);
if (cf->cycle->new_log.file == NULL) {
return NULL;
new_log->file = ngx_conf_open_file(cf->cycle, &name);
if (new_log->file == NULL) {
return NGX_CONF_ERROR;
}

if (cf->args->nelts == 2) {
cf->cycle->new_log.log_level = NGX_LOG_ERR;
return NGX_CONF_OK;
if (ngx_log_set_levels(cf, new_log) != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}

if (*head != new_log) {
ngx_log_insert(*head, new_log);
}

cf->cycle->new_log.log_level = 0;
return NGX_CONF_OK;
}


static void
ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log)
{
ngx_log_t tmp;

if (new_log->log_level > log->log_level) {

/*
* list head address is permanent, insert new log after
* head and swap its contents with head
*/

tmp = *log;
*log = *new_log;
*new_log = tmp;

log->next = new_log;
return;
}

while (log->next) {
if (new_log->log_level > log->next->log_level) {
new_log->next = log->next;
log->next = new_log;
return;
}

log = log->next;
}

return ngx_log_set_levels(cf, &cf->cycle->new_log);
log->next = new_log;
}
5 changes: 3 additions & 2 deletions src/core/ngx_log.h
Expand Up @@ -61,6 +61,8 @@ struct ngx_log_s {
*/

char *action;

ngx_log_t *next;
};


Expand Down Expand Up @@ -220,11 +222,10 @@ void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err,
/*********************************/

ngx_log_t *ngx_log_init(u_char *prefix);
ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
u_char *ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err);
char *ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head);


/*
Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_stub_status_module.c
Expand Up @@ -145,6 +145,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
r->headers_out.content_length_n = b->last - b->pos;

b->last_buf = (r == r->main) ? 1 : 0;
b->last_in_chain = 1;

rc = ngx_http_send_header(r);

Expand Down

0 comments on commit 76075f5

Please sign in to comment.