Skip to content

Commit 3dc9599

Browse files
committed
Improve handling of nodes (un)locking
1 parent 6c3e497 commit 3dc9599

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

native/mod_manager/mod_manager.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
14071407
nodeinfo.mess.ResponseFieldSize = mconf->response_field_size;
14081408
}
14091409
/* Insert or update balancer description */
1410-
rv = loc_lock_nodes();
1411-
ap_assert(rv == APR_SUCCESS);
1410+
ap_assert(loc_lock_nodes() == APR_SUCCESS);
14121411
if (insert_update_balancer(balancerstatsmem, &balancerinfo) != APR_SUCCESS) {
14131412
loc_unlock_nodes();
14141413
*errtype = TYPEMEM;

native/mod_proxy_cluster/mod_proxy_cluster.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,10 +1730,8 @@ static proxy_worker *internal_find_best_byrequests(const proxy_balancer *balance
17301730

17311731
/* create workers for new nodes */
17321732
if (!cache_share_for) {
1733-
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
17341733
update_workers_node(conf, r->pool, r->server, 1, node_table);
17351734
check_workers(conf, r->server);
1736-
node_storage->unlock_nodes();
17371735
}
17381736

17391737
/* do this once now to avoid repeating find_node_context_host through loop iterations */
@@ -2981,8 +2979,10 @@ static proxy_worker *find_best_worker(const proxy_balancer *balancer, const prox
29812979
return NULL;
29822980
}
29832981

2982+
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
29842983
candidate = internal_find_best_byrequests(balancer, conf, r, domain, failoverdomain, vhost_table, context_table,
29852984
node_table);
2985+
node_storage->unlock_nodes();
29862986

29872987
if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
29882988
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
@@ -3229,7 +3229,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32293229
check_workers(conf, r->server);
32303230
node_storage->unlock_nodes();
32313231
if (!(*balancer = ap_proxy_get_balancer(r->pool, conf, *url, 0))) {
3232-
/* node_storage->unlock_nodes(); */
32333232
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "proxy_cluster_pre_request: CLUSTER no balancer for %s",
32343233
*url);
32353234
return DECLINED;
@@ -3239,8 +3238,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32393238
}
32403239

32413240
/* Step 2: find the session route */
3242-
3241+
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
32433242
runtime = find_session_route(*balancer, r, &route, &sticky, url, &domain, vhost_table, context_table, node_table);
3243+
node_storage->unlock_nodes();
32443244

32453245
/* Lock the LoadBalancer
32463246
* XXX: perhaps we need the process lock here
@@ -3321,9 +3321,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33213321
*worker = runtime;
33223322
}
33233323

3324-
(*worker)->s->busy++;
3325-
apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count, apr_pool_cleanup_null);
3326-
33273324
/* Also mark the context here note that find_best_worker set BALANCER_CONTEXT_ID */
33283325
context_id = apr_table_get(r->subprocess_env, "BALANCER_CONTEXT_ID");
33293326
ap_assert(node_storage->lock_nodes() == APR_SUCCESS);
@@ -3335,7 +3332,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33353332
/* XXX: Do we need the lock here??? */
33363333
helper = (proxy_cluster_helper *)(*worker)->context;
33373334
helper->count_active++;
3335+
(*worker)->s->busy++;
33383336
node_storage->unlock_nodes();
3337+
apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count, apr_pool_cleanup_null);
33393338

33403339
/*
33413340
* get_route_balancer already fills all of the notes and some subprocess_env
@@ -3458,6 +3457,7 @@ static int proxy_cluster_post_request(proxy_worker *worker, proxy_balancer *bala
34583457
worker->s->name,
34593458
#endif
34603459
val);
3460+
34613461
worker->s->status |= PROXY_WORKER_IN_ERROR;
34623462
worker->s->error_time = apr_time_now();
34633463
break;

0 commit comments

Comments
 (0)