Skip to content

Commit f6f8018

Browse files
committed
Use self describing constants for fpm_php_apply_defines_ex result
1 parent 7283065 commit f6f8018

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sapi/fpm/fpm/fpm_php.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ static void fpm_php_disable(char *value, int (*zend_disable)(const char *, size_
7777
}
7878
/* }}} */
7979

80+
#define FPM_PHP_INI_ALTERING_ERROR -1
81+
#define FPM_PHP_INI_APPLIED 1
82+
#define FPM_PHP_INI_EXTENSION_FAILED 0
83+
#define FPM_PHP_INI_EXTENSION_LOADED 2
84+
8085
int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
8186
{
8287

@@ -90,26 +95,26 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
9095
zend_interned_strings_switch_storage(0);
9196
php_dl(value, MODULE_PERSISTENT, &zv, 1);
9297
zend_interned_strings_switch_storage(1);
93-
return Z_TYPE(zv) == IS_TRUE ? 2 : 0;
98+
return Z_TYPE(zv) == IS_TRUE ? FPM_PHP_INI_EXTENSION_LOADED : FPM_PHP_INI_EXTENSION_FAILED;
9499
}
95100

96101
if (fpm_php_zend_ini_alter_master(name, name_len, value, value_len, mode, PHP_INI_STAGE_ACTIVATE) == FAILURE) {
97-
return -1;
102+
return FPM_PHP_INI_ALTERING_ERROR;
98103
}
99104

100105
if (!strcmp(name, "disable_functions") && *value) {
101106
zend_disable_functions(value);
102-
return 1;
107+
return FPM_PHP_INI_APPLIED;
103108
}
104109

105110
if (!strcmp(name, "disable_classes") && *value) {
106111
char *v = strdup(value);
107112
PG(disable_classes) = v;
108113
fpm_php_disable(v, zend_disable_class);
109-
return 1;
114+
return FPM_PHP_INI_APPLIED;
110115
}
111116

112-
return 1;
117+
return FPM_PHP_INI_APPLIED;
113118
}
114119
/* }}} */
115120

@@ -121,24 +126,23 @@ static int fpm_php_apply_defines(struct fpm_worker_pool_s *wp) /* {{{ */
121126

122127
for (kv = wp->config->php_values; kv; kv = kv->next) {
123128
apply_result = fpm_php_apply_defines_ex(kv, ZEND_INI_USER);
124-
if (apply_result == -1) {
129+
if (apply_result == FPM_PHP_INI_ALTERING_ERROR) {
125130
zlog(ZLOG_ERROR, "Unable to set php_value '%s'", kv->key);
126-
} else if (apply_result == 2) {
131+
} else if (apply_result == FPM_PHP_INI_EXTENSION_LOADED) {
127132
extension_loaded = true;
128133
}
129134
}
130135

131136
for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
132137
apply_result = fpm_php_apply_defines_ex(kv, ZEND_INI_SYSTEM);
133-
if (apply_result == -1) {
138+
if (apply_result == FPM_PHP_INI_ALTERING_ERROR) {
134139
zlog(ZLOG_ERROR, "Unable to set php_admin_value '%s'", kv->key);
135-
} else if (apply_result == 2) {
140+
} else if (apply_result == FPM_PHP_INI_EXTENSION_LOADED) {
136141
extension_loaded = true;
137142
}
138143
}
139144

140145
if (extension_loaded) {
141-
zend_destroy_module_handlers();
142146
zend_collect_module_handlers();
143147
}
144148

0 commit comments

Comments
 (0)