php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch dont-while-loop-for-ever-php-7.3-only-for-noperm for opcache Bug #76482

Patch version 2019-02-01 13:52 UTC

Return to Bug #76482 | Download this patch
Patch Revisions:

Developer: arekm@maven.pl

diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index a066954bf4..20fd5c8109 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -768,7 +768,7 @@ static void accel_use_permanent_interned_strings(void)
 #ifndef ZEND_WIN32
 static inline void kill_all_lockers(struct flock *mem_usage_check)
 {
-	int success, tries;
+	int success, tries, noperm = 0;
 	/* 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) {
@@ -784,6 +784,9 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
 					/* Process died before the signal was sent */
 					success = 1;
 					zend_accel_error(ACCEL_LOG_WARNING, "Process %d died before SIGKILL was sent", mem_usage_check->l_pid);
+				} else if (errno == EPERM) {
+					/* We have no permission to kill the other process, so no point in trying */)
+					noperm = 1;
 				}
 				break;
 			}
@@ -804,6 +807,9 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
 			ZCSG(force_restart_time) = time(NULL); /* restore forced restart request */
 			/* cannot kill the locker, bail out with error */
 			zend_accel_error(ACCEL_LOG_ERROR, "Cannot kill process %d: %s!", mem_usage_check->l_pid, strerror(errno));
+			/* no permission, so we end here */
+			if (noperm)
+			    break;
 		}
 
 		mem_usage_check->l_type = F_WRLCK;
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 25 17:01:29 2019 UTC