diff src/http/ngx_http_script.c @ 430:dac47e9ef0d5 NGINX_0_7_27

nginx 0.7.27 *) Feature: the "try_files" directive. *) Feature: variables support in the "fastcgi_pass" directive. *) Feature: now the $geo variable may get an address from a variable. Thanks to Andrei Nigmatulin. *) Feature: now a location's modifier may be used without space before name. *) Feature: the $upstream_response_length variable. *) Bugfix: now a "add_header" directive does not add an empty value. *) Bugfix: if zero length static file was requested, then nginx just closed connection; the bug had appeared in 0.7.25. *) Bugfix: a MOVE method could not move file in non-existent directory. *) Bugfix: a segmentation fault occurred in worker process, if no one named location was defined in server, but some one was used in an error_page directive. Thanks to Sergey Bochenkov.
author Igor Sysoev <http://sysoev.ru>
date Mon, 15 Dec 2008 00:00:00 +0300
parents a094317ba307
children 33394d1255b0
line wrap: on
line diff
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -430,20 +430,23 @@ ngx_http_script_copy_len_code(ngx_http_s
 void
 ngx_http_script_copy_code(ngx_http_script_engine_t *e)
 {
+    u_char                       *p;
     ngx_http_script_copy_code_t  *code;
 
     code = (ngx_http_script_copy_code_t *) e->ip;
 
+    p = e->pos;
+
     if (!e->skip) {
-        e->pos = ngx_copy(e->pos, e->ip + sizeof(ngx_http_script_copy_code_t),
+        e->pos = ngx_copy(p, e->ip + sizeof(ngx_http_script_copy_code_t),
                           code->len);
     }
 
     e->ip += sizeof(ngx_http_script_copy_code_t)
           + ((code->len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1));
 
-    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
-                   "http script copy: \"%V\"", &e->buf);
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
+                   "http script copy: \"%*s\"", e->pos - p, p);
 }
 
 
@@ -475,6 +478,7 @@ ngx_http_script_copy_var_len_code(ngx_ht
 void
 ngx_http_script_copy_var_code(ngx_http_script_engine_t *e)
 {
+    u_char                      *p;
     ngx_http_variable_value_t   *value;
     ngx_http_script_var_code_t  *code;
 
@@ -492,11 +496,12 @@ ngx_http_script_copy_var_code(ngx_http_s
         }
 
         if (value && !value->not_found) {
-            e->pos = ngx_copy(e->pos, value->data, value->len);
+            p = e->pos;
+            e->pos = ngx_copy(p, value->data, value->len);
 
-            ngx_log_debug1(NGX_LOG_DEBUG_HTTP,
+            ngx_log_debug2(NGX_LOG_DEBUG_HTTP,
                            e->request->connection->log, 0,
-                           "http script var: \"%V\"", &e->buf);
+                           "http script var: \"%*s\"", e->pos - p, p);
         }
     }
 }
@@ -532,29 +537,32 @@ ngx_http_script_copy_capture_len_code(ng
 void
 ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e)
 {
+    u_char                               *p;
     ngx_http_script_copy_capture_code_t  *code;
 
     code = (ngx_http_script_copy_capture_code_t *) e->ip;
 
     e->ip += sizeof(ngx_http_script_copy_capture_code_t);
 
+    p = e->pos;
+
     if (code->n < e->ncaptures) {
         if ((e->is_args || e->quote)
             && (e->request->quoted_uri || e->request->plus_in_uri))
         {
-            e->pos = (u_char *) ngx_escape_uri(e->pos,
+            e->pos = (u_char *) ngx_escape_uri(p,
                                 &e->line.data[e->captures[code->n]],
                                 e->captures[code->n + 1] - e->captures[code->n],
                                 NGX_ESCAPE_ARGS);
         } else {
-            e->pos = ngx_copy(e->pos,
+            e->pos = ngx_copy(p,
                               &e->line.data[e->captures[code->n]],
                               e->captures[code->n + 1] - e->captures[code->n]);
         }
     }
 
-    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
-                   "http script capture: \"%V\"", &e->buf);
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
+                   "http script capture: \"%*s\"", e->pos - p, p);
 }
 
 
@@ -612,7 +620,7 @@ ngx_http_script_regex_start_code(ngx_htt
     rc = ngx_regex_exec(code->regex, &e->line, e->captures, code->ncaptures);
 
     if (rc == NGX_REGEX_NO_MATCHED) {
-        if (e->log) {
+        if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
             ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
                           "\"%V\" does not match \"%V\"",
                           &code->name, &e->line);
@@ -650,7 +658,7 @@ ngx_http_script_regex_start_code(ngx_htt
         return;
     }
 
-    if (e->log) {
+    if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
         ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
                       "\"%V\" matches \"%V\"", &code->name, &e->line);
     }
@@ -786,7 +794,7 @@ ngx_http_script_regex_end_code(ngx_http_
 
         e->buf.len = e->pos - e->buf.data;
 
-        if (e->log) {
+        if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
             ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
                           "rewritten redirect: \"%V\"", &e->buf);
         }
@@ -828,7 +836,7 @@ ngx_http_script_regex_end_code(ngx_http_
         }
     }
 
-    if (e->log) {
+    if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
         ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
                       "rewritten data: \"%V\", args: \"%V\"",
                       &e->buf, &r->args);
@@ -928,8 +936,8 @@ ngx_http_script_equal_code(ngx_http_scri
 
     e->ip += sizeof(uintptr_t);
 
-    if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len)
-        == 0)
+    if (val->len == res->len
+        && ngx_strncmp(val->data, res->data, res->len) == 0)
     {
         *res = ngx_http_variable_true_value;
         return;
@@ -956,8 +964,8 @@ ngx_http_script_not_equal_code(ngx_http_
 
     e->ip += sizeof(uintptr_t);
 
-    if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len)
-        == 0)
+    if (val->len == res->len
+        && ngx_strncmp(val->data, res->data, res->len) == 0)
     {
         ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
                        "http script not equal: no");
@@ -1163,9 +1171,6 @@ ngx_http_script_set_var_code(ngx_http_sc
     ngx_http_request_t          *r;
     ngx_http_script_var_code_t  *code;
 
-    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
-                   "http script set var");
-
     code = (ngx_http_script_var_code_t *) e->ip;
 
     e->ip += sizeof(ngx_http_script_var_code_t);
@@ -1179,6 +1184,20 @@ ngx_http_script_set_var_code(ngx_http_sc
     r->variables[code->index].no_cacheable = 0;
     r->variables[code->index].not_found = 0;
     r->variables[code->index].data = e->sp->data;
+
+#if (NGX_DEBUG)
+    {
+    ngx_http_variable_t        *v;
+    ngx_http_core_main_conf_t  *cmcf;
+
+    cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+
+    v = cmcf->variables.elts;
+
+    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
+                   "http script set $%V", &v[code->index].name);
+    }
+#endif
 }