ASF Bugzilla – Attachment 32098 Details for
Bug 44736
mod_proxy_balancer looses it's mind on reloads.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed patch v6
httpd-2.2.x-graceful-share.patch (text/plain), 5.93 KB, created by
Yann Ylavic
on 2014-10-09 11:56:24 UTC
(
hide
)
Description:
proposed patch v6
Filename:
MIME Type:
Creator:
Yann Ylavic
Created:
2014-10-09 11:56:24 UTC
Size:
5.93 KB
patch
obsolete
>Index: modules/proxy/mod_proxy_balancer.c >=================================================================== >--- modules/proxy/mod_proxy_balancer.c (revision 1630072) >+++ modules/proxy/mod_proxy_balancer.c (working copy) >@@ -83,25 +83,23 @@ static int init_balancer_members(proxy_server_conf > int i; > proxy_worker *workers; > int worker_is_initialized; >- proxy_worker_stat *slot; > > workers = (proxy_worker *)balancer->workers->elts; > > for (i = 0; i < balancer->workers->nelts; i++) { > worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(workers); >+#if PROXY_HAS_SCOREBOARD >+ /* >+ * If the worker is not initialized but has a scoreboard >+ * slot, check whether it was already initialized in a >+ * previous generation to avoid resetting the shared lb >+ * parameters below. >+ */ > if (!worker_is_initialized) { >- /* >- * If the worker is not initialized check whether its scoreboard >- * slot is already initialized. >- */ >- slot = (proxy_worker_stat *) ap_get_scoreboard_lb(workers->id); >- if (slot) { >- worker_is_initialized = slot->status & PROXY_WORKER_INITIALIZED; >- } >- else { >- worker_is_initialized = 0; >- } >+ ap_proxy_set_scoreboard_lb(workers); >+ worker_is_initialized = PROXY_WORKER_IS_INITIALIZED(workers); > } >+#endif > ap_proxy_initialize_worker_share(conf, workers, s); > ap_proxy_initialize_worker(workers, s); > if (!worker_is_initialized) { >Index: modules/proxy/proxy_util.c >=================================================================== >--- modules/proxy/proxy_util.c (revision 1630072) >+++ modules/proxy/proxy_util.c (working copy) >@@ -1794,6 +1794,42 @@ static apr_status_t connection_destructor(void *re > } > #endif > >+#if PROXY_HAS_SCOREBOARD >+void *ap_proxy_set_scoreboard_lb(proxy_worker *worker) { >+ int i = 0; >+ proxy_worker_stat *free_slot = NULL; >+ proxy_worker_stat *s; >+ unsigned char digest[APR_MD5_DIGESTSIZE]; >+ >+ if (!ap_scoreboard_image) { >+ return NULL; >+ } >+ >+ if (worker->s) { >+ return worker->s; >+ } >+ >+ apr_md5(digest, (const unsigned char *) worker->name, >+ strlen(worker->name)); >+ >+ /* Try to find out the right shared memory according to the hash >+ * of worker->name. */ >+ while ((s = (proxy_worker_stat *)ap_get_scoreboard_lb(i++)) != NULL) { >+ if (memcmp(s->digest, digest, APR_MD5_DIGESTSIZE) == 0) { >+ worker->s = s; >+ return s; >+ } >+ else if (s->status == 0 && free_slot == NULL) { >+ free_slot = s; >+ } >+ } >+ >+ /* We failed to find out shared memory, so just use free slot */ >+ worker->s = free_slot; >+ return free_slot; >+} >+#endif >+ > /* > * ap_proxy_initialize_worker_share() concerns itself > * with initializing those parts of worker which >@@ -1803,11 +1839,7 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_sha > proxy_worker *worker, > server_rec *s) > { >-#if PROXY_HAS_SCOREBOARD >- lb_score *score = NULL; >-#else > void *score = NULL; >-#endif > > if (PROXY_WORKER_IS_INITIALIZED(worker)) { > /* The worker share is already initialized */ >@@ -1819,16 +1851,16 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_sha > #if PROXY_HAS_SCOREBOARD > /* Get scoreboard slot */ > if (ap_scoreboard_image) { >- score = ap_get_scoreboard_lb(worker->id); >- if (!score) { >+ if (!ap_proxy_set_scoreboard_lb(worker)) { > 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", >+ "proxy: ap_proxy_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); >+ score = worker->s; > } > } > #endif >@@ -1837,8 +1869,8 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_sha > 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 = (proxy_worker_stat *)score; > } >- worker->s = (proxy_worker_stat *)score; > /* > * recheck to see if we've already been here. Possible > * if proxy is using scoreboard to hold shared stats >@@ -1863,6 +1895,9 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_sha > *worker->s->redirect = '\0'; > } > >+ apr_md5(worker->s->digest, (const unsigned char *) worker->name, >+ strlen(worker->name)); >+ > worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED); > > } >Index: modules/proxy/mod_proxy.h >=================================================================== >--- modules/proxy/mod_proxy.h (revision 1630072) >+++ modules/proxy/mod_proxy.h (working copy) >@@ -308,6 +308,7 @@ typedef struct { > void *context; /* general purpose storage */ > apr_size_t busy; /* busyness factor */ > int lbset; /* load balancer cluster set */ >+ unsigned char digest[APR_MD5_DIGESTSIZE]; /* hash of the worker->name */ > } proxy_worker_stat; > > /* Worker configuration */ >@@ -772,6 +773,10 @@ PROXY_DECLARE(apr_status_t) > ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from, > apr_bucket_brigade *to); > >+#if PROXY_HAS_SCOREBOARD >+void *ap_proxy_set_scoreboard_lb(proxy_worker *worker); >+#endif >+ > #define PROXY_LBMETHOD "proxylbmethod" > > /* The number of dynamic workers that can be added when reconfiguring.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44736
:
26555
|
32086
|
32087
|
32091
|
32093
|
32095
|
32098
|
32159