@@ -691,14 +691,12 @@ int try_read_command_proxy(conn *c) {
691
691
// Must only be called with an active coroutine.
692
692
void proxy_cleanup_conn (conn * c ) {
693
693
assert (c -> proxy_rctx );
694
- LIBEVENT_THREAD * thr = c -> thread ;
695
694
mcp_rcontext_t * rctx = c -> proxy_rctx ;
696
695
assert (rctx -> pending_reqs == 1 );
697
696
rctx -> pending_reqs = 0 ;
698
697
699
698
mcp_funcgen_return_rctx (rctx );
700
699
c -> proxy_rctx = NULL ;
701
- WSTAT_DECR (thr , proxy_req_active , 1 );
702
700
}
703
701
704
702
// we buffered a SET of some kind.
@@ -899,13 +897,11 @@ int proxy_run_rcontext(mcp_rcontext_t *rctx) {
899
897
int cores = lua_resume (Lc , NULL , rctx -> lua_narg , & nresults );
900
898
rctx -> lua_narg = 1 ; // reset to default since not-default is uncommon.
901
899
size_t rlen = 0 ;
902
- conn * c = rctx -> c ;
903
900
mc_resp * resp = rctx -> resp ;
904
901
905
902
if (cores == LUA_OK ) {
906
903
// don't touch the result object if we were a sub-context.
907
904
if (!rctx -> parent ) {
908
- WSTAT_DECR (c -> thread , proxy_req_active , 1 );
909
905
int type = lua_type (Lc , 1 );
910
906
mcp_resp_t * r = NULL ;
911
907
P_DEBUG ("%s: coroutine completed. return type: %d\n" , __func__ , type );
@@ -915,7 +911,6 @@ int proxy_run_rcontext(mcp_rcontext_t *rctx) {
915
911
proxy_out_errstring (resp , PROXY_SERVER_ERROR , "backend failure" );
916
912
} else if (r -> cresp ) {
917
913
mc_resp * tresp = r -> cresp ;
918
- assert (c != NULL );
919
914
920
915
_proxy_run_tresp_to_resp (tresp , resp );
921
916
// we let the mcp_resp gc handler free up tresp and any
@@ -994,7 +989,6 @@ int proxy_run_rcontext(mcp_rcontext_t *rctx) {
994
989
P_DEBUG ("%s: Failed to run coroutine: %s\n" , __func__ , lua_tostring (Lc , -1 ));
995
990
LOGGER_LOG (NULL , LOG_PROXYEVENTS , LOGGER_PROXY_ERROR , NULL , lua_tostring (Lc , -1 ));
996
991
if (!rctx -> parent ) {
997
- WSTAT_DECR (c -> thread , proxy_req_active , 1 );
998
992
proxy_out_errstring (resp , PROXY_SERVER_ERROR , "lua failure" );
999
993
}
1000
994
rctx -> pending_reqs -- ;
@@ -1160,13 +1154,11 @@ static void proxy_process_command(conn *c, char *command, size_t cmdlen, bool mu
1160
1154
WSTAT_L (c -> thread );
1161
1155
istats -> counters [pr .command ]++ ;
1162
1156
c -> thread -> stats .proxy_conn_requests ++ ;
1163
- c -> thread -> stats .proxy_req_active ++ ;
1164
1157
active_reqs = c -> thread -> stats .proxy_req_active ;
1165
1158
WSTAT_UL (c -> thread );
1166
1159
1167
- if (active_reqs > ctx -> active_req_limit ) {
1160
+ if (active_reqs >= ctx -> active_req_limit ) {
1168
1161
proxy_out_errstring (c -> resp , PROXY_SERVER_ERROR , "active request limit reached" );
1169
- WSTAT_DECR (c -> thread , proxy_req_active , 1 );
1170
1162
if (pr .vlen != 0 ) {
1171
1163
c -> sbytes = pr .vlen ;
1172
1164
conn_set_state (c , conn_swallow );
@@ -1178,7 +1170,6 @@ static void proxy_process_command(conn *c, char *command, size_t cmdlen, bool mu
1178
1170
mcp_rcontext_t * rctx = mcp_funcgen_start (L , hook_ref .ctx , & pr );
1179
1171
if (rctx == NULL ) {
1180
1172
proxy_out_errstring (c -> resp , PROXY_SERVER_ERROR , "lua start failure" );
1181
- WSTAT_DECR (c -> thread , proxy_req_active , 1 );
1182
1173
if (pr .vlen != 0 ) {
1183
1174
c -> sbytes = pr .vlen ;
1184
1175
conn_set_state (c , conn_swallow );
@@ -1218,7 +1209,6 @@ static void proxy_process_command(conn *c, char *command, size_t cmdlen, bool mu
1218
1209
// normal cleanup
1219
1210
lua_settop (L , 0 );
1220
1211
proxy_out_errstring (c -> resp , PROXY_SERVER_ERROR , "out of memory" );
1221
- WSTAT_DECR (c -> thread , proxy_req_active , 1 );
1222
1212
c -> sbytes = pr .vlen ;
1223
1213
conn_set_state (c , conn_swallow );
1224
1214
return ;
0 commit comments