Skip to content

Commit f7232d6

Browse files
committed
Improve handling of nodes (un)locking
1 parent af80f75 commit f7232d6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

native/mod_manager/mod_manager.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1412,8 +1412,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
14121412
nodeinfo.mess.ResponseFieldSize = mconf->response_field_size;
14131413
}
14141414
/* Insert or update balancer description */
1415-
rv = loc_lock_nodes();
1416-
ap_assert(rv == APR_SUCCESS);
1415+
ap_assert(loc_lock_nodes() == APR_SUCCESS);
14171416
if (insert_update_balancer(balancerstatsmem, &balancerinfo) != APR_SUCCESS) {
14181417
loc_unlock_nodes();
14191418
*errtype = TYPEMEM;

native/mod_proxy_cluster/mod_proxy_cluster.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1740,10 +1740,8 @@ static proxy_worker *internal_find_best_byrequests(const proxy_balancer *balance
17401740

17411741
/* create workers for new nodes */
17421742
if (!cache_share_for) {
1743-
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
17441743
update_workers_node(conf, r->pool, r->server, 1, node_table);
17451744
check_workers(conf, r->server);
1746-
node_storage->unlock_nodes();
17471745
}
17481746

17491747
/* do this once now to avoid repeating find_node_context_host through loop iterations */
@@ -2992,8 +2990,10 @@ static proxy_worker *find_best_worker(const proxy_balancer *balancer, const prox
29922990
return NULL;
29932991
}
29942992

2993+
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
29952994
candidate = internal_find_best_byrequests(balancer, conf, r, domain, failoverdomain, vhost_table, context_table,
29962995
node_table);
2996+
node_storage->unlock_nodes();
29972997

29982998
if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
29992999
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
@@ -3240,7 +3240,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32403240
check_workers(conf, r->server);
32413241
node_storage->unlock_nodes();
32423242
if (!(*balancer = ap_proxy_get_balancer(r->pool, conf, *url, 0))) {
3243-
/* node_storage->unlock_nodes(); */
32443243
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "proxy_cluster_pre_request: CLUSTER no balancer for %s",
32453244
*url);
32463245
return DECLINED;
@@ -3250,8 +3249,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32503249
}
32513250

32523251
/* Step 2: find the session route */
3253-
3252+
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
32543253
runtime = find_session_route(*balancer, r, &route, &sticky, url, &domain, vhost_table, context_table, node_table);
3254+
node_storage->unlock_nodes();
32553255

32563256
/* Lock the LoadBalancer
32573257
* XXX: perhaps we need the process lock here
@@ -3332,9 +3332,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33323332
*worker = runtime;
33333333
}
33343334

3335-
(*worker)->s->busy++;
3336-
apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count, apr_pool_cleanup_null);
3337-
33383335
/* Also mark the context here note that find_best_worker set BALANCER_CONTEXT_ID */
33393336
context_id = apr_table_get(r->subprocess_env, "BALANCER_CONTEXT_ID");
33403337
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
@@ -3346,7 +3343,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33463343
/* XXX: Do we need the lock here??? */
33473344
helper = (proxy_cluster_helper *)(*worker)->context;
33483345
helper->count_active++;
3346+
(*worker)->s->busy++;
33493347
node_storage->unlock_nodes();
3348+
apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count, apr_pool_cleanup_null);
33503349

33513350
/*
33523351
* get_route_balancer already fills all of the notes and some subprocess_env
@@ -3469,6 +3468,7 @@ static int proxy_cluster_post_request(proxy_worker *worker, proxy_balancer *bala
34693468
worker->s->name,
34703469
#endif
34713470
val);
3471+
34723472
worker->s->status |= PROXY_WORKER_IN_ERROR;
34733473
worker->s->error_time = apr_time_now();
34743474
break;

0 commit comments

Comments
 (0)