From 965c4513a57062c37ed4892fdb22329a389541df Mon Sep 17 00:00:00 2001 From: Sergei Turchanov Date: Wed, 28 Aug 2019 13:05:14 +1000 Subject: [PATCH] fcgi_accept_request must call on_accept hook for named pipes too fcgi_accept_request function is supposed to call a FastCGI implementation's on_accept hook when entering an "accepting" stage (that is right before calling "accept"). This hook implementation (fpm_request_accepting) updates a worker state to an "accepting" state which is effectively an "Idle" state, and updates counters on the scoreboard of the corresponding pool (idle++, active--). But this is not done when listening for client connections on a named pipe on Windows platform. In that case a combination of ConnectNamedPipe/WaitForSingleObject is used (to be able to catch in_shutdown as far as I understand), but it is nonetheless functionally equivalent to "accept" call. Also by not calling on_hook neither a worker's state is updated to "accepting" state nor scoreboard counters are updated. --- main/fastcgi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/fastcgi.c b/main/fastcgi.c index 3181661877108..4b3dd312ff79d 100644 --- a/main/fastcgi.c +++ b/main/fastcgi.c @@ -1375,6 +1375,8 @@ int fcgi_accept_request(fcgi_request *req) if (in_shutdown) { return -1; } + + req->hook.on_accept(); #ifdef _WIN32 if (!req->tcp) { pipe = (HANDLE)_get_osfhandle(req->listen_socket); @@ -1405,8 +1407,6 @@ int fcgi_accept_request(fcgi_request *req) sa_t sa; socklen_t len = sizeof(sa); - req->hook.on_accept(); - FCGI_LOCK(req->listen_socket); req->fd = accept(listen_socket, (struct sockaddr *)&sa, &len); FCGI_UNLOCK(req->listen_socket);