Skip to content

Commit b0b416b

Browse files
committed
Merge branch 'PHP-8.1'
2 parents ddf7e35 + 62b676f commit b0b416b

File tree

4 files changed

+62
-20
lines changed

4 files changed

+62
-20
lines changed

sapi/fpm/fpm/fpm_process_ctl.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,21 +327,6 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
327327

328328
if (wp->config == NULL) continue;
329329

330-
for (child = wp->children; child; child = child->next) {
331-
if (fpm_request_is_idle(child)) {
332-
if (last_idle_child == NULL) {
333-
last_idle_child = child;
334-
} else {
335-
if (timercmp(&child->started, &last_idle_child->started, <)) {
336-
last_idle_child = child;
337-
}
338-
}
339-
idle++;
340-
} else {
341-
active++;
342-
}
343-
}
344-
345330
/* update status structure for all PMs */
346331
if (wp->listen_address_domain == FPM_AF_INET) {
347332
if (0 > fpm_socket_get_listening_queue(wp->listening_socket, &cur_lq, NULL)) {
@@ -359,7 +344,25 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{
359344
#endif
360345
}
361346
}
362-
fpm_scoreboard_update(idle, active, cur_lq, -1, -1, -1, 0, FPM_SCOREBOARD_ACTION_SET, wp->scoreboard);
347+
348+
fpm_scoreboard_update_begin(wp->scoreboard);
349+
350+
for (child = wp->children; child; child = child->next) {
351+
if (fpm_request_is_idle(child)) {
352+
if (last_idle_child == NULL) {
353+
last_idle_child = child;
354+
} else {
355+
if (timercmp(&child->started, &last_idle_child->started, <)) {
356+
last_idle_child = child;
357+
}
358+
}
359+
idle++;
360+
} else {
361+
active++;
362+
}
363+
}
364+
365+
fpm_scoreboard_update_commit(idle, active, cur_lq, -1, -1, -1, 0, FPM_SCOREBOARD_ACTION_SET, wp->scoreboard);
363366

364367
/* this is specific to PM_STYLE_ONDEMAND */
365368
if (wp->config->pm == PM_STYLE_ONDEMAND) {

sapi/fpm/fpm/fpm_request.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ void fpm_request_accepting() /* {{{ */
4141

4242
fpm_clock_get(&now);
4343

44+
fpm_scoreboard_update_begin(NULL);
45+
4446
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
4547
if (proc == NULL) {
4648
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
@@ -52,7 +54,7 @@ void fpm_request_accepting() /* {{{ */
5254
fpm_scoreboard_proc_release(proc);
5355

5456
/* idle++, active-- */
55-
fpm_scoreboard_update(1, -1, 0, 0, 0, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
57+
fpm_scoreboard_update_commit(1, -1, 0, 0, 0, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
5658
}
5759
/* }}} */
5860

@@ -72,6 +74,8 @@ void fpm_request_reading_headers() /* {{{ */
7274
times(&cpu);
7375
#endif
7476

77+
fpm_scoreboard_update_begin(NULL);
78+
7579
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
7680
if (proc == NULL) {
7781
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
@@ -95,7 +99,7 @@ void fpm_request_reading_headers() /* {{{ */
9599
fpm_scoreboard_proc_release(proc);
96100

97101
/* idle--, active++, request++ */
98-
fpm_scoreboard_update(-1, 1, 0, 0, 1, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
102+
fpm_scoreboard_update_commit(-1, 1, 0, 0, 1, 0, 0, FPM_SCOREBOARD_ACTION_INC, NULL);
99103
}
100104
/* }}} */
101105

sapi/fpm/fpm/fpm_scoreboard.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,39 @@ int fpm_scoreboard_init_main() /* {{{ */
7474
}
7575
/* }}} */
7676

77-
void fpm_scoreboard_update(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int slow_rq, int action, struct fpm_scoreboard_s *scoreboard) /* {{{ */
77+
static struct fpm_scoreboard_s *fpm_scoreboard_get_for_update(struct fpm_scoreboard_s *scoreboard) /* {{{ */
7878
{
7979
if (!scoreboard) {
8080
scoreboard = fpm_scoreboard;
8181
}
8282
if (!scoreboard) {
8383
zlog(ZLOG_WARNING, "Unable to update scoreboard: the SHM has not been found");
84-
return;
8584
}
8685

86+
return scoreboard;
87+
}
88+
/* }}} */
89+
90+
void fpm_scoreboard_update_begin(struct fpm_scoreboard_s *scoreboard) /* {{{ */
91+
{
92+
scoreboard = fpm_scoreboard_get_for_update(scoreboard);
93+
if (!scoreboard) {
94+
return;
95+
}
8796

8897
fpm_spinlock(&scoreboard->lock, 0);
98+
}
99+
/* }}} */
100+
101+
void fpm_scoreboard_update_commit(
102+
int idle, int active, int lq, int lq_len, int requests, int max_children_reached,
103+
int slow_rq, int action, struct fpm_scoreboard_s *scoreboard) /* {{{ */
104+
{
105+
scoreboard = fpm_scoreboard_get_for_update(scoreboard);
106+
if (!scoreboard) {
107+
return;
108+
}
109+
89110
if (action == FPM_SCOREBOARD_ACTION_SET) {
90111
if (idle >= 0) {
91112
scoreboard->idle = idle;
@@ -154,6 +175,17 @@ void fpm_scoreboard_update(int idle, int active, int lq, int lq_len, int request
154175
}
155176
/* }}} */
156177

178+
179+
void fpm_scoreboard_update(
180+
int idle, int active, int lq, int lq_len, int requests, int max_children_reached,
181+
int slow_rq, int action, struct fpm_scoreboard_s *scoreboard) /* {{{ */
182+
{
183+
fpm_scoreboard_update_begin(scoreboard);
184+
fpm_scoreboard_update_commit(
185+
idle, active, lq, lq_len, requests, max_children_reached, slow_rq, action, scoreboard);
186+
}
187+
/* }}} */
188+
157189
struct fpm_scoreboard_s *fpm_scoreboard_get() /* {{{*/
158190
{
159191
return fpm_scoreboard;

sapi/fpm/fpm/fpm_scoreboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ struct fpm_scoreboard_s {
7373
int fpm_scoreboard_init_main(void);
7474
int fpm_scoreboard_init_child(struct fpm_worker_pool_s *wp);
7575

76+
void fpm_scoreboard_update_begin(struct fpm_scoreboard_s *scoreboard);
77+
void fpm_scoreboard_update_commit(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int slow_rq, int action, struct fpm_scoreboard_s *scoreboard);
7678
void fpm_scoreboard_update(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int slow_rq, int action, struct fpm_scoreboard_s *scoreboard);
79+
7780
struct fpm_scoreboard_s *fpm_scoreboard_get(void);
7881
struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_get(struct fpm_scoreboard_s *scoreboard, int child_index);
7982
struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_get_from_child(struct fpm_child_s *child);

0 commit comments

Comments
 (0)