diff src/http/ngx_http_request.c @ 346:55e496a8ece3

nginx-0.0.3-2004-06-06-23:49:18 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 06 Jun 2004 19:49:18 +0000
parents e366ba5db8f8
children 2e3cbc1bbe3c
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -90,7 +90,7 @@ void ngx_http_init_connection(ngx_connec
     /* STUB: epoll edge */ c->write->event_handler = ngx_http_empty_handler;
 
     if (rev->ready) {
-        /* deferred accept, aio, iocp */
+        /* the deferred accept(), rtsig, aio, iocp */
 
         if (ngx_accept_mutex) {
             if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
@@ -1542,10 +1542,12 @@ int ngx_http_send_last(ngx_http_request_
 
 void ngx_http_close_request(ngx_http_request_t *r, int error)
 {
-    ngx_uint_t           i;
-    ngx_log_t           *log;
-    ngx_http_log_ctx_t  *ctx;
-    ngx_http_cleanup_t  *cleanup;
+    ngx_uint_t                 i;
+    ngx_log_t                 *log;
+    ngx_http_log_ctx_t        *ctx;
+    ngx_http_cleanup_t        *cleanup;
+    ngx_http_core_loc_conf_t  *clcf;
+    struct linger              l;
 
     log = r->connection->log;
 
@@ -1610,6 +1612,22 @@ void ngx_http_close_request(ngx_http_req
         }
     }
 
+    if (r->connection->timedout) {
+        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+        if (clcf->reset_timedout_connection) {
+            l.l_onoff = 1;
+            l.l_linger = 0;
+
+            if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER,
+                           (const void *) &l, sizeof(struct linger)) == -1)
+            {
+                ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
+                              "setsockopt(SO_LINGER) failed");
+            }
+        }
+    }
+
     /* ctx->url was allocated from r->pool */
     ctx = log->data;
     ctx->url = NULL;
@@ -1676,6 +1694,7 @@ static void ngx_http_client_error(ngx_ht
     if (error == NGX_HTTP_REQUEST_TIME_OUT) {
         ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
                       "client timed out");
+        r->connection->timedout = 1;
         ngx_http_close_request(r, error);
         ngx_http_close_connection(r->connection);
         return;