@@ -1738,10 +1738,8 @@ static proxy_worker *internal_find_best_byrequests(const proxy_balancer *balance
17381738
17391739 /* create workers for new nodes */
17401740 if (!cache_share_for ) {
1741- ap_assert (node_storage -> lock_nodes () == APR_SUCCESS );
17421741 update_workers_node (conf , r -> pool , r -> server , 1 , node_table );
17431742 check_workers (conf , r -> server );
1744- node_storage -> unlock_nodes ();
17451743 }
17461744
17471745 /* do this once now to avoid repeating find_node_context_host through loop iterations */
@@ -2989,8 +2987,10 @@ static proxy_worker *find_best_worker(const proxy_balancer *balancer, const prox
29892987 return NULL ;
29902988 }
29912989
2990+ ap_assert (node_storage -> lock_nodes () == APR_SUCCESS );
29922991 candidate = internal_find_best_byrequests (balancer , conf , r , domain , failoverdomain , vhost_table , context_table ,
29932992 node_table );
2993+ node_storage -> unlock_nodes ();
29942994
29952995 if ((rv = PROXY_THREAD_UNLOCK (balancer )) != APR_SUCCESS ) {
29962996 ap_log_error (APLOG_MARK , APLOG_ERR , rv , r -> server ,
@@ -3237,7 +3237,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32373237 check_workers (conf , r -> server );
32383238 node_storage -> unlock_nodes ();
32393239 if (!(* balancer = ap_proxy_get_balancer (r -> pool , conf , * url , 0 ))) {
3240- /* node_storage->unlock_nodes(); */
32413240 ap_log_error (APLOG_MARK , APLOG_ERR , 0 , r -> server , "proxy_cluster_pre_request: CLUSTER no balancer for %s" ,
32423241 * url );
32433242 return DECLINED ;
@@ -3247,8 +3246,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
32473246 }
32483247
32493248 /* Step 2: find the session route */
3250-
3249+ ap_assert ( node_storage -> lock_nodes () == APR_SUCCESS );
32513250 runtime = find_session_route (* balancer , r , & route , & sticky , url , & domain , vhost_table , context_table , node_table );
3251+ node_storage -> unlock_nodes ();
32523252
32533253 /* Lock the LoadBalancer
32543254 * XXX: perhaps we need the process lock here
@@ -3329,9 +3329,6 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33293329 * worker = runtime ;
33303330 }
33313331
3332- (* worker )-> s -> busy ++ ;
3333- apr_pool_cleanup_register (r -> pool , * worker , decrement_busy_count , apr_pool_cleanup_null );
3334-
33353332 /* Also mark the context here note that find_best_worker set BALANCER_CONTEXT_ID */
33363333 context_id = apr_table_get (r -> subprocess_env , "BALANCER_CONTEXT_ID" );
33373334 ap_assert (node_storage -> lock_nodes () == APR_SUCCESS );
@@ -3343,7 +3340,9 @@ static int proxy_cluster_pre_request(proxy_worker **worker, proxy_balancer **bal
33433340 /* XXX: Do we need the lock here??? */
33443341 helper = (proxy_cluster_helper * )(* worker )-> context ;
33453342 helper -> count_active ++ ;
3343+ (* worker )-> s -> busy ++ ;
33463344 node_storage -> unlock_nodes ();
3345+ apr_pool_cleanup_register (r -> pool , * worker , decrement_busy_count , apr_pool_cleanup_null );
33473346
33483347 /*
33493348 * get_route_balancer already fills all of the notes and some subprocess_env
@@ -3466,6 +3465,7 @@ static int proxy_cluster_post_request(proxy_worker *worker, proxy_balancer *bala
34663465 worker -> s -> name ,
34673466#endif
34683467 val );
3468+
34693469 worker -> s -> status |= PROXY_WORKER_IN_ERROR ;
34703470 worker -> s -> error_time = apr_time_now ();
34713471 break ;
0 commit comments