summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-29 16:58:29 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-29 17:14:40 +0200
commit6df1665bb3d5b5d8f799ec40b27463df2b630c51 (patch)
tree1d0f81af278bafa82425e12eb4a00bc2f14e61c1
parent94924841ac42b9ef4445abfbe7d5d77c93e181f0 (diff)
parentbbed5564eb8155efb14146e11ef0ad67edb20e28 (diff)
downloadphp-git-6df1665bb3d5b5d8f799ec40b27463df2b630c51.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
-rw-r--r--Zend/zend_signal.c21
-rw-r--r--ext/opcache/ZendAccelerator.c14
-rw-r--r--main/main.c5
3 files changed, 34 insertions, 6 deletions
diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c
index 703097eeb5..96870f8d5c 100644
--- a/Zend/zend_signal.c
+++ b/Zend/zend_signal.c
@@ -328,13 +328,13 @@ void zend_signal_activate(void)
SIGG(active) = 1;
SIGG(depth) = 0;
+ SIGG(check) = ZEND_DEBUG;
} /* }}} */
/* {{{ zend_signal_deactivate
* */
void zend_signal_deactivate(void)
{
-
if (SIGG(check)) {
size_t x;
struct sigaction sa;
@@ -342,21 +342,32 @@ void zend_signal_deactivate(void)
if (SIGG(depth) != 0) {
zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth));
}
+
/* did anyone steal our installed handler */
for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
sigaction(zend_sigs[x], NULL, &sa);
- if (sa.sa_sigaction != zend_signal_handler_defer) {
+ if (sa.sa_sigaction != zend_signal_handler_defer &&
+ sa.sa_sigaction != (void *) SIG_IGN) {
zend_error(E_CORE_WARNING, "zend_signal: handler was replaced for signal (%d) after startup", zend_sigs[x]);
}
}
}
- SIGNAL_BEGIN_CRITICAL();
- SIGG(active) = 0;
+ /* After active=0 is set, signal handlers will be called directly and other
+ * state that is reset below will not be accessed. */
+ *((volatile int *) &SIGG(active)) = 0;
+
SIGG(running) = 0;
SIGG(blocked) = 0;
SIGG(depth) = 0;
- SIGNAL_END_CRITICAL();
+
+ /* If there are any queued signals because of a missed unblock, drop them. */
+ if (SIGG(phead) && SIGG(ptail)) {
+ SIGG(ptail)->next = SIGG(pavail);
+ SIGG(pavail) = SIGG(phead);
+ SIGG(phead) = NULL;
+ SIGG(ptail) = NULL;
+ }
}
/* }}} */
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 0c3109ee50..8efc340065 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -1686,7 +1686,9 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
/* check blacklist right after ensuring that file was opened */
if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, ZSTR_VAL(file_handle->opened_path), ZSTR_LEN(file_handle->opened_path))) {
+ SHM_UNPROTECT();
ZCSG(blacklist_misses)++;
+ SHM_PROTECT();
*op_array_p = accelerator_orig_compile_file(file_handle, type);
return NULL;
}
@@ -1717,7 +1719,9 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
}
if (ZCG(accel_directives).max_file_size > 0 && size > (size_t)ZCG(accel_directives).max_file_size) {
+ SHM_UNPROTECT();
ZCSG(blacklist_misses)++;
+ SHM_PROTECT();
*op_array_p = accelerator_orig_compile_file(file_handle, type);
return NULL;
}
@@ -2107,11 +2111,16 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
return accelerator_orig_compile_file(file_handle, type);
}
+ SHM_PROTECT();
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+ persistent_script = opcache_compile_file(file_handle, type, key, &op_array);
+ HANDLE_BLOCK_INTERRUPTIONS();
+ SHM_UNPROTECT();
+
/* Try and cache the script and assume that it is returned from_shared_memory.
* If it isn't compile_and_cache_file() changes the flag to 0
*/
from_shared_memory = 0;
- persistent_script = opcache_compile_file(file_handle, type, key, &op_array);
if (persistent_script) {
persistent_script = cache_script_in_shared_memory(persistent_script, key, key ? key_length : 0, &from_shared_memory);
}
@@ -4533,6 +4542,9 @@ static int accel_finish_startup(void)
orig_report_memleaks = PG(report_memleaks);
PG(report_memleaks) = 0;
+ /* We may not have registered signal handlers due to SIGG(reset)=0, so
+ * also disable the check that they are registered. */
+ SIGG(check) = 0;
php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */
PG(report_memleaks) = orig_report_memleaks;
} else {
diff --git a/main/main.c b/main/main.c
index 9c8e83cc42..5822cbfa21 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1940,6 +1940,11 @@ void php_request_shutdown(void *dummy)
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
} zend_end_try();
+ /* 16. Deactivate Zend signals */
+#ifdef ZEND_SIGNALS
+ zend_signal_deactivate();
+#endif
+
#ifdef PHP_WIN32
if (PG(com_initialized)) {
CoUninitialize();