commit b2cbca6b938375619bc761fba56342367f970080
Author: althial@gmx.net
Date:   Mon Feb 11 11:17:33 2013 +0100

    Directive for error marking of worker in case of generic backend error
    
    We ought to mark the worker as "in error" if the backend gives some
    unrecognized error code (like failed DNS resolution). Since that
    might break existing setups it should be configurable.

diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index 431efb8..4d2e6f9 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1098,6 +1098,10 @@ static int proxy_handler(request_rec *r)
             /* Unrecoverable error.
              * Return the origin status code to the client.
              */
+            if (conf->mark_all_errors && balancer) {
+                worker->s->status |= PROXY_WORKER_IN_ERROR;
+                worker->s->error_time = apr_time_now();
+            }
             break;
         }
         /* Try again if the worker is unusable and the service is
@@ -1212,6 +1216,8 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     ps->source_address = (overrides->source_address_set == 0) ? base->source_address : overrides->source_address;
     ps->source_address_set = overrides->source_address_set || base->source_address_set;
     ps->pool = p;
+    ps->mark_all_errors = (overrides->mark_all_errors_set == 0) ? base->mark_all_errors : overrides->mark_all_errors;
+    ps->mark_all_errors_set = (overrides->mark_all_errors_set == 0) ? base->mark_all_errors_set : overrides->mark_all_errors_set;
     return ps;
 }
 static const char *set_source_address(cmd_parms *parms, void *dummy,
@@ -1734,6 +1740,16 @@ static const char *
     conf->preserve_host_set = 1;
     return NULL;
 }
+static const char *
+    set_mark_all_errors(cmd_parms *parms, void *dummy, int flag)
+{
+    proxy_server_conf *psf =
+    ap_get_module_config(parms->server->module_config, &proxy_module);
+
+    psf->mark_all_errors = flag;
+    psf->mark_all_errors_set = 1;
+    return NULL;
+}
 
 static const char *
     set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
@@ -2259,6 +2275,8 @@ static const command_rec proxy_cmds[] =
      "A balancer name and scheme with list of params"),
     AP_INIT_TAKE1("BalancerGrowth", set_bgrowth, NULL, RSRC_CONF,
      "Number of additional Balancers that can be added post-config"),
+    AP_INIT_FLAG("BalancerMarkAllErrors", set_mark_all_errors, NULL, RSRC_CONF|ACCESS_CONF,
+     "Make all server errors flag workers as 'in error'"),
     AP_INIT_TAKE1("ProxyStatus", set_status_opt, NULL, RSRC_CONF,
      "Configure Status: proxy status to one of: on | off | full"),
     AP_INIT_RAW_ARGS("ProxySet", set_proxy_param, NULL, RSRC_CONF|ACCESS_CONF,
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
index 0bce506..18ea5bf 100644
--- a/modules/proxy/mod_proxy.h
+++ b/modules/proxy/mod_proxy.h
@@ -178,6 +178,8 @@ typedef struct {
     unsigned int proxy_status_set:1;
     unsigned int source_address_set:1;
     unsigned int bgrowth_set:1;
+    unsigned int mark_all_errors:1;
+    unsigned int mark_all_errors_set:1;
 } proxy_server_conf;
 
 
