summaryrefslogtreecommitdiffstats
path: root/69.patch
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2021-02-05 14:26:44 +0100
committerRemi Collet <remi@remirepo.net>2021-02-05 14:26:44 +0100
commit8df608aba06b851377a9d6e5a6085541725e11d2 (patch)
tree71d6ea6fb9af0d4d47e63018e0b1477896318739 /69.patch
parentcd3df9ea48899dee839edffe37c4677492c1a657 (diff)
add patch for PHP 8 / ZTS from
https://github.com/scoutapp/scout-apm-php-ext/pull/69
Diffstat (limited to '69.patch')
-rw-r--r--69.patch117
1 files changed, 117 insertions, 0 deletions
diff --git a/69.patch b/69.patch
new file mode 100644
index 0000000..3589d4b
--- /dev/null
+++ b/69.patch
@@ -0,0 +1,117 @@
+From 4d1ec38c5cdf104f4167faf47378c4f19e7c25b9 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Fri, 5 Feb 2021 12:05:28 +0100
+Subject: [PATCH 1/3] fix globals init and ZTS
+
+---
+ config.m4 | 2 +-
+ zend_scoutapm.c | 15 ++++++++++++++-
+ 2 files changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/config.m4 b/config.m4
+index 771fc1d..5e8d1d0 100644
+--- a/config.m4
++++ b/config.m4
+@@ -80,7 +80,7 @@ if test "$PHP_SCOUTAPM" != "no"; then
+ STD_CFLAGS="-g -O0 -Wall"
+ fi
+
+- PHP_SCOUTAPM_CFLAGS="$STD_CFLAGS $MAINTAINER_CFLAGS"
++ PHP_SCOUTAPM_CFLAGS="-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $STD_CFLAGS $MAINTAINER_CFLAGS"
+
+ PHP_NEW_EXTENSION(scoutapm, zend_scoutapm.c scout_curl_wrapper.c scout_file_wrapper.c scout_pdo_wrapper.c,
+ $ext_shared,,$PHP_SCOUTAPM_CFLAGS,,yes)
+diff --git a/zend_scoutapm.c b/zend_scoutapm.c
+index 739dc66..7139a52 100644
+--- a/zend_scoutapm.c
++++ b/zend_scoutapm.c
+@@ -82,6 +82,12 @@ PHP_MINFO_FUNCTION(scoutapm)
+ php_info_print_table_end();
+ }
+
++static
++PHP_GINIT_FUNCTION(scoutapm)
++{
++ scoutapm_globals->handlers_set = 0;
++}
++
+ /* scoutapm_module_entry provides the metadata/information for PHP about this PHP module */
+ static zend_module_entry scoutapm_module_entry = {
+ STANDARD_MODULE_HEADER,
+@@ -94,7 +100,7 @@ static zend_module_entry scoutapm_module_entry = {
+ PHP_MINFO(scoutapm), /* module information */
+ PHP_SCOUTAPM_VERSION, /* module version */
+ PHP_MODULE_GLOBALS(scoutapm), /* module global variables */
+- NULL,
++ PHP_GINIT(scoutapm), /* init global */
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
+@@ -105,6 +111,9 @@ static zend_module_entry scoutapm_module_entry = {
+ * Instead, see `zend_scoutapm_startup` - we load the module there.
+ ZEND_GET_MODULE(scoutapm);
+ */
++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS)
++ZEND_TSRMLS_CACHE_DEFINE()
++#endif
+
+ /* extension_version_info is used by PHP */
+ zend_extension_version_info extension_version_info = {
+@@ -178,6 +187,10 @@ static PHP_RINIT_FUNCTION(scoutapm)
+ int handler_index;
+ zend_class_entry *ce;
+
++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS)
++ ZEND_TSRMLS_CACHE_UPDATE();
++#endif
++
+ SCOUTAPM_DEBUG_MESSAGE("Initialising stacks...");
+ SCOUTAPM_G(observed_stack_frames_count) = 0;
+ SCOUTAPM_G(observed_stack_frames) = calloc(0, sizeof(scoutapm_stack_frame));
+
+From 2794f94a9ce0e30451a2d1fd64701e4500644453 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Fri, 5 Feb 2021 12:15:56 +0100
+Subject: [PATCH 2/3] zero all globals
+
+---
+ zend_scoutapm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/zend_scoutapm.c b/zend_scoutapm.c
+index 7139a52..2b70a07 100644
+--- a/zend_scoutapm.c
++++ b/zend_scoutapm.c
+@@ -85,7 +85,7 @@ PHP_MINFO_FUNCTION(scoutapm)
+ static
+ PHP_GINIT_FUNCTION(scoutapm)
+ {
+- scoutapm_globals->handlers_set = 0;
++ memset(scoutapm_globals, 0, sizeof(zend_scoutapm_globals));
+ }
+
+ /* scoutapm_module_entry provides the metadata/information for PHP about this PHP module */
+
+From 8330d02f790a0aa6f82a94d13b2b94a9d6f8a109 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Fri, 5 Feb 2021 14:15:59 +0100
+Subject: [PATCH 3/3] missing ZEND_TSRMLS_CACHE_UPDATE in GINIT
+
+---
+ zend_scoutapm.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/zend_scoutapm.c b/zend_scoutapm.c
+index 2b70a07..5be730b 100644
+--- a/zend_scoutapm.c
++++ b/zend_scoutapm.c
+@@ -85,6 +85,9 @@ PHP_MINFO_FUNCTION(scoutapm)
+ static
+ PHP_GINIT_FUNCTION(scoutapm)
+ {
++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS)
++ ZEND_TSRMLS_CACHE_UPDATE();
++#endif
+ memset(scoutapm_globals, 0, sizeof(zend_scoutapm_globals));
+ }
+