diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-07 12:57:30 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-02-04 17:07:18 +0100 |
commit | 8b7aaad7d65779b1d6497436b4e7da52f53d159c (patch) | |
tree | b018e26842c2b73cef87a4d67f6cf28f50a96ec8 /ext | |
parent | 958e3b93c34a54c98069d1b4666f3ba6dae0c0e2 (diff) | |
download | php-git-8b7aaad7d65779b1d6497436b4e7da52f53d159c.tar.gz |
Try SIGTERM before SIGKILL in opcache restart
SIGTERM is subject to HANDLE_BLOCK_INTERRUPTIONS(), which will
allow code to exit critical sections before it gets terminated.
Closes GH-6493.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 7cc301013b..189cfca279 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -774,14 +774,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; @@ -800,6 +801,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 */ |