]> granicus.if.org Git - apache/commitdiff
Just like for balancers initialize the workers on post_config
authorMladen Turk <mturk@apache.org>
Fri, 10 Sep 2004 18:29:16 +0000 (18:29 +0000)
committerMladen Turk <mturk@apache.org>
Fri, 10 Sep 2004 18:29:16 +0000 (18:29 +0000)
instead on first request to skip the race condition.

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

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c

index ac9622390bb76c50b83247ceb8d6439d3c269e81..e8c8e7081fe605acc32f354cf1806d4c1eb16bf5 100644 (file)
@@ -1349,7 +1349,6 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
     }
     /* Add the worker to the load balancer */
     ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);
-
     return NULL;
 }
 
@@ -1596,9 +1595,21 @@ PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c)
 static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                              apr_pool_t *ptemp, server_rec *s)
 {
+    proxy_server_conf *conf =
+    (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
+    proxy_worker *worker;
+    int i;
+
     proxy_ssl_enable = APR_RETRIEVE_OPTIONAL_FN(ssl_proxy_enable);
     proxy_ssl_disable = APR_RETRIEVE_OPTIONAL_FN(ssl_engine_disable);
 
+    /* Initialize all the workers */
+    worker = (proxy_worker *)conf->workers->elts;
+    for (i = 0; i < conf->workers->nelts; i++) {
+        ap_proxy_initialize_worker(worker, s);
+        worker++;
+    }
+
     return OK;
 }
 
index 17fe6d0bfcc1843ffcdf5a82cfd5aefc39bb180a..f2ebe9adc92f92d74d2992785c87215c7b668693 100644 (file)
@@ -282,7 +282,6 @@ typedef struct {
 } proxy_runtime_worker;
 
 struct proxy_balancer {
-    int                status;
     apr_array_header_t *workers; /* array of proxy_runtime_workers */
     const char *name;            /* name of the load balancer */
     const char *sticky;          /* sticky session identifier */
@@ -409,6 +408,16 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
                                                 apr_pool_t *p,
                                                 proxy_server_conf *conf,
                                                 const char *url);
+
+/**
+ * Initize the worker
+ * @param worker the new worker
+ * @param p      memory pool to allocate worker from 
+ * @param s      current server record
+ * @return       APR_SUCCESS or error code
+ */
+PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
+                                                       server_rec *s);
 /**
  * Get the balancer from proxy configuration
  * @param p     memory pool used for finding balancer
index 8d09132fe76fd181151e93e6df8e765d169592c5..607f08df727f70f121fab378dbba5fe39e4b9a0e 100644 (file)
@@ -1377,7 +1377,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_close_connection(proxy_conn_rec *conn)
     return connection_destructor(conn, NULL, NULL);
 }
 
-static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
+PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s)
 {
     apr_status_t rv;
 
@@ -1420,13 +1420,13 @@ static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
 #endif
     {
         
-        connection_constructor((void **)&(worker->cp->conn), s, worker->cp->pool);
-        rv = APR_SUCCESS;
+        rv = connection_constructor((void **)&(worker->cp->conn), s, worker->cp->pool);
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                      "proxy: initialized single connection worker for (%s)",
                       worker->hostname);
     }
-
+    if (rv == APR_SUCCESS)
+        worker->status |= PROXY_WORKER_INITIALIZED;
     return rv;
 }
 
@@ -1465,16 +1465,6 @@ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
 {
     apr_status_t rv;
 
-    if (!(worker->status & PROXY_WORKER_INITIALIZED)) {
-        if ((rv = init_conn_worker(worker, s)) != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "proxy: %s: failed to initialize worker for (%s)",
-                         proxy_function, worker->hostname);
-            return HTTP_INTERNAL_SERVER_ERROR;
-        }
-        worker->status |= PROXY_WORKER_INITIALIZED;
-    }
-
     if (!PROXY_WORKER_IS_USABLE(worker)) {
         /* Retry the worker */
         ap_proxy_retry_worker(proxy_function, worker, s);