]> granicus.if.org Git - apache/commitdiff
* Make the connection timeout to backends work by temporarily setting the
authorRuediger Pluem <rpluem@apache.org>
Mon, 13 Oct 2008 10:06:28 +0000 (10:06 +0000)
committerRuediger Pluem <rpluem@apache.org>
Mon, 13 Oct 2008 10:06:28 +0000 (10:06 +0000)
  socket to non blocking mode.

Submitted by: Matt Stevenson <mavricknzwork yahoo.com>
Reviewed by: rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@703998 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 88bdf81ab3de9b5146a79c033b766d49282941db..784d4bcd9e89f97aab2e21aba2e85963fb2d69fe 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) mod_proxy: Make the connection timeout to backends work by temporarily
+     setting the socket to non blocking mode.
+     [Matt Stevenson <mavricknzwork yahoo.com>]
+
   *) Worker MPM: Crosscheck that idle workers are still available before using
      them and thus preventing an overflow of the worker queue which causes
      a SegFault. PR 45605 [Denis Ustimenko <denusk gmail.com>]
index 1a150eafdd0a14d16784f9c97ee194935c39974b..825fd728fa3eb9baf7b08fdab1eeb9e41e558c30 100644 (file)
@@ -2358,6 +2358,17 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
                      "proxy: %s: fam %d socket created to connect to %s",
                      proxy_function, backend_addr->family, worker->hostname);
 
+        /*
+         * Temporarily set the socket to non blocking to make connection
+         * timeouts (set via connectiontimeout) work.
+         */
+        if ((rv = apr_socket_opt_set(newsock, APR_SO_NONBLOCK, 1))
+            != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+                         "apr_socket_opt_set(SO_NONBLOCK): Failed to set"
+                         " the socket to non blocking mode");
+        }
+
         /* make the connection out of the socket */
         rv = apr_socket_connect(newsock, backend_addr);
 
@@ -2374,6 +2385,13 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
             continue;
         }
 
+        if ((rv = apr_socket_opt_set(newsock, APR_SO_NONBLOCK, 0))
+            != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+                         "apr_socket_opt_set(SO_NONBLOCK): Failed to set"
+                         " the socket to blocking mode");
+        }
+
         /* Set a timeout on the socket */
         if (worker->timeout_set == 1) {
             apr_socket_timeout_set(newsock, worker->timeout);