Skip to content

Commit 411f84b

Browse files
committed
Fix GH-18956: PHP-FPM Process Count Inconsistencies
This fixes incorrect decrement of the active number of processes. This was done in accepting stage before incrementing which is problematic if there are already some running processes as it decrements their number first and result in incorrect total (lower than the actual number). In addition it also fixes GH-14212 as accept is done just once for keepalive connection so in this case the number of active connection just increasing with each request.
1 parent 3128693 commit 411f84b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

sapi/fpm/fpm/fpm_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,8 @@ consult the installation file that came with this distribution, or visit \n\
19731973

19741974
fpm_stdio_flush_child();
19751975

1976+
fpm_request_shutdown();
1977+
19761978
requests++;
19771979
if (UNEXPECTED(max_requests && (requests == max_requests))) {
19781980
fcgi_request_set_keep(request, 0);

sapi/fpm/fpm/fpm_request.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void fpm_request_accepting(void)
5454
proc->tv = now;
5555
fpm_scoreboard_proc_release(proc);
5656

57-
/* idle++, active-- */
58-
fpm_scoreboard_update_commit(1, -1, 0, 0, 0, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
57+
/* idle++ */
58+
fpm_scoreboard_update_commit(1, 0, 0, 0, 0, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
5959
}
6060

6161
void fpm_request_reading_headers(void)
@@ -220,6 +220,12 @@ void fpm_request_finished(void)
220220
fpm_scoreboard_proc_release(proc);
221221
}
222222

223+
void fpm_request_shutdown(void)
224+
{
225+
/* active-- */
226+
fpm_scoreboard_update(0, -1, 0, 0, 0, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
227+
}
228+
223229
void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, int terminate_timeout, int slowlog_timeout, int track_finished) /* {{{ */
224230
{
225231
struct fpm_scoreboard_proc_s proc, *proc_p;

sapi/fpm/fpm/fpm_request.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ void fpm_request_executing(void);
1515
void fpm_request_end(void);
1616
/* request processed: cleaning current request */
1717
void fpm_request_finished(void);
18+
/* request post shutdown: decrement active */
19+
void fpm_request_shutdown(void);
1820

1921
struct fpm_child_s;
2022
struct timeval;

0 commit comments

Comments
 (0)