]> granicus.if.org Git - php/commitdiff
Fix ZTS issue regarding new Windows CTRL handling API
authorChristoph M. Becker <cmbecker69@gmx.de>
Sat, 1 Jun 2019 07:08:51 +0000 (09:08 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sat, 1 Jun 2019 07:35:47 +0000 (09:35 +0200)
php_win32_signal_system_ctrl_handler() is called from a kernel thread,
so the former initialization of `vm_interrupt_flag` has no effect,
since it is defined as thread-local.  This is, however, not necessary,
since the CTRL signal handling is supposed to work only for the main
thread anyway.  We therefore change `vm_interrupt_flag` and the related
variables to true globals.

This also allows us to unmark the respective test case as XFAIL.

Furthermore, `vm_interrupt_flag` is declared as `zend_bool *`, so we
better treat it such.

sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt
win32/signal.c

index 083ed8fd0cdd0726f4fd3f6dac7b64c03f407f28..a5cb3ef03e40462c1bd87e82fc4f06d56ed87f62 100644 (file)
@@ -8,8 +8,6 @@ include "skipinf.inc";
 if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
   die("skip this test is for Windows platforms only");
 ?>
---XFAIL--
-Fails on AppVeyor
 --FILE--
 <?php
 
index 586e125eb0eb8d4b79868841eda111b9261cd2d6..bdfd7033f3894c1bd783cb2002f86cdd47707035 100644 (file)
 
 #include "win32/console.h"
 
-ZEND_TLS zval ctrl_handler;
-ZEND_TLS DWORD ctrl_evt = (DWORD)-1;
-ZEND_TLS zend_bool *vm_interrupt_flag = NULL;
+/* true globals; only used from main thread and from kernel callback */
+static zval ctrl_handler;
+static DWORD ctrl_evt = (DWORD)-1;
+static zend_bool *vm_interrupt_flag = NULL;
 
 static void (*orig_interrupt_function)(zend_execute_data *execute_data);
 
@@ -78,7 +79,7 @@ static BOOL WINAPI php_win32_signal_system_ctrl_handler(DWORD evt)
                return FALSE;
        }
 
-       (void)InterlockedExchange((LONG*)vm_interrupt_flag, 1);
+       (void)InterlockedExchange8(vm_interrupt_flag, 1);
 
        ctrl_evt = evt;