ASF Bugzilla – Attachment 37339 Details for
Bug 64338
Expose balancer member state to origin / upstream server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add BALANCER_WORKER_STATUS environment variable, pass to upstream in http/ajp modules
file_64338.txt (text/plain), 2.88 KB, created by
Christopher Schultz
on 2020-06-30 17:19:17 UTC
(
hide
)
Description:
Add BALANCER_WORKER_STATUS environment variable, pass to upstream in http/ajp modules
Filename:
MIME Type:
Creator:
Christopher Schultz
Created:
2020-06-30 17:19:17 UTC
Size:
2.88 KB
patch
obsolete
>Index: modules/proxy/ajp_header.c >=================================================================== >--- modules/proxy/ajp_header.c (revision 1879349) >+++ modules/proxy/ajp_header.c (working copy) >@@ -489,6 +489,16 @@ > elts[i].key, elts[i].val); > return AJP_EOVERFLOW; > } >+ } else if(0 == strcmp(elts[i].key, "BALANCER_WORKER_STATUS")) { >+ if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) || >+ ajp_msg_append_string(msg, elts[i].key) || >+ ajp_msg_append_string(msg, elts[i].val)) { >+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00981) >+ "ajp_marshal_into_msgb: " >+ "Error appending attribute %s=%s", >+ elts[i].key, elts[i].val); >+ return AJP_EOVERFLOW; >+ } > } > } > >Index: modules/proxy/mod_proxy_balancer.c >=================================================================== >--- modules/proxy/mod_proxy_balancer.c (revision 1879349) >+++ modules/proxy/mod_proxy_balancer.c (working copy) >@@ -482,6 +482,7 @@ > char *route = NULL; > const char *sticky = NULL; > apr_status_t rv; >+ unsigned int worker_status; > > *worker = NULL; > /* Step 1: check if the url is for us >@@ -622,6 +623,18 @@ > apr_table_setn(r->subprocess_env, > "BALANCER_WORKER_ROUTE", (*worker)->s->route); > >+ worker_status = (*worker)->s->status; >+ /* unsigned worker status can theoretically be > INT_MAX; */ >+ if(worker_status > INT_MAX) { >+ apr_table_setn(r->subprocess_env, >+ "BALANCER_WORKER_STATUS", >+ apr_ltoa(r->pool, (long)worker_status)); >+ } else { >+ apr_table_setn(r->subprocess_env, >+ "BALANCER_WORKER_STATUS", >+ apr_itoa(r->pool, (int)worker_status)); >+ } >+ > /* Rewrite the url from 'balancer://url' > * to the 'worker_scheme://worker_hostname[:worker_port]/url' > * This replaces the balancers fictional name with the >Index: modules/proxy/proxy_util.c >=================================================================== >--- modules/proxy/proxy_util.c (revision 1879349) >+++ modules/proxy/proxy_util.c (working copy) >@@ -3795,6 +3795,14 @@ > */ > apr_table_mergen(r->headers_in, "X-Forwarded-Server", > r->server->server_hostname); >+ >+ /* If we are being used in a balanced-worker situation and >+ * have a worker status, copy that status into X-Worker-Status >+ * so that upstream knows the worker status. >+ */ >+ if((buf = apr_table_get(r->subprocess_env, "BALANCER_WORKER_STATUS"))) { >+ apr_table_mergen(r->headers_in, "X-Worker-Status", buf); >+ } > } > } >
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 64338
:
37337
|
37338
| 37339