diff src/http/modules/proxy/ngx_http_proxy_cache.c @ 189:c966c09be66b

nginx-0.0.1-2003-11-18-19:49:00 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 18 Nov 2003 16:49:00 +0000
parents c1f3a3c7c5db
children 02a715e85df1
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_cache.c
+++ b/src/http/modules/proxy/ngx_http_proxy_cache.c
@@ -283,8 +283,28 @@ void ngx_http_proxy_cache_busy_lock(ngx_
         p->cache->ctx.file.info_valid = 1;
     }
 
+    if (rc == NGX_AGAIN) {
 
-    if (rc == NGX_AGAIN) {
+        if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT))
+            && !p->request->connection->write->active)
+        {
+            /*
+             * kqueue allows to detect when client closes prematurely
+             * connection
+             */
+
+            p->request->connection->write->event_handler =
+                                        ngx_http_proxy_check_broken_connection;
+
+            if (ngx_add_event(p->request->connection->write, NGX_WRITE_EVENT,
+                                                NGX_CLEAR_EVENT) == NGX_ERROR)
+            {
+                ngx_http_proxy_finalize_request(p,
+                                                NGX_HTTP_INTERNAL_SERVER_ERROR);
+                return;
+            }
+        }
+
         return;
     }