Mercurial > hg > nginx
comparison src/core/ngx_log.c @ 5771:c3b08217f2a2
Core: fixed default log initialization.
The ngx_log_insert() function may invalidate pointer passed to it,
so make sure to don't use it after the ngx_log_insert() call.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 24 Jul 2014 16:25:07 +0400 |
parents | 777202558122 |
children | 727177743c3c |
comparison
equal
deleted
inserted
replaced
5770:9de5820bb3e0 | 5771:c3b08217f2a2 |
---|---|
385 log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); | 385 log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); |
386 if (log == NULL) { | 386 if (log == NULL) { |
387 return NGX_ERROR; | 387 return NGX_ERROR; |
388 } | 388 } |
389 | 389 |
390 log->log_level = NGX_LOG_ERR; | |
391 ngx_log_insert(&cycle->new_log, log); | |
392 | |
393 } else { | 390 } else { |
394 /* no error logs at all */ | 391 /* no error logs at all */ |
395 log = &cycle->new_log; | 392 log = &cycle->new_log; |
396 log->log_level = NGX_LOG_ERR; | 393 } |
397 } | 394 |
395 log->log_level = NGX_LOG_ERR; | |
398 | 396 |
399 log->file = ngx_conf_open_file(cycle, &error_log); | 397 log->file = ngx_conf_open_file(cycle, &error_log); |
400 if (log->file == NULL) { | 398 if (log->file == NULL) { |
401 return NGX_ERROR; | 399 return NGX_ERROR; |
400 } | |
401 | |
402 if (log != &cycle->new_log) { | |
403 ngx_log_insert(&cycle->new_log, log); | |
402 } | 404 } |
403 | 405 |
404 return NGX_OK; | 406 return NGX_OK; |
405 } | 407 } |
406 | 408 |