summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-04 17:07:30 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-04 17:07:30 +0100
commit0c6ff5eafa360cf49ed93082e214552fbcb2d899 (patch)
treef78b05e1ac34289ea90978f50ccfe6c60250378d
parent5cb25a2d32df8073df7c191dd6c7694b4495af62 (diff)
parent8b7aaad7d65779b1d6497436b4e7da52f53d159c (diff)
downloadphp-git-0c6ff5eafa360cf49ed93082e214552fbcb2d899.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Try SIGTERM before SIGKILL in opcache restart
-rw-r--r--ext/opcache/ZendAccelerator.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 19fc938228..6974307e29 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -767,14 +767,15 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
/* so that other process won't try to force while we are busy cleaning up */
ZCSG(force_restart_time) = 0;
while (mem_usage_check->l_pid > 0) {
- /* Clear previous errno, reset success and tries */
+ /* Try SIGTERM first, switch to SIGKILL if not successful. */
+ int signal = SIGTERM;
errno = 0;
success = 0;
tries = 10;
while (tries--) {
zend_accel_error(ACCEL_LOG_WARNING, "Attempting to kill locker %d", mem_usage_check->l_pid);
- if (kill(mem_usage_check->l_pid, SIGKILL)) {
+ if (kill(mem_usage_check->l_pid, signal)) {
if (errno == ESRCH) {
/* Process died before the signal was sent */
success = 1;
@@ -797,6 +798,8 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
break;
}
usleep(10000);
+ /* If SIGTERM was not sufficient, use SIGKILL. */
+ signal = SIGKILL;
}
if (!success) {
/* errno is not ESRCH or we ran out of tries to kill the locker */