Skip to content

Commit 937ceb4

Browse files
authored
Merge pull request #849 from jfclere/1.3.x
Fix for MODCLUSTER-841, use updated to propagate the status and error_time.
2 parents c7947c3 + f22301b commit 937ceb4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

native/mod_proxy_cluster/mod_proxy_cluster.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,11 +2335,13 @@ static int proxy_node_isup(request_rec *r, int id, int load)
23352335
}
23362336
}
23372337
else {
2338+
apr_time_t now = apr_time_now();
23382339
worker->s->status &= ~PROXY_WORKER_IN_ERROR;
23392340
worker->s->status &= ~PROXY_WORKER_STOPPED;
23402341
worker->s->status &= ~PROXY_WORKER_DISABLED;
23412342
worker->s->status &= ~PROXY_WORKER_HOT_STANDBY;
23422343
worker->s->lbfactor = load;
2344+
worker->s->updated = now;
23432345
if (http_worker != NULL) {
23442346
/* the ws/wss doesn't point to shared memory, so fix the http/https part */
23452347
http_worker->s->error_time = 0; /* we know the worker is OK ;-) */
@@ -2348,6 +2350,7 @@ static int proxy_node_isup(request_rec *r, int id, int load)
23482350
http_worker->s->status &= ~PROXY_WORKER_DISABLED;
23492351
http_worker->s->status &= ~PROXY_WORKER_HOT_STANDBY;
23502352
http_worker->s->lbfactor = load;
2353+
http_worker->s->updated = now;
23512354
}
23522355
}
23532356
return 0;
@@ -2540,6 +2543,8 @@ static void * APR_THREAD_FUNC proxy_cluster_watchdog_func(apr_thread_t *thd, voi
25402543
}
25412544

25422545
while (s) {
2546+
int i;
2547+
proxy_balancer *balancer;
25432548
sconf = s->module_config;
25442549
conf = (proxy_server_conf *)
25452550
ap_get_module_config(sconf, &proxy_module);
@@ -2556,6 +2561,45 @@ static void * APR_THREAD_FUNC proxy_cluster_watchdog_func(apr_thread_t *thd, voi
25562561
/* Free sessionid slots */
25572562
if (sessionid_storage)
25582563
remove_timeout_sessionid(conf, pool, s);
2564+
2565+
/* synchronize the http_worker when we have WS or WSS */
2566+
balancer = (proxy_balancer *)conf->balancers->elts;
2567+
for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
2568+
int j;
2569+
proxy_worker **workers;
2570+
workers = (proxy_worker **)balancer->workers->elts;
2571+
for (j = 0; j < balancer->workers->nelts; j++, workers++) {
2572+
proxy_worker *worker = *workers;
2573+
if (strcasecmp(worker->s->scheme, "WSS") == 0 ||
2574+
strcasecmp(worker->s->scheme, "WS") == 0) {
2575+
proxy_worker *http_worker;
2576+
http_worker = get_http_worker(s, worker);
2577+
if (http_worker != NULL) {
2578+
if (http_worker->s->status != worker->s->status ||
2579+
http_worker->s->error_time != worker->s->error_time) {
2580+
ap_log_error(APLOG_MARK, APLOG_TRACE8, 0, s,
2581+
"proxy_cluster_watchdog_func status(%d %d) error_time (%ld %ld) updated (%ld %ld) pid: %d %s",
2582+
http_worker->s->status, worker->s->status,
2583+
http_worker->s->error_time, worker->s->error_time,
2584+
http_worker->s->updated, worker->s->updated,
2585+
getpid(),
2586+
#if MODULE_MAGIC_NUMBER_MAJOR == 20120211 && MODULE_MAGIC_NUMBER_MINOR >= 124
2587+
worker->s->name_ex);
2588+
#else
2589+
worker->s->name);
2590+
#endif
2591+
/* The STATUS sets the worker->s->updated */
2592+
if (http_worker->s->updated < worker->s->updated) {
2593+
http_worker->s->status = worker->s->status;
2594+
http_worker->s->error_time = worker->s->error_time;
2595+
http_worker->s->updated = apr_time_now();
2596+
}
2597+
}
2598+
}
2599+
}
2600+
}
2601+
}
2602+
25592603
s = s->next;
25602604
}
25612605
apr_pool_destroy(pool);

0 commit comments

Comments
 (0)