PHP: Fix ZTS build shutdown segfault
diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c
index 74f536e..6d66e79 100644
--- a/src/php/ext/grpc/php_grpc.c
+++ b/src/php/ext/grpc/php_grpc.c
@@ -42,6 +42,8 @@
};
/* }}} */
+ZEND_DECLARE_MODULE_GLOBALS(grpc);
+
/* {{{ grpc_module_entry
*/
zend_module_entry grpc_module_entry = {
@@ -77,10 +79,13 @@
/* {{{ php_grpc_init_globals
*/
-static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) {
- grpc_globals->enable_fork_support = 0;
- grpc_globals->poll_strategy = NULL;
-}
+/* Uncomment this function if you have INI entries
+ static void php_grpc_init_globals(zend_grpc_globals *grpc_globals)
+ {
+ grpc_globals->global_value = 0;
+ grpc_globals->global_string = NULL;
+ }
+*/
/* }}} */
void create_new_channel(
@@ -222,7 +227,6 @@
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(grpc) {
- ZEND_INIT_MODULE_GLOBALS(grpc, php_grpc_init_globals, NULL);
REGISTER_INI_ENTRIES();
/* Register call error constants */
@@ -406,6 +410,8 @@
*/
static PHP_GINIT_FUNCTION(grpc) {
grpc_globals->initialized = 0;
+ grpc_globals->enable_fork_support = 0;
+ grpc_globals->poll_strategy = NULL;
}
/* }}} */
diff --git a/src/php/ext/grpc/php_grpc.h b/src/php/ext/grpc/php_grpc.h
index 2629b1b..1c7973b 100644
--- a/src/php/ext/grpc/php_grpc.h
+++ b/src/php/ext/grpc/php_grpc.h
@@ -70,6 +70,8 @@
char *poll_strategy;
ZEND_END_MODULE_GLOBALS(grpc)
+ZEND_EXTERN_MODULE_GLOBALS(grpc);
+
/* In every utility function you add that needs to use variables
in php_grpc_globals, call TSRMLS_FETCH(); after declaring other
variables used by that function, or better yet, pass in TSRMLS_CC