diff src/http/ngx_http_request.c @ 2261:07bf557a2e40

*) log_subrequest *) flush variables in access log
author Igor Sysoev <igor@sysoev.ru>
date Sat, 27 Sep 2008 15:08:02 +0000
parents 8c17cfe63d2c
children c31f46332e80
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -47,6 +47,7 @@ static void ngx_http_lingering_close_han
 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r);
 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error);
 static void ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error);
+static void ngx_http_log_request(ngx_http_request_t *r);
 static void ngx_http_close_connection(ngx_connection_t *c);
 
 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len);
@@ -1774,6 +1775,8 @@ ngx_http_finalize_request(ngx_http_reque
         return;
     }
 
+    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
     if (r != r->main) {
 
         pr = r->parent;
@@ -1807,6 +1810,11 @@ ngx_http_finalize_request(ngx_http_reque
                 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                                "http fast subrequest: \"%V?%V\" done",
                                &r->uri, &r->args);
+
+                if (clcf->log_subrequest) {
+                    ngx_http_log_request(r);
+                }
+
                 return;
             }
 
@@ -1819,6 +1827,10 @@ ngx_http_finalize_request(ngx_http_reque
             }
         }
 
+        if (clcf->log_subrequest) {
+            ngx_http_log_request(r);
+        }
+
         return;
     }
 
@@ -1857,8 +1869,6 @@ ngx_http_finalize_request(ngx_http_reque
         return;
     }
 
-    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
     if (!ngx_terminate
          && !ngx_exiting
          && r->keepalive
@@ -2604,14 +2614,11 @@ ngx_http_close_request(ngx_http_request_
 static void
 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
 {
-    ngx_log_t                  *log;
-    ngx_uint_t                  i, n;
-    struct linger               linger;
-    ngx_http_cleanup_t         *cln;
-    ngx_http_log_ctx_t         *ctx;
-    ngx_http_handler_pt        *log_handler;
-    ngx_http_core_loc_conf_t   *clcf;
-    ngx_http_core_main_conf_t  *cmcf;
+    ngx_log_t                 *log;
+    struct linger              linger;
+    ngx_http_cleanup_t        *cln;
+    ngx_http_log_ctx_t        *ctx;
+    ngx_http_core_loc_conf_t  *clcf;
 
     log = r->connection->log;
 
@@ -2646,13 +2653,7 @@ ngx_http_request_done(ngx_http_request_t
 
     log->action = "logging request";
 
-    cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
-
-    log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
-    n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
-    for (i = 0; i < n; i++) {
-        log_handler[i](r);
-    }
+    ngx_http_log_request(r);
 
     log->action = "closing request";
 
@@ -2685,6 +2686,24 @@ ngx_http_request_done(ngx_http_request_t
 
 
 static void
+ngx_http_log_request(ngx_http_request_t *r)
+{
+    ngx_uint_t                  i, n;
+    ngx_http_handler_pt        *log_handler;
+    ngx_http_core_main_conf_t  *cmcf;
+
+    cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+
+    log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
+    n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
+
+    for (i = 0; i < n; i++) {
+        log_handler[i](r);
+    }
+}
+
+
+static void
 ngx_http_close_connection(ngx_connection_t *c)
 {
     ngx_pool_t  *pool;