]> granicus.if.org Git - apache/blobdiff - server/connection.c
use APR_STATUS_IS_TIMEUP() instead of direct comparison with APR_TIMEUP.
[apache] / server / connection.c
index 0adfb7071d85d26b7d7c62e9912c1d1b85adbeb0..8436ea06e37228ad5b2613407174b95916f2df1a 100644 (file)
@@ -23,7 +23,6 @@
 #include "http_request.h"
 #include "http_protocol.h"
 #include "ap_mpm.h"
-#include "mpm_default.h"
 #include "http_config.h"
 #include "http_core.h"
 #include "http_vhost.h"
@@ -153,8 +152,20 @@ AP_DECLARE(void) ap_lingering_close(conn_rec *c)
             break;
 
         if (timeup == 0) {
-            /* First time through; calculate now + 30 seconds. */
-            timeup = apr_time_now() + apr_time_from_sec(MAX_SECS_TO_LINGER);
+            /*
+             * First time through;
+             * calculate now + 30 seconds (MAX_SECS_TO_LINGER).
+             *
+             * If some module requested a shortened waiting period, only wait for
+             * 2s (SECONDS_TO_LINGER). This is useful for mitigating certain
+             * DoS attacks.
+             */
+            if (apr_table_get(c->notes, "short-lingering-close")) {
+                timeup = apr_time_now() + apr_time_from_sec(SECONDS_TO_LINGER);
+            }
+            else {
+                timeup = apr_time_now() + apr_time_from_sec(MAX_SECS_TO_LINGER);
+            }
             continue;
         }
     } while (apr_time_now() < timeup);