httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r809545 - in /httpd/httpd/branches/httpd-2.2-proxy/modules/proxy: mod_proxy_balancer.c mod_proxy_connect.c mod_proxy_http.c proxy_util.c
Date Mon, 31 Aug 2009 11:41:33 GMT
Author: jim
Date: Mon Aug 31 11:41:33 2009
New Revision: 809545

URL: http://svn.apache.org/viewvc?rev=809545&view=rev
Log:
More trunk backporting

Modified:
    httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_connect.c
    httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_http.c
    httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c

Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c?rev=809545&r1=809544&r2=809545&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c Mon Aug 31 11:41:33
2009
@@ -534,10 +534,15 @@
     if (!*worker) {
         runtime = find_best_worker(*balancer, r);
         if (!runtime) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
-                         "proxy: BALANCER: (%s). All workers are in error state",
-                         (*balancer)->name);
-
+            if ((*balancer)->workers->nelts) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                             "proxy: BALANCER: (%s). All workers are in error state",
+                             (*balancer)->name);
+            } else {
+                 ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                              "proxy: BALANCER: (%s). No workers in balancer",
+                               (*balancer)->name);
+            }
             return HTTP_SERVICE_UNAVAILABLE;
         }
         if ((*balancer)->sticky && runtime) {

Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_connect.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_connect.c?rev=809545&r1=809544&r2=809545&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_connect.c (original)
+++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_connect.c Mon Aug 31 11:41:33
2009
@@ -201,7 +201,7 @@
             return DECLINED;
         }
         else {
-            return HTTP_BAD_GATEWAY;
+            return HTTP_SERVICE_UNAVAILABLE;
         }
     }
 
@@ -270,7 +270,8 @@
     if ((rv = apr_pollset_create(&pollset, 2, r->pool, 0)) != APR_SUCCESS) {
         apr_socket_close(sock);
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-            "proxy: CONNECT: error apr_pollset_create()");
+            "proxy: CONNECT: error apr_pollset_create();"
+            " check system or user limits");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
@@ -280,11 +281,23 @@
     pollfd.reqevents = APR_POLLIN;
     pollfd.desc.s = client_socket;
     pollfd.client_data = NULL;
-    apr_pollset_add(pollset, &pollfd);
+    rv = apr_pollset_add(pollset, &pollfd);
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                     "proxy: CONNECT: error apr_pollset_add();"
+                     " check system or user limits");
+        return HTTP_INTERNAL_SERVER_ERROR;
+    }
 
     /* Add the server side to the poll */
     pollfd.desc.s = sock;
-    apr_pollset_add(pollset, &pollfd);
+    rv = apr_pollset_add(pollset, &pollfd);
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                     "proxy: CONNECT: error apr_pollset_add();"
+                     " check system or user limits");
+        return HTTP_INTERNAL_SERVER_ERROR;
+    }
 
     while (1) { /* Infinite loop until error (one side closes the connection) */
         if ((rv = apr_pollset_poll(pollset, -1, &pollcnt, &signalled)) != APR_SUCCESS)
{

Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_http.c?rev=809545&r1=809544&r2=809545&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_http.c Mon Aug 31 11:41:33
2009
@@ -427,10 +427,15 @@
     apr_off_t bytes_streamed = 0;
 
     if (old_cl_val) {
+        char *endstr;
         add_cl(p, bucket_alloc, header_brigade, old_cl_val);
-        if (APR_SUCCESS != (status = apr_strtoff(&cl_val, old_cl_val, NULL,
-                                                 0))) {
-            return HTTP_INTERNAL_SERVER_ERROR;
+        status = apr_strtoff(&cl_val, old_cl_val, &endstr, 10);
+
+        if (status || *endstr || endstr == old_cl_val || cl_val < 0) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
+                          "proxy: could not parse request Content-Length (%s)",
+                          old_cl_val);
+            return HTTP_BAD_REQUEST;
         }
     }
     terminate_headers(bucket_alloc, header_brigade);
@@ -463,8 +468,13 @@
          *
          * Prevents HTTP Response Splitting.
          */
-        if (bytes_streamed > cl_val)
-             continue;
+        if (bytes_streamed > cl_val) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "proxy: read more bytes of request body than expected "
+                          "(got %" APR_OFF_T_FMT ", expected %" APR_OFF_T_FMT ")",
+                          bytes_streamed, cl_val);
+            return HTTP_INTERNAL_SERVER_ERROR;
+        }
 
         if (header_brigade) {
             /* we never sent the header brigade, so go ahead and
@@ -733,11 +743,20 @@
     e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
     APR_BRIGADE_INSERT_TAIL(header_brigade, e);
     if (conf->preserve_host == 0) {
-        if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
-            buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str,
-                              CRLF, NULL);
+        if (ap_strchr_c(uri->hostname, ':')) { /* if literal IPv6 address */
+            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
+                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]:", 
+                                  uri->port_str, CRLF, NULL);
+            } else {
+                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]", CRLF, NULL);
+            }
         } else {
-            buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
+            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
+                buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str,
+                                  CRLF, NULL);
+            } else {
+                buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
+            }
         }
     }
     else {
@@ -947,7 +966,7 @@
      * encoding has been done by the extensions' handler, and
      * do not modify add_te_chunked's logic
      */
-    if (old_te_val && strcmp(old_te_val, "chunked") != 0) {
+    if (old_te_val && strcasecmp(old_te_val, "chunked") != 0) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
                      "proxy: %s Transfer-Encoding is not supported",
                      old_te_val);

Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c?rev=809545&r1=809544&r2=809545&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c Mon Aug 31 11:41:33 2009
@@ -1785,38 +1785,40 @@
               worker->name);
         return;
     }
-    /* Get scoreboard slot */
-    if (ap_scoreboard_image) {
-        score = (proxy_worker_stat *) ap_get_scoreboard_lb(worker->id);
+    if (!worker->s) {
+        /* Get scoreboard slot */
+        if (ap_scoreboard_image) {
+            score = (proxy_worker_stat *) ap_get_scoreboard_lb(worker->id);
+            if (!score) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+                      "proxy: ap_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT "
for worker %s",
+                      worker->id, getpid(), worker->name);
+            }
+            else {
+                 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+                      "proxy: grabbed scoreboard slot %d in child %" APR_PID_T_FMT " for
worker %s",
+                      worker->id, getpid(), worker->name);
+            }
+        }
         if (!score) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
-                  "proxy: ap_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT " for
worker %s",
-                  worker->id, getpid(), worker->name);
+            score = (proxy_worker_stat *) apr_pcalloc(conf->pool, sizeof(proxy_worker_stat));
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+                  "proxy: initialized plain memory in child %" APR_PID_T_FMT " for worker
%s",
+                  getpid(), worker->name);
         }
-        else {
-             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
-                  "proxy: grabbed scoreboard slot %d in child %" APR_PID_T_FMT " for worker
%s",
-                  worker->id, getpid(), worker->name);
+        worker->s = score;
+        /*
+         * recheck to see if we've already been here. Possible
+         * if proxy is using scoreboard to hold shared stats
+         */
+        if (PROXY_WORKER_IS_INITIALIZED(worker)) {
+            /* The worker share is already initialized */
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+                  "proxy: worker %s already initialized",
+                  worker->name);
+            return;
         }
     }
-    if (!score) {
-        score = (proxy_worker_stat *) apr_pcalloc(conf->pool, sizeof(proxy_worker_stat));
-        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
-              "proxy: initialized plain memory in child %" APR_PID_T_FMT " for worker %s",
-              getpid(), worker->name);
-    }
-    worker->s = score;
-    /*
-     * recheck to see if we've already been here. Possible
-     * if proxy is using scoreboard to hold shared stats
-     */
-    if (PROXY_WORKER_IS_INITIALIZED(worker)) {
-        /* The worker share is already initialized */
-        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
-              "proxy: worker %s already initialized",
-              worker->name);
-        return;
-    }
     if (worker->route) {
         strcpy(worker->s->route, worker->route);
     }



Mime
View raw message