Skip to content

Commit

Permalink
Merge pull request #305 from jfclere/master
Browse files Browse the repository at this point in the history
  • Loading branch information
jajik authored Dec 10, 2024
2 parents 195dda7 + 764b5ab commit 06c0ac1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions native/mod_proxy_cluster/mod_proxy_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ static void add_hcheck(server_rec *s, const proxy_server_conf *conf, proxy_worke

static int (*ap_proxy_retry_worker_fn)(const char *proxy_function, proxy_worker *worker, server_rec *s) = NULL;

static int is_worker_empty(proxy_worker *worker)
{
return worker && (worker->s->port == 0 || worker->s->scheme[0] == '\0' || worker->s->hostname[0] == '\0');
}

static void check_workers(const proxy_server_conf *conf, const server_rec *s)
{
int i;
Expand All @@ -211,13 +216,12 @@ static void check_workers(const proxy_server_conf *conf, const server_rec *s)
proxy_worker **workers;
workers = (proxy_worker **)balancer->workers->elts;
for (j = 0; j < balancer->workers->nelts; j++, workers++) {
volatile proxy_worker *worker = *workers;
proxy_worker *worker = *workers;
proxy_cluster_helper *helper;
int stop_worker = 0;
helper = (proxy_cluster_helper *)worker->context;
ap_assert(helper); /* we are in trouble ... */
if (worker->s->port == 0 && worker->s->scheme[0] == '\0' && worker->s->hostname[0] == '\0' &&
worker->s->route[0] == '\0') {
if (is_worker_empty(worker)) {
/* this happens when a new child process is created and it "cleaned" some old slotmem */
/* it is like the remove_workers_node we try to restore the non shared memory allocated in
* create_worker() */
Expand Down Expand Up @@ -796,7 +800,11 @@ static proxy_worker *get_worker_from_id_stat(const proxy_server_conf *conf, int
proxy_worker **worker = (proxy_worker **)ptrw;
proxy_cluster_helper *helper = (proxy_cluster_helper *)(*worker)->context;
if ((*worker)->s == stat && helper->index == id) {
return *worker;
if (is_worker_empty(*worker)) {
return NULL;
} else {
return *worker;
}
}
if (helper->index == id) {
unpair_worker_node((*worker)->s, node);
Expand Down Expand Up @@ -2048,7 +2056,7 @@ static int proxy_node_get_free_id(request_rec *r, int node_table_size)
proxy_worker **workers;
workers = (proxy_worker **)balancer->workers->elts;
for (j = 0; j < balancer->workers->nelts; j++, workers++) {
volatile proxy_worker *worker = *workers;
proxy_worker *worker = *workers;
proxy_cluster_helper *helper;
if (worker->s->index >= node_table_size) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server,
Expand Down

0 comments on commit 06c0ac1

Please sign in to comment.