httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r891230 - in /httpd/httpd/trunk: CHANGES modules/proxy/mod_proxy_balancer.c
Date Wed, 16 Dec 2009 13:24:51 GMT
Author: rjung
Date: Wed Dec 16 13:24:51 2009
New Revision: 891230

URL: http://svn.apache.org/viewvc?rev=891230&view=rev
Log:
Fix crash in balancer-manager.

This was due to an incomplete refactoring in
r771940 (switching balancer->workers to an
array of pointers).

It's likely that other balancer functionality
was broken too.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=891230&r1=891229&r2=891230&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Wed Dec 16 13:24:51 2009
@@ -2,6 +2,8 @@
 
 Changes with Apache 2.3.5
 
+  *) mod_proxy_balancer: Fix crash in balancer-manager. [Rainer Jung]
+
   *) mod_headers: Ensure that changes to the main request remain valid when
      the subrequest is destroyed. PR 48359 [Nick Kew, Ruediger Pluem]
 

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=891230&r1=891229&r2=891230&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Wed Dec 16 13:24:51 2009
@@ -197,12 +197,14 @@
     int checking_standby;
     int checked_standby;
     
+    proxy_worker **workers;
     proxy_worker *worker;
 
     checking_standby = checked_standby = 0;
     while (!checked_standby) {
-        worker = (proxy_worker *)balancer->workers->elts;
-        for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+        workers = (proxy_worker **)balancer->workers->elts;
+        for (i = 0; i < balancer->workers->nelts; i++, workers++) {
+            worker = *workers;
             if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker))
)
                 continue;
             if (*(worker->s->route) && strcmp(worker->s->route, route)
== 0) {
@@ -470,13 +472,13 @@
     runtime = find_session_route(*balancer, r, &route, &sticky, url);
     if (runtime) {
         int i, total_factor = 0;
-        proxy_worker *workers;
+        proxy_worker **workers;
         /* We have a sticky load balancer
          * Update the workers status
          * so that even session routes get
          * into account.
          */
-        workers = (proxy_worker *)(*balancer)->workers->elts;
+        workers = (proxy_worker **)(*balancer)->workers->elts;
         for (i = 0; i < (*balancer)->workers->nelts; i++) {
             /* Take into calculation only the workers that are
              * not in error state or not disabled.
@@ -484,9 +486,9 @@
              * TODO: Abstract the below, since this is dependent
              *       on the LB implementation
              */
-            if (PROXY_WORKER_IS_USABLE(workers)) {
-                workers->s->lbstatus += workers->s->lbfactor;
-                total_factor += workers->s->lbfactor;
+            if (PROXY_WORKER_IS_USABLE(*workers)) {
+                (*workers)->s->lbstatus += (*workers)->s->lbfactor;
+                total_factor += (*workers)->s->lbfactor;
             }
             workers++;
         }
@@ -497,15 +499,15 @@
     }
     else if (route && (*balancer)->sticky_force) {
         int i, member_of = 0;
-        proxy_worker *workers;
+        proxy_worker **workers;
         /*
          * We have a route provided that doesn't match the
          * balancer name. See if the provider route is the
          * member of the same balancer in which case return 503
          */
-        workers = (proxy_worker *)(*balancer)->workers->elts;
+        workers = (proxy_worker **)(*balancer)->workers->elts;
         for (i = 0; i < (*balancer)->workers->nelts; i++) {
-            if (*(workers->s->route) && strcmp(workers->s->route, route)
== 0) {
+            if (*((*workers)->s->route) && strcmp((*workers)->s->route,
route) == 0) {
                 member_of = 1;
                 break;
             }
@@ -630,21 +632,21 @@
 static void recalc_factors(proxy_balancer *balancer)
 {
     int i;
-    proxy_worker *workers;
+    proxy_worker **workers;
 
 
     /* Recalculate lbfactors */
-    workers = (proxy_worker *)balancer->workers->elts;
+    workers = (proxy_worker **)balancer->workers->elts;
     /* Special case if there is only one worker it's
      * load factor will always be 1
      */
     if (balancer->workers->nelts == 1) {
-        workers->s->lbstatus = workers->s->lbfactor = 1;
+        (*workers)->s->lbstatus = (*workers)->s->lbfactor = 1;
         return;
     }
     for (i = 0; i < balancer->workers->nelts; i++) {
         /* Update the status entries */
-        workers[i].s->lbstatus = workers[i].s->lbfactor;
+        workers[i]->s->lbstatus = workers[i]->s->lbfactor;
     }
 }
 
@@ -682,6 +684,7 @@
         ap_get_module_config(sconf, &proxy_module);
     proxy_balancer *balancer, *bsel = NULL;
     proxy_worker *worker, *wsel = NULL;
+    proxy_worker **workers = NULL;
     apr_table_t *params = apr_table_make(r->pool, 10);
     int access_status;
     int i, n;
@@ -731,13 +734,14 @@
 
         ws = ap_proxy_get_worker(r->pool, conf, name);
         if (bsel && ws) {
-            worker = (proxy_worker *)bsel->workers->elts;
+            workers = (proxy_worker **)bsel->workers->elts;
             for (n = 0; n < bsel->workers->nelts; n++) {
+                worker = *workers;
                 if (strcasecmp(worker->name, ws->name) == 0) {
                     wsel = worker;
                     break;
                 }
-                ++worker;
+                ++workers;
             }
         }
     }
@@ -792,8 +796,9 @@
             ap_rputs("    <httpd:balancer>\n", r);
             ap_rvputs(r, "      <httpd:name>", balancer->name, "</httpd:name>\n",
NULL);
             ap_rputs("      <httpd:workers>\n", r);
-            worker = (proxy_worker *)balancer->workers->elts;
+            workers = (proxy_worker **)balancer->workers->elts;
             for (n = 0; n < balancer->workers->nelts; n++) {
+                worker = *workers;
                 ap_rputs("        <httpd:worker>\n", r);
                 ap_rvputs(r, "          <httpd:scheme>", worker->scheme,
                           "</httpd:scheme>\n", NULL);
@@ -802,7 +807,7 @@
                ap_rprintf(r, "          <httpd:loadfactor>%d</httpd:loadfactor>\n",
                           worker->s->lbfactor);
                 ap_rputs("        </httpd:worker>\n", r);
-                ++worker;
+                ++workers;
             }
             ap_rputs("      </httpd:workers>\n", r);
             ap_rputs("    </httpd:balancer>\n", r);
@@ -854,9 +859,10 @@
                 "<th>Elected</th><th>To</th><th>From</th>"
                 "</tr>\n", r);
 
-            worker = (proxy_worker *)balancer->workers->elts;
+            workers = (proxy_worker **)balancer->workers->elts;
             for (n = 0; n < balancer->workers->nelts; n++) {
                 char fbuf[50];
+                worker = *workers;
                 ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=",
                           balancer->name + sizeof("balancer://") - 1, "&w=",
                           ap_escape_uri(r->pool, worker->name),
@@ -888,7 +894,7 @@
                 ap_rputs(apr_strfsize(worker->s->read, fbuf), r);
                 ap_rputs("</td></tr>\n", r);
 
-                ++worker;
+                ++workers;
             }
             ap_rputs("</table>\n", r);
             ++balancer;



Mime
View raw message