Skip to content

Commit a50de37

Browse files
MaxKellermannGirgias
authored andcommitted
ext/opcache/ZendAccelerator: accel_is_inactive() returns bool
It was declared to be `int`, but actually returned `zend_result` enum values. However the name of the function suggests it should be `bool`, so returning something else is error prone. The function definition is difficult enough already because the name is negated...
1 parent 3dcd472 commit a50de37

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/opcache/ZendAccelerator.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
893893
}
894894
#endif
895895

896-
static inline int accel_is_inactive(void)
896+
static inline bool accel_is_inactive(void)
897897
{
898898
#ifdef ZEND_WIN32
899899
/* on Windows, we don't need kill_all_lockers() because SAPIs
@@ -904,7 +904,7 @@ static inline int accel_is_inactive(void)
904904
provide us with the PID of locker processes) */
905905

906906
if (LOCKVAL(mem_usage) == 0) {
907-
return SUCCESS;
907+
return true;
908908
}
909909
#else
910910
struct flock mem_usage_check;
@@ -916,10 +916,10 @@ static inline int accel_is_inactive(void)
916916
mem_usage_check.l_pid = -1;
917917
if (fcntl(lock_file, F_GETLK, &mem_usage_check) == -1) {
918918
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC: %s (%d)", strerror(errno), errno);
919-
return FAILURE;
919+
return false;
920920
}
921921
if (mem_usage_check.l_type == F_UNLCK) {
922-
return SUCCESS;
922+
return true;
923923
}
924924

925925
if (ZCG(accel_directives).force_restart_timeout
@@ -928,11 +928,11 @@ static inline int accel_is_inactive(void)
928928
zend_accel_error(ACCEL_LOG_WARNING, "Forced restart at %ld (after " ZEND_LONG_FMT " seconds), locked by %d", (long)time(NULL), ZCG(accel_directives).force_restart_timeout, mem_usage_check.l_pid);
929929
kill_all_lockers(&mem_usage_check);
930930

931-
return FAILURE; /* next request should be able to restart it */
931+
return false; /* next request should be able to restart it */
932932
}
933933
#endif
934934

935-
return FAILURE;
935+
return false;
936936
}
937937

938938
static int zend_get_stream_timestamp(const char *filename, zend_stat_t *statbuf)
@@ -2687,7 +2687,7 @@ zend_result accel_activate(INIT_FUNC_ARGS)
26872687
if (ZCSG(restart_pending)) {
26882688
zend_shared_alloc_lock();
26892689
if (ZCSG(restart_pending)) { /* check again, to ensure that the cache wasn't already cleaned by another process */
2690-
if (accel_is_inactive() == SUCCESS) {
2690+
if (accel_is_inactive()) {
26912691
zend_accel_error(ACCEL_LOG_DEBUG, "Restarting!");
26922692
ZCSG(restart_pending) = false;
26932693
switch ZCSG(restart_reason) {

0 commit comments

Comments
 (0)