@@ -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