]> granicus.if.org Git - php/commitdiff
Fix misleading error message in `ZendAccelerator.c`.
authorAdam Saponara <as@php.net>
Tue, 26 Nov 2019 22:21:16 +0000 (17:21 -0500)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 2 Dec 2019 09:06:32 +0000 (10:06 +0100)
Currently this error emits something like...

`Error Cannot kill process 12345: Success!`

...due to calling `time` before `strerror` which clears `errno`. This
patch adds an error log immediately after both `kill` calls which gives
us better indication of what exactly failed.

ext/opcache/ZendAccelerator.c

index 08fca1e3fa90f4adc66399b1aa60eaa67f1fbb03..5cf1bced129564db2a6566a46ae9a43ba1cf70b1 100644 (file)
@@ -783,6 +783,8 @@ 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 != 0) {
+                                       zend_accel_error(ACCEL_LOG_WARNING, "Failed to send SIGKILL to locker %d: %s", mem_usage_check->l_pid, strerror(errno));
                                }
                                break;
                        }
@@ -793,6 +795,8 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
                                        /* successfully killed locker, process no longer exists  */
                                        success = 1;
                                        zend_accel_error(ACCEL_LOG_WARNING, "Killed locker %d", mem_usage_check->l_pid);
+                               } else if (errno != 0) {
+                                       zend_accel_error(ACCEL_LOG_WARNING, "Failed to check locker %d: %s", mem_usage_check->l_pid, strerror(errno));
                                }
                                break;
                        }
@@ -802,7 +806,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
                        /* errno is not ESRCH or we ran out of tries to kill the locker */
                        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));
+                       zend_accel_error(ACCEL_LOG_ERROR, "Cannot kill process %d!", mem_usage_check->l_pid);
                }
 
                mem_usage_check->l_type = F_WRLCK;