Skip to content

Commit

Permalink
fix a bug of segment fault
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoweibin committed May 3, 2011
1 parent 3de3cbf commit 0696171
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions syslog_0.8.54.patch
Expand Up @@ -13,7 +13,7 @@ index 357c6b2..9540367 100644


cycle->conf_prefix.len = old_cycle->conf_prefix.len; cycle->conf_prefix.len = old_cycle->conf_prefix.len;
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index c0485c6..c551248 100644 index c0485c6..c207fe6 100644
--- a/src/core/ngx_log.c --- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c +++ b/src/core/ngx_log.c
@@ -9,6 +9,14 @@ @@ -9,6 +9,14 @@
Expand Down Expand Up @@ -132,7 +132,7 @@ index c0485c6..c551248 100644
+ /* Don't send the debug info to syslog */ + /* Don't send the debug info to syslog */
+ if (log->syslog_on && level < NGX_LOG_DEBUG) { + if (log->syslog_on && level < NGX_LOG_DEBUG) {
+ /* write to syslog */ + /* write to syslog */
+ syslog(log->priority, "%.*s", p - errstr, errstr_syslog); + syslog(log->priority, "%.*s", p - errstr_syslog, errstr_syslog);
+ } + }


if (!ngx_use_stderr if (!ngx_use_stderr
Expand Down Expand Up @@ -339,7 +339,7 @@ index 1054836..f280956 100644
void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...); 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, ...); void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index 5f356c3..78589f1 100644 index 5f356c3..fa021c5 100644
--- a/src/http/modules/ngx_http_log_module.c --- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c
@@ -8,6 +8,9 @@ @@ -8,6 +8,9 @@
Expand All @@ -362,7 +362,7 @@ index 5f356c3..78589f1 100644
} ngx_http_log_t; } ngx_http_log_t;




@@ -312,13 +318,22 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, @@ -312,13 +318,25 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
{ {
u_char *name; u_char *name;
time_t now; time_t now;
Expand All @@ -384,11 +384,14 @@ index 5f356c3..78589f1 100644
+ name = log->file->name.data; + name = log->file->name.data;
+ if (name != NULL) { + if (name != NULL) {
+ n = ngx_write_fd(log->file->fd, buf, len); + n = ngx_write_fd(log->file->fd, buf, len);
+ }
+ else {
+ n = len;
+ } + }
} else { } else {
name = NULL; name = NULL;
n = ngx_http_log_script_write(r, log->script, &name, buf, len); n = ngx_http_log_script_write(r, log->script, &name, buf, len);
@@ -827,6 +842,9 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) @@ -827,6 +845,9 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
log->disk_full_time = 0; log->disk_full_time = 0;
log->error_log_time = 0; log->error_log_time = 0;


Expand All @@ -398,7 +401,7 @@ index 5f356c3..78589f1 100644
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
fmt = lmcf->formats.elts; fmt = lmcf->formats.elts;


@@ -843,14 +861,16 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) @@ -843,14 +864,16 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{ {
ngx_http_log_loc_conf_t *llcf = conf; ngx_http_log_loc_conf_t *llcf = conf;


Expand All @@ -417,7 +420,7 @@ index 5f356c3..78589f1 100644
value = cf->args->elts; value = cf->args->elts;


if (ngx_strcmp(value[1].data, "off") == 0) { if (ngx_strcmp(value[1].data, "off") == 0) {
@@ -863,6 +883,36 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) @@ -863,6 +886,36 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
"invalid parameter \"%V\"", &value[2]); "invalid parameter \"%V\"", &value[2]);
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
Expand Down Expand Up @@ -454,12 +457,12 @@ index 5f356c3..78589f1 100644


if (llcf->logs == NULL) { if (llcf->logs == NULL) {
llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
@@ -880,35 +930,48 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) @@ -880,35 +933,48 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)


ngx_memzero(log, sizeof(ngx_http_log_t)); ngx_memzero(log, sizeof(ngx_http_log_t));


- n = ngx_http_script_variables_count(&value[1]); - n = ngx_http_script_variables_count(&value[1]);
-
- if (n == 0) { - if (n == 0) {
- log->file = ngx_conf_open_file(cf->cycle, &value[1]); - log->file = ngx_conf_open_file(cf->cycle, &value[1]);
- if (log->file == NULL) { - if (log->file == NULL) {
Expand All @@ -470,13 +473,13 @@ index 5f356c3..78589f1 100644
- if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { - if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
- return NGX_CONF_ERROR; - return NGX_CONF_ERROR;
- } - }
+ log->syslog_on = syslog_on;


- log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t)); - log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
- if (log->script == NULL) { - if (log->script == NULL) {
- return NGX_CONF_ERROR; - return NGX_CONF_ERROR;
- } - }
+ log->syslog_on = syslog_on; -

- ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); - ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
+ if (priority.len == 0) { + if (priority.len == 0) {
+ log->priority = HTTP_SYSLOG_PRIORITY; + log->priority = HTTP_SYSLOG_PRIORITY;
Expand Down

0 comments on commit 0696171

Please sign in to comment.