nginx-0.0.1-2003-11-21-09:30:49 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_parse.c b/src/http/modules/proxy/ngx_http_proxy_parse.c
index 1729542..a697958 100644
--- a/src/http/modules/proxy/ngx_http_proxy_parse.c
+++ b/src/http/modules/proxy/ngx_http_proxy_parse.c
@@ -185,6 +185,10 @@
                 return NGX_HTTP_PROXY_PARSE_NO_HEADER;
             }
             break;
+
+        /* suppress warning */
+        case sw_done:
+            break;
         }
     }
 
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 9d442cd..1b1ca44 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -936,6 +936,14 @@
 
     p->header_sent = 1;
 
+    if (p->cache && p->cache->ctx.file.fd != NGX_INVALID_FILE) {
+        if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) {
+            ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
+                          ngx_close_file_n " \"%s\" failed",
+                          p->cache->ctx.file.name.data);
+        }
+    }
+
     if (p->cachable) {
         header = (ngx_http_cache_header_t *) p->header_in->start;
 
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index e06198e..086e57d 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -662,7 +662,7 @@
         return rv;
     }
 
-    ngx_qsort(cscf->locations.elts, cscf->locations.nelts,
+    ngx_qsort(cscf->locations.elts, (size_t) cscf->locations.nelts,
               sizeof(void *), ngx_cmp_locations);
 
     return rv;
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index fa037dd..07da10d 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -392,6 +392,10 @@
                 return NGX_HTTP_PARSE_INVALID_REQUEST;
             }
             break;
+
+        /* suppress warning */
+        case sw_done:
+            break;
         }
     }
 
@@ -595,6 +599,11 @@
                 return NGX_HTTP_PARSE_INVALID_HEADER;
             }
             break;
+
+        /* suppress warning */
+        case sw_done:
+        case sw_header_done:
+            break;
         }
     }
 
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index ccaa73f..1a6485f 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1116,10 +1116,20 @@
     wev = c->write;
     wev->event_handler = ngx_http_empty_handler;
 
-    if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && wev->active) {
-        if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
-            ngx_http_close_connection(c);
-            return;
+    if (wev->active) {
+        if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+            if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
+                                                                  == NGX_ERROR)
+            {
+                ngx_http_close_connection(c);
+                return;
+            }
+
+        } else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
+            if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
+                ngx_http_close_connection(c);
+                return;
+            }
         }
     }
 
@@ -1218,11 +1228,20 @@
     wev = c->write;
     wev->event_handler = ngx_http_empty_handler;
 
-    if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && wev->active) {
-        if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
-            ngx_http_close_request(r, 0);
-            ngx_http_close_connection(c);
-            return;
+    if (wev->active) {
+        if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+            if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
+                                                                  == NGX_ERROR)
+            {
+                ngx_http_close_connection(c);
+                return;
+            }
+
+        } else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
+            if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
+                ngx_http_close_connection(c);
+                return;
+            }
         }
     }