From aa3b2d1e865eae1204ae6339efec1b9338e2ffac Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Sat, 1 Jun 2019 00:25:11 -0700 Subject: [PATCH] PHP: Fix ZTS build shutdown segfault --- src/php/ext/grpc/php_grpc.c | 16 +++++++++++----- src/php/ext/grpc/php_grpc.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 74f536ea07b..6d66e790459 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -42,6 +42,8 @@ const zend_function_entry grpc_functions[] = { }; /* }}} */ +ZEND_DECLARE_MODULE_GLOBALS(grpc); + /* {{{ grpc_module_entry */ zend_module_entry grpc_module_entry = { @@ -77,10 +79,13 @@ ZEND_GET_MODULE(grpc) /* {{{ 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 @@ void apply_ini_settings(TSRMLS_D) { /* {{{ 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 @@ PHP_RINIT_FUNCTION(grpc) { */ 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 2629b1bbd78..1c7973b9ef8 100644 --- a/src/php/ext/grpc/php_grpc.h +++ b/src/php/ext/grpc/php_grpc.h @@ -70,6 +70,8 @@ ZEND_BEGIN_MODULE_GLOBALS(grpc) 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