Minor refactoring of main/main.c and TSRM (#8608)

This commit is contained in:
George Peter Banyard 2022-05-24 08:34:55 +01:00 committed by GitHub
parent 9f06bb3bb6
commit 5ba6ecd523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 69 additions and 77 deletions

View file

@ -112,11 +112,11 @@ static pthread_key_t tls_key;
# define tsrm_tls_get() pthread_getspecific(tls_key) # define tsrm_tls_get() pthread_getspecific(tls_key)
#endif #endif
TSRM_TLS uint8_t in_main_thread = 0; TSRM_TLS bool in_main_thread = false;
TSRM_TLS uint8_t is_thread_shutdown = 0; TSRM_TLS bool is_thread_shutdown = false;
/* Startup TSRM (call once for the entire process) */ /* Startup TSRM (call once for the entire process) */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename) TSRM_API bool tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename)
{/*{{{*/ {/*{{{*/
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
tls_key = TlsAlloc(); tls_key = TlsAlloc();
@ -125,8 +125,8 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
#endif #endif
/* ensure singleton */ /* ensure singleton */
in_main_thread = 1; in_main_thread = true;
is_thread_shutdown = 0; is_thread_shutdown = false;
tsrm_error_file = stderr; tsrm_error_file = stderr;
tsrm_error_set(debug_level, debug_filename); tsrm_error_set(debug_level, debug_filename);
@ -135,7 +135,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *)); tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
if (!tsrm_tls_table) { if (!tsrm_tls_table) {
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate TLS table")); TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate TLS table"));
is_thread_shutdown = 1; is_thread_shutdown = true;
return 0; return 0;
} }
id_count=0; id_count=0;
@ -144,7 +144,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type)); resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
if (!resource_types_table) { if (!resource_types_table) {
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate resource types table")); TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate resource types table"));
is_thread_shutdown = 1; is_thread_shutdown = true;
free(tsrm_tls_table); free(tsrm_tls_table);
return 0; return 0;
} }
@ -165,28 +165,24 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
/* Shutdown TSRM (call once for the entire process) */ /* Shutdown TSRM (call once for the entire process) */
TSRM_API void tsrm_shutdown(void) TSRM_API void tsrm_shutdown(void)
{/*{{{*/ {/*{{{*/
int i;
if (is_thread_shutdown) { if (is_thread_shutdown) {
/* shutdown must only occur once */ /* shutdown must only occur once */
return; return;
} }
is_thread_shutdown = 1; is_thread_shutdown = true;
if (!in_main_thread) { if (!in_main_thread) {
/* only the main thread may shutdown tsrm */ /* only the main thread may shutdown tsrm */
return; return;
} }
for (i=0; i<tsrm_tls_table_size; i++) { for (int i=0; i<tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i], *next_p; tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
while (p) { while (p) {
int j;
next_p = p->next; next_p = p->next;
for (j=0; j<p->count; j++) { for (int j=0; j<p->count; j++) {
if (p->storage[j]) { if (p->storage[j]) {
if (resource_types_table) { if (resource_types_table) {
if (!resource_types_table[j].done) { if (!resource_types_table[j].done) {
@ -244,9 +240,7 @@ TSRM_API void tsrm_env_unlock(void) {
/* enlarge the arrays for the already active threads */ /* enlarge the arrays for the already active threads */
static void tsrm_update_active_threads(void) static void tsrm_update_active_threads(void)
{/*{{{*/ {/*{{{*/
int i; for (int i=0; i<tsrm_tls_table_size; i++) {
for (i=0; i<tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i]; tsrm_tls_entry *p = tsrm_tls_table[i];
while (p) { while (p) {
@ -370,8 +364,6 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, siz
static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id) static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id)
{/*{{{*/ {/*{{{*/
int i;
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id)); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
(*thread_resources_ptr) = (tsrm_tls_entry *) malloc(TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_size); (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_size);
(*thread_resources_ptr)->storage = NULL; (*thread_resources_ptr)->storage = NULL;
@ -389,7 +381,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
if (tsrm_new_thread_begin_handler) { if (tsrm_new_thread_begin_handler) {
tsrm_new_thread_begin_handler(thread_id); tsrm_new_thread_begin_handler(thread_id);
} }
for (i=0; i<id_count; i++) { for (int i=0; i<id_count; i++) {
if (resource_types_table[i].done) { if (resource_types_table[i].done) {
(*thread_resources_ptr)->storage[i] = NULL; (*thread_resources_ptr)->storage[i] = NULL;
} else { } else {
@ -479,7 +471,6 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
void ts_free_thread(void) void ts_free_thread(void)
{/*{{{*/ {/*{{{*/
tsrm_tls_entry *thread_resources; tsrm_tls_entry *thread_resources;
int i;
THREAD_T thread_id = tsrm_thread_id(); THREAD_T thread_id = tsrm_thread_id();
int hash_value; int hash_value;
tsrm_tls_entry *last=NULL; tsrm_tls_entry *last=NULL;
@ -492,12 +483,12 @@ void ts_free_thread(void)
while (thread_resources) { while (thread_resources) {
if (thread_resources->thread_id == thread_id) { if (thread_resources->thread_id == thread_id) {
for (i=0; i<thread_resources->count; i++) { for (int i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) { if (resource_types_table[i].dtor) {
resource_types_table[i].dtor(thread_resources->storage[i]); resource_types_table[i].dtor(thread_resources->storage[i]);
} }
} }
for (i=0; i<thread_resources->count; i++) { for (int i=0; i<thread_resources->count; i++) {
if (!resource_types_table[i].fast_offset) { if (!resource_types_table[i].fast_offset) {
free(thread_resources->storage[i]); free(thread_resources->storage[i]);
} }
@ -523,34 +514,33 @@ void ts_free_thread(void)
/* deallocates all occurrences of a given id */ /* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id) void ts_free_id(ts_rsrc_id id)
{/*{{{*/ {/*{{{*/
int i; int rsrc_id = TSRM_UNSHUFFLE_RSRC_ID(id);
int j = TSRM_UNSHUFFLE_RSRC_ID(id);
tsrm_mutex_lock(tsmm_mutex); tsrm_mutex_lock(tsmm_mutex);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Freeing resource id %d", id)); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Freeing resource id %d", id));
if (tsrm_tls_table) { if (tsrm_tls_table) {
for (i=0; i<tsrm_tls_table_size; i++) { for (int i=0; i<tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i]; tsrm_tls_entry *p = tsrm_tls_table[i];
while (p) { while (p) {
if (p->count > j && p->storage[j]) { if (p->count > rsrc_id && p->storage[rsrc_id]) {
if (resource_types_table) { if (resource_types_table) {
if (resource_types_table[j].dtor) { if (resource_types_table[rsrc_id].dtor) {
resource_types_table[j].dtor(p->storage[j]); resource_types_table[rsrc_id].dtor(p->storage[rsrc_id]);
} }
if (!resource_types_table[j].fast_offset) { if (!resource_types_table[rsrc_id].fast_offset) {
free(p->storage[j]); free(p->storage[rsrc_id]);
} }
} }
p->storage[j] = NULL; p->storage[rsrc_id] = NULL;
} }
p = p->next; p = p->next;
} }
} }
} }
resource_types_table[j].done = 1; resource_types_table[rsrc_id].done = 1;
tsrm_mutex_unlock(tsmm_mutex); tsrm_mutex_unlock(tsmm_mutex);
@ -770,12 +760,12 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
#endif #endif
}/*}}}*/ }/*}}}*/
TSRM_API uint8_t tsrm_is_main_thread(void) TSRM_API bool tsrm_is_main_thread(void)
{/*{{{*/ {/*{{{*/
return in_main_thread; return in_main_thread;
}/*}}}*/ }/*}}}*/
TSRM_API uint8_t tsrm_is_shutdown(void) TSRM_API bool tsrm_is_shutdown(void)
{/*{{{*/ {/*{{{*/
return is_thread_shutdown; return is_thread_shutdown;
}/*}}}*/ }/*}}}*/

View file

@ -21,6 +21,7 @@
#endif #endif
#include "main/php_stdint.h" #include "main/php_stdint.h"
#include <stdbool.h>
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32
# ifdef TSRM_EXPORTS # ifdef TSRM_EXPORTS
@ -79,7 +80,7 @@ extern "C" {
#endif #endif
/* startup/shutdown */ /* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename); TSRM_API bool tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename);
TSRM_API void tsrm_shutdown(void); TSRM_API void tsrm_shutdown(void);
/* environ lock API */ /* environ lock API */
@ -133,8 +134,8 @@ TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler);
TSRM_API void *tsrm_get_ls_cache(void); TSRM_API void *tsrm_get_ls_cache(void);
TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void); TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void);
TSRM_API uint8_t tsrm_is_main_thread(void); TSRM_API bool tsrm_is_main_thread(void);
TSRM_API uint8_t tsrm_is_shutdown(void); TSRM_API bool tsrm_is_shutdown(void);
TSRM_API const char *tsrm_api_name(void); TSRM_API const char *tsrm_api_name(void);
#ifdef TSRM_WIN32 #ifdef TSRM_WIN32

View file

@ -358,7 +358,7 @@ static void php_binary_init(void)
binary_location = (char *)malloc(MAXPATHLEN); binary_location = (char *)malloc(MAXPATHLEN);
if (binary_location && !strchr(sapi_module.executable_location, '/')) { if (binary_location && !strchr(sapi_module.executable_location, '/')) {
char *envpath, *path; char *envpath, *path;
int found = 0; bool found = false;
if ((envpath = getenv("PATH")) != NULL) { if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN]; char *search_dir, search_path[MAXPATHLEN];
@ -371,7 +371,7 @@ static void php_binary_init(void)
while (search_dir) { while (search_dir) {
snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location); snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK) && VCWD_STAT(binary_location, &s) == 0 && S_ISREG(s.st_mode)) { if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK) && VCWD_STAT(binary_location, &s) == 0 && S_ISREG(s.st_mode)) {
found = 1; found = true;
break; break;
} }
search_dir = php_strtok_r(NULL, ":", &last); search_dir = php_strtok_r(NULL, ":", &last);
@ -768,26 +768,26 @@ PHP_INI_END()
/* True globals (no need for thread safety */ /* True globals (no need for thread safety */
/* But don't make them a single int bitfield */ /* But don't make them a single int bitfield */
static int module_initialized = 0; static bool module_initialized = false;
static int module_startup = 1; static bool module_startup = true;
static int module_shutdown = 0; static bool module_shutdown = false;
/* {{{ php_during_module_startup */ /* {{{ php_during_module_startup */
PHPAPI int php_during_module_startup(void) PHPAPI bool php_during_module_startup(void)
{ {
return module_startup; return module_startup;
} }
/* }}} */ /* }}} */
/* {{{ php_during_module_shutdown */ /* {{{ php_during_module_shutdown */
PHPAPI int php_during_module_shutdown(void) PHPAPI bool php_during_module_shutdown(void)
{ {
return module_shutdown; return module_shutdown;
} }
/* }}} */ /* }}} */
/* {{{ php_get_module_initialized */ /* {{{ php_get_module_initialized */
PHPAPI int php_get_module_initialized(void) PHPAPI bool php_get_module_initialized(void)
{ {
return module_initialized; return module_initialized;
} }
@ -1467,14 +1467,14 @@ PHP_FUNCTION(set_time_limit)
{ {
zend_long new_timeout; zend_long new_timeout;
char *new_timeout_str; char *new_timeout_str;
int new_timeout_strlen; size_t new_timeout_strlen;
zend_string *key; zend_string *key;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) {
RETURN_THROWS(); RETURN_THROWS();
} }
new_timeout_strlen = (int)zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout); new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0); key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0);
if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == SUCCESS) { if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == SUCCESS) {
@ -1694,9 +1694,9 @@ static void sigchld_handler(int apar)
#endif #endif
/* {{{ php_request_startup */ /* {{{ php_request_startup */
int php_request_startup(void) zend_result php_request_startup(void)
{ {
int retval = SUCCESS; zend_result retval = SUCCESS;
zend_interned_strings_activate(); zend_interned_strings_activate();
@ -1945,7 +1945,7 @@ PHP_MINFO_FUNCTION(php_core) { /* {{{ */
/* }}} */ /* }}} */
/* {{{ php_register_extensions */ /* {{{ php_register_extensions */
int php_register_extensions(zend_module_entry * const * ptr, int count) zend_result php_register_extensions(zend_module_entry * const * ptr, int count)
{ {
zend_module_entry * const * end = ptr + count; zend_module_entry * const * end = ptr + count;
@ -2032,8 +2032,8 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
} }
#endif #endif
module_shutdown = 0; module_shutdown = false;
module_startup = 1; module_startup = true;
sapi_initialize_empty_request(); sapi_initialize_empty_request();
sapi_activate(); sapi_activate();
@ -2270,7 +2270,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
/* Extensions that add engine hooks after this point do so at their own peril */ /* Extensions that add engine hooks after this point do so at their own peril */
zend_finalize_system_id(); zend_finalize_system_id();
module_initialized = 1; module_initialized = true;
if (zend_post_startup() != SUCCESS) { if (zend_post_startup() != SUCCESS) {
return FAILURE; return FAILURE;
@ -2343,7 +2343,7 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
virtual_cwd_deactivate(); virtual_cwd_deactivate();
sapi_deactivate(); sapi_deactivate();
module_startup = 0; module_startup = false;
/* Don't leak errors from startup into the per-request phase. */ /* Don't leak errors from startup into the per-request phase. */
clear_last_error(); clear_last_error();
@ -2376,7 +2376,7 @@ void php_module_shutdown(void)
{ {
int module_number=0; int module_number=0;
module_shutdown = 1; module_shutdown = true;
if (!module_initialized) { if (!module_initialized) {
return; return;
@ -2431,7 +2431,7 @@ void php_module_shutdown(void)
cb(); cb();
} }
module_initialized = 0; module_initialized = false;
#ifndef ZTS #ifndef ZTS
core_globals_dtor(&core_globals); core_globals_dtor(&core_globals);
@ -2451,7 +2451,7 @@ void php_module_shutdown(void)
/* }}} */ /* }}} */
/* {{{ php_execute_script */ /* {{{ php_execute_script */
PHPAPI int php_execute_script(zend_file_handle *primary_file) PHPAPI bool php_execute_script(zend_file_handle *primary_file)
{ {
zend_file_handle *prepend_file_p = NULL, *append_file_p = NULL; zend_file_handle *prepend_file_p = NULL, *append_file_p = NULL;
zend_file_handle prepend_file, append_file; zend_file_handle prepend_file, append_file;
@ -2461,7 +2461,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
char *old_cwd; char *old_cwd;
ALLOCA_FLAG(use_heap) ALLOCA_FLAG(use_heap)
#endif #endif
int retval = 0; bool retval = false;
#ifndef HAVE_BROKEN_GETCWD #ifndef HAVE_BROKEN_GETCWD
# define OLD_CWD_SIZE 4096 # define OLD_CWD_SIZE 4096
@ -2644,10 +2644,10 @@ PHPAPI int php_handle_auth_data(const char *auth)
/* }}} */ /* }}} */
/* {{{ php_lint_script */ /* {{{ php_lint_script */
PHPAPI int php_lint_script(zend_file_handle *file) PHPAPI zend_result php_lint_script(zend_file_handle *file)
{ {
zend_op_array *op_array; zend_op_array *op_array;
int retval = FAILURE; zend_result retval = FAILURE;
zend_try { zend_try {
op_array = zend_compile_file(file, ZEND_INCLUDE); op_array = zend_compile_file(file, ZEND_INCLUDE);
@ -2688,9 +2688,9 @@ PHPAPI void php_reserve_tsrm_memory(void)
/* }}} */ /* }}} */
/* {{{ php_tsrm_startup */ /* {{{ php_tsrm_startup */
PHPAPI int php_tsrm_startup(void) PHPAPI bool php_tsrm_startup(void)
{ {
int ret = tsrm_startup(1, 1, 0, NULL); bool ret = tsrm_startup(1, 1, 0, NULL);
php_reserve_tsrm_memory(); php_reserve_tsrm_memory();
(void)ts_resource(0); (void)ts_resource(0);
return ret; return ret;

View file

@ -297,9 +297,9 @@ void phperror(char *error);
PHPAPI size_t php_write(void *buf, size_t size); PHPAPI size_t php_write(void *buf, size_t size);
PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2); PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
PHPAPI size_t php_printf_unchecked(const char *format, ...); PHPAPI size_t php_printf_unchecked(const char *format, ...);
PHPAPI int php_during_module_startup(void); PHPAPI bool php_during_module_startup(void);
PHPAPI int php_during_module_shutdown(void); PHPAPI bool php_during_module_shutdown(void);
PHPAPI int php_get_module_initialized(void); PHPAPI bool php_get_module_initialized(void);
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
#include "php_syslog.h" #include "php_syslog.h"
#define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE) #define php_log_err(msg) php_log_err_with_severity(msg, LOG_NOTICE)

View file

@ -23,24 +23,23 @@
#include "SAPI.h" #include "SAPI.h"
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
PHPAPI int php_request_startup(void); PHPAPI zend_result php_request_startup(void);
PHPAPI void php_request_shutdown(void *dummy); PHPAPI void php_request_shutdown(void *dummy);
PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module); PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module);
PHPAPI void php_module_shutdown(void); PHPAPI void php_module_shutdown(void);
PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals); PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
PHPAPI int php_register_extensions(zend_module_entry * const * ptr, int count); PHPAPI zend_result php_register_extensions(zend_module_entry * const * ptr, int count);
PHPAPI int php_execute_script(zend_file_handle *primary_file); PHPAPI bool php_execute_script(zend_file_handle *primary_file);
PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret); PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret);
PHPAPI int php_handle_special_queries(void); PHPAPI zend_result php_lint_script(zend_file_handle *file);
PHPAPI int php_lint_script(zend_file_handle *file);
PHPAPI void php_handle_aborted_connection(void); PHPAPI void php_handle_aborted_connection(void);
PHPAPI int php_handle_auth_data(const char *auth); PHPAPI int php_handle_auth_data(const char *auth);
PHPAPI void php_html_puts(const char *str, size_t siz); PHPAPI void php_html_puts(const char *str, size_t siz);
PHPAPI int php_stream_open_for_zend_ex(zend_file_handle *handle, int mode); PHPAPI zend_result php_stream_open_for_zend_ex(zend_file_handle *handle, int mode);
/* environment module */ /* environment module */
extern int php_init_environ(void); extern int php_init_environ(void);
@ -48,7 +47,7 @@ extern int php_shutdown_environ(void);
#ifdef ZTS #ifdef ZTS
PHPAPI void php_reserve_tsrm_memory(void); PHPAPI void php_reserve_tsrm_memory(void);
PHPAPI int php_tsrm_startup(void); PHPAPI bool php_tsrm_startup(void);
#endif #endif
END_EXTERN_C() END_EXTERN_C()

View file

@ -2501,11 +2501,12 @@ parent_loop_end:
break; break;
case PHP_MODE_LINT: case PHP_MODE_LINT:
PG(during_request_startup) = 0; PG(during_request_startup) = 0;
exit_status = php_lint_script(&file_handle); if (php_lint_script(&file_handle) == SUCCESS) {
if (exit_status == SUCCESS) {
zend_printf("No syntax errors detected in %s\n", ZSTR_VAL(file_handle.filename)); zend_printf("No syntax errors detected in %s\n", ZSTR_VAL(file_handle.filename));
exit_status = 0;
} else { } else {
zend_printf("Errors parsing %s\n", ZSTR_VAL(file_handle.filename)); zend_printf("Errors parsing %s\n", ZSTR_VAL(file_handle.filename));
exit_status = -1;
} }
break; break;
case PHP_MODE_STRIP: case PHP_MODE_STRIP:

View file

@ -966,11 +966,12 @@ do_repeat:
} }
break; break;
case PHP_MODE_LINT: case PHP_MODE_LINT:
EG(exit_status) = php_lint_script(&file_handle); if (php_lint_script(&file_handle) == SUCCESS) {
if (EG(exit_status) == SUCCESS) {
zend_printf("No syntax errors detected in %s\n", php_self); zend_printf("No syntax errors detected in %s\n", php_self);
EG(exit_status) = 0;
} else { } else {
zend_printf("Errors parsing %s\n", php_self); zend_printf("Errors parsing %s\n", php_self);
EG(exit_status) = 255;
} }
break; break;
case PHP_MODE_STRIP: case PHP_MODE_STRIP: