Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix a bug of segment fault

  • Loading branch information...
commit 06961717ae5e535b1520ca51689dbe3291273739 1 parent 3de3cbf
Weibin Yao(姚伟斌) authored May 03, 2011

Showing 1 changed file with 14 additions and 11 deletions. Show diff stats Hide diff stats

  1. 25  syslog_0.8.54.patch
25  syslog_0.8.54.patch
@@ -13,7 +13,7 @@ index 357c6b2..9540367 100644
13 13
  
14 14
      cycle->conf_prefix.len = old_cycle->conf_prefix.len;
15 15
 diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
16  
-index c0485c6..c551248 100644
  16
+index c0485c6..c207fe6 100644
17 17
 --- a/src/core/ngx_log.c
18 18
 +++ b/src/core/ngx_log.c
19 19
 @@ -9,6 +9,14 @@
@@ -132,7 +132,7 @@ index c0485c6..c551248 100644
132 132
 +    /* Don't send the debug info to syslog */
133 133
 +    if (log->syslog_on && level < NGX_LOG_DEBUG) {
134 134
 +        /* write to syslog */
135  
-+        syslog(log->priority, "%.*s", p - errstr, errstr_syslog);
  135
++        syslog(log->priority, "%.*s", p - errstr_syslog, errstr_syslog);
136 136
 +    }
137 137
  
138 138
      if (!ngx_use_stderr
@@ -339,7 +339,7 @@ index 1054836..f280956 100644
339 339
  void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
340 340
  void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
341 341
 diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
342  
-index 5f356c3..78589f1 100644
  342
+index 5f356c3..fa021c5 100644
343 343
 --- a/src/http/modules/ngx_http_log_module.c
344 344
 +++ b/src/http/modules/ngx_http_log_module.c
345 345
 @@ -8,6 +8,9 @@
@@ -362,7 +362,7 @@ index 5f356c3..78589f1 100644
362 362
  } ngx_http_log_t;
363 363
  
364 364
  
365  
-@@ -312,13 +318,22 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
  365
+@@ -312,13 +318,25 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
366 366
  {
367 367
      u_char     *name;
368 368
      time_t      now;
@@ -385,10 +385,13 @@ index 5f356c3..78589f1 100644
385 385
 +        if (name != NULL) {
386 386
 +            n = ngx_write_fd(log->file->fd, buf, len);
387 387
 +        }
  388
++        else {
  389
++            n = len;
  390
++        }
388 391
      } else {
389 392
          name = NULL;
390 393
          n = ngx_http_log_script_write(r, log->script, &name, buf, len);
391  
-@@ -827,6 +842,9 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
  394
+@@ -827,6 +845,9 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
392 395
      log->disk_full_time = 0;
393 396
      log->error_log_time = 0;
394 397
  
@@ -398,7 +401,7 @@ index 5f356c3..78589f1 100644
398 401
      lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
399 402
      fmt = lmcf->formats.elts;
400 403
  
401  
-@@ -843,14 +861,16 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  404
+@@ -843,14 +864,16 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
402 405
  {
403 406
      ngx_http_log_loc_conf_t *llcf = conf;
404 407
  
@@ -417,7 +420,7 @@ index 5f356c3..78589f1 100644
417 420
      value = cf->args->elts;
418 421
  
419 422
      if (ngx_strcmp(value[1].data, "off") == 0) {
420  
-@@ -863,6 +883,36 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  423
+@@ -863,6 +886,36 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
421 424
                             "invalid parameter \"%V\"", &value[2]);
422 425
          return NGX_CONF_ERROR;
423 426
      }
@@ -454,12 +457,12 @@ index 5f356c3..78589f1 100644
454 457
  
455 458
      if (llcf->logs == NULL) {
456 459
          llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
457  
-@@ -880,35 +930,48 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
  460
+@@ -880,35 +933,48 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
458 461
  
459 462
      ngx_memzero(log, sizeof(ngx_http_log_t));
460 463
  
461 464
 -    n = ngx_http_script_variables_count(&value[1]);
462  
--
  465
+ 
463 466
 -    if (n == 0) {
464 467
 -        log->file = ngx_conf_open_file(cf->cycle, &value[1]);
465 468
 -        if (log->file == NULL) {
@@ -470,13 +473,13 @@ index 5f356c3..78589f1 100644
470 473
 -        if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
471 474
 -            return NGX_CONF_ERROR;
472 475
 -        }
  476
++    log->syslog_on = syslog_on;
473 477
  
474 478
 -        log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
475 479
 -        if (log->script == NULL) {
476 480
 -            return NGX_CONF_ERROR;
477 481
 -        }
478  
-+    log->syslog_on = syslog_on;
479  
- 
  482
+-
480 483
 -        ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
481 484
 +    if (priority.len == 0) {
482 485
 +        log->priority = HTTP_SYSLOG_PRIORITY;

0 notes on commit 0696171

Please sign in to comment.
Something went wrong with that request. Please try again.