]> granicus.if.org Git - apache/commitdiff
Change behaviour of worker sharing.
authorRainer Jung <rjung@apache.org>
Sun, 22 Aug 2010 09:47:29 +0000 (09:47 +0000)
committerRainer Jung <rjung@apache.org>
Sun, 22 Aug 2010 09:47:29 +0000 (09:47 +0000)
A proxy worker is shared, if its URL is a leading substring
of the URL of another worker defined later in the configuration.

Before this change this
- triggered the "worker ... already used by another worker" message
- resulted in a hard to understand configuration for this worker
  - Attributes explicitely given in the later worker overwrote
    attributes in the worker which was defined first
  - General proxy attributes (e.g. ProxyTimeout ) overwrote
    attributes in the worker which was defined first

New behaviour:
- Talk about "sharing" of workers and log both worker URLs
  in the info log message instead of the "already used" message
- Do not overwrite attributes. If attributes were explicitely
  given in the later worker, log a warning that those are ignored
  because of sharing.

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

modules/proxy/mod_proxy.c

index 938b20223db1cea7c6297d73beffd83ff73beb99..d8d712def49d77dcce5a0e20dc31da5880c02ee5 100644 (file)
@@ -1395,21 +1395,30 @@ static const char *
     }
     else {
         proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, conf, r);
+        int reuse = 0;
         if (!worker) {
             const char *err = ap_proxy_add_worker(&worker, cmd->pool, conf, r);
             if (err)
                 return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
+            PROXY_COPY_CONF_PARAMS(worker, conf);
         } else {
+            reuse = 1;
             ap_log_error(APLOG_MARK, APLOG_INFO, 0, cmd->server,
-                         "worker %s already used by another worker", worker->name);
+                         "Sharing worker '%s' instead of creating new worker '%s'",
+                         worker->name, new->real);
         }
-        PROXY_COPY_CONF_PARAMS(worker, conf);
 
         for (i = 0; i < arr->nelts; i++) {
-            const char *err = set_worker_param(cmd->pool, worker, elts[i].key,
-                                               elts[i].val);
-            if (err)
-                return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
+            if (reuse) {
+                ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
+                             "Ignoring parameter '%s=%s' for worker '%s' because of worker sharing",
+                             elts[i].key, elts[i].val, worker->name);
+            } else {
+                const char *err = set_worker_param(cmd->pool, worker, elts[i].key,
+                                                   elts[i].val);
+                if (err)
+                    return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
+            }
         }
     }
     return NULL;
@@ -1756,6 +1765,7 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
     apr_table_t *params = apr_table_make(cmd->pool, 5);
     const apr_array_header_t *arr;
     const apr_table_entry_t *elts;
+    int reuse = 0;
     int i;
 
     if (cmd->path)
@@ -1796,19 +1806,27 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
         const char *err;
         if ((err = ap_proxy_add_worker(&worker, cmd->pool, conf, name)) != NULL)
             return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
+        PROXY_COPY_CONF_PARAMS(worker, conf);
     } else {
+        reuse = 1;
         ap_log_error(APLOG_MARK, APLOG_INFO, 0, cmd->server,
-                     "worker %s already used by another worker", worker->name);
+                     "Sharing worker '%s' instead of creating new worker '%s'",
+                     worker->name, name);
     }
-    PROXY_COPY_CONF_PARAMS(worker, conf);
 
     arr = apr_table_elts(params);
     elts = (const apr_table_entry_t *)arr->elts;
     for (i = 0; i < arr->nelts; i++) {
-        const char *err = set_worker_param(cmd->pool, worker, elts[i].key,
-                                           elts[i].val);
-        if (err)
-            return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
+        if (reuse) {
+            ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
+                         "Ignoring parameter '%s=%s' for worker '%s' because of worker sharing",
+                         elts[i].key, elts[i].val, worker->name);
+        } else {
+            const char *err = set_worker_param(cmd->pool, worker, elts[i].key,
+                                               elts[i].val);
+            if (err)
+                return apr_pstrcat(cmd->temp_pool, "BalancerMember ", err, NULL);
+        }
     }
     /* Try to find the balancer */
     balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, path);