diff src/http/ngx_http_request.c @ 427:0d08eabe5c7b

nginx-0.0.10-2004-09-15-20:00:43 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 15 Sep 2004 16:00:43 +0000
parents 3f88935a02e8
children 694cd6cdb714
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -97,10 +97,6 @@ void ngx_http_init_connection(ngx_connec
     ngx_event_t         *rev;
     ngx_http_log_ctx_t  *ctx;
 
-#if (NGX_STAT_STUB)
-    (*ngx_stat_reading)++;
-#endif
-
     if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
         ngx_http_close_connection(c);
         return;
@@ -133,6 +129,10 @@ void ngx_http_init_connection(ngx_connec
             return;
         }
 
+#if (NGX_STAT_STUB)
+        (*ngx_stat_reading)++;
+#endif
+
         ngx_http_init_request(rev);
         return;
     }
@@ -155,6 +155,11 @@ void ngx_http_init_connection(ngx_connec
         return;
     }
 #endif
+
+#if (NGX_STAT_STUB)
+    (*ngx_stat_reading)++;
+#endif
+
 }
 
 
@@ -178,6 +183,11 @@ static void ngx_http_init_request(ngx_ev
 
     if (rev->timedout) {
         ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
+
+#if (NGX_STAT_STUB)
+        (*ngx_stat_reading)--;
+#endif
+
         ngx_http_close_connection(c);
         return;
     }
@@ -186,8 +196,17 @@ static void ngx_http_init_request(ngx_ev
         r = c->data;
         ngx_memzero(r, sizeof(ngx_http_request_t));
 
+#if (NGX_STAT_STUB)
+        (*ngx_stat_reading)++;
+#endif
+
     } else {
         if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
+
+#if (NGX_STAT_STUB)
+            (*ngx_stat_reading)--;
+#endif
+
             ngx_http_close_connection(c);
             return;
         }
@@ -195,6 +214,10 @@ static void ngx_http_init_request(ngx_ev
         c->data = r;
     }
 
+#if (NGX_STAT_STUB)
+    r->stat_reading = 1;
+#endif
+
     c->sent = 0;
     r->signature = NGX_HTTP_MODULE;
 
@@ -869,7 +892,9 @@ static void ngx_http_process_request_hea
 
 #if (NGX_STAT_STUB)
             (*ngx_stat_reading)--;
+            r->stat_reading = 0;
             (*ngx_stat_writing)++;
+            r->stat_writing = 1;
 #endif
 
             rev->event_handler = ngx_http_block_read;
@@ -1118,6 +1143,12 @@ static ngx_int_t ngx_http_process_reques
             ngx_ssl_set_nosendshut(r->connection->ssl);
 #endif
         }
+
+        if (ngx_strstr(r->headers_in.user_agent->value.data, "Opera")) {
+            r->headers_in.opera = 1;
+            r->headers_in.msie = 0;
+            r->headers_in.msie4 = 0;
+        }
     }
 
     return NGX_OK;
@@ -1148,11 +1179,6 @@ void ngx_http_finalize_request(ngx_http_
         }
 
         if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
-
-#if (NGX_STAT_STUB)
-            (*ngx_stat_writing)--;
-#endif
-
             ngx_http_close_request(r, 0);
             ngx_http_close_connection(r->connection);
             return;
@@ -1163,11 +1189,6 @@ void ngx_http_finalize_request(ngx_http_
         return;
 
     } else if (rc == NGX_ERROR) {
-
-#if (NGX_STAT_STUB)
-        (*ngx_stat_writing)--;
-#endif
-
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
         return;
@@ -1177,10 +1198,6 @@ void ngx_http_finalize_request(ngx_http_
         return;
     }
 
-#if (NGX_STAT_STUB)
-    (*ngx_stat_writing)--;
-#endif
-
     if (r->connection->read->timer_set) {
         ngx_del_timer(r->connection->read);
     }
@@ -1800,6 +1817,16 @@ void ngx_http_close_request(ngx_http_req
         return;
     }
 
+#if (NGX_STAT_STUB)
+    if (r->stat_reading) {
+        (*ngx_stat_reading)--;
+    }
+
+    if (r->stat_writing) {
+        (*ngx_stat_writing)--;
+    }
+#endif
+
     if (error && r->headers_out.status == 0) {
         r->headers_out.status = error;
     }