|  | @@ -67,27 +67,22 @@ ZEND_GET_MODULE(grpc)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* {{{ PHP_INI
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -/* Remove comments and fill if you need to have entries in php.ini
 | 
	
		
			
				|  |  |     PHP_INI_BEGIN()
 | 
	
		
			
				|  |  | -   STD_PHP_INI_ENTRY("grpc.global_value", "42", PHP_INI_ALL, OnUpdateLong,
 | 
	
		
			
				|  |  | -                     global_value, zend_grpc_globals, grpc_globals)
 | 
	
		
			
				|  |  | -   STD_PHP_INI_ENTRY("grpc.global_string", "foobar", PHP_INI_ALL,
 | 
	
		
			
				|  |  | -                     OnUpdateString, global_string, zend_grpc_globals,
 | 
	
		
			
				|  |  | -                     grpc_globals)
 | 
	
		
			
				|  |  | +   STD_PHP_INI_ENTRY("grpc.enable_fork_support", "0", PHP_INI_SYSTEM, OnUpdateBool,
 | 
	
		
			
				|  |  | +                     enable_fork_support, zend_grpc_globals, grpc_globals)
 | 
	
		
			
				|  |  | +   STD_PHP_INI_ENTRY("grpc.poll_strategy", NULL, PHP_INI_SYSTEM, OnUpdateString,
 | 
	
		
			
				|  |  | +                     poll_strategy, zend_grpc_globals, grpc_globals)
 | 
	
		
			
				|  |  |     PHP_INI_END()
 | 
	
		
			
				|  |  | -*/
 | 
	
		
			
				|  |  |  /* }}} */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* {{{ php_grpc_init_globals
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -/* 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;
 | 
	
		
			
				|  |  | -   }
 | 
	
		
			
				|  |  | -*/
 | 
	
		
			
				|  |  | +static void php_grpc_init_globals(zend_grpc_globals *grpc_globals) {
 | 
	
		
			
				|  |  | +  grpc_globals->enable_fork_support = 0;
 | 
	
		
			
				|  |  | +  grpc_globals->poll_strategy = NULL;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  /* }}} */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  void create_new_channel(
 | 
	
		
			
				|  |  |      wrapped_grpc_channel *channel,
 | 
	
		
			
				|  |  |      char *target,
 | 
	
	
		
			
				|  | @@ -208,12 +203,22 @@ void register_fork_handlers() {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +void apply_ini_settings() {
 | 
	
		
			
				|  |  | +  if (GRPC_G(enable_fork_support)) {
 | 
	
		
			
				|  |  | +    setenv("GRPC_ENABLE_FORK_SUPPORT", "1", 1 /* overwrite? */);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  if (GRPC_G(poll_strategy)) {
 | 
	
		
			
				|  |  | +    setenv("GRPC_POLL_STRATEGY", GRPC_G(poll_strategy), 1 /* overwrite? */);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /* {{{ PHP_MINIT_FUNCTION
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  PHP_MINIT_FUNCTION(grpc) {
 | 
	
		
			
				|  |  | -  /* If you have INI entries, uncomment these lines
 | 
	
		
			
				|  |  | -     REGISTER_INI_ENTRIES();
 | 
	
		
			
				|  |  | -  */
 | 
	
		
			
				|  |  | +  ZEND_INIT_MODULE_GLOBALS(grpc, php_grpc_init_globals, NULL);
 | 
	
		
			
				|  |  | +  REGISTER_INI_ENTRIES();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    /* Register call error constants */
 | 
	
		
			
				|  |  |    REGISTER_LONG_CONSTANT("Grpc\\CALL_OK", GRPC_CALL_OK,
 | 
	
		
			
				|  |  |                           CONST_CS | CONST_PERSISTENT);
 | 
	
	
		
			
				|  | @@ -349,9 +354,7 @@ PHP_MINIT_FUNCTION(grpc) {
 | 
	
		
			
				|  |  |  /* {{{ PHP_MSHUTDOWN_FUNCTION
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  PHP_MSHUTDOWN_FUNCTION(grpc) {
 | 
	
		
			
				|  |  | -  /* uncomment this line if you have INI entries
 | 
	
		
			
				|  |  | -     UNREGISTER_INI_ENTRIES();
 | 
	
		
			
				|  |  | -  */
 | 
	
		
			
				|  |  | +  UNREGISTER_INI_ENTRIES();
 | 
	
		
			
				|  |  |    // WARNING: This function IS being called by PHP when the extension
 | 
	
		
			
				|  |  |    // is unloaded but the logs were somehow suppressed.
 | 
	
		
			
				|  |  |    if (GRPC_G(initialized)) {
 | 
	
	
		
			
				|  | @@ -375,9 +378,7 @@ PHP_MINFO_FUNCTION(grpc) {
 | 
	
		
			
				|  |  |    php_info_print_table_row(2, "grpc support", "enabled");
 | 
	
		
			
				|  |  |    php_info_print_table_row(2, "grpc module version", PHP_GRPC_VERSION);
 | 
	
		
			
				|  |  |    php_info_print_table_end();
 | 
	
		
			
				|  |  | -  /* Remove comments if you have entries in php.ini
 | 
	
		
			
				|  |  | -     DISPLAY_INI_ENTRIES();
 | 
	
		
			
				|  |  | -  */
 | 
	
		
			
				|  |  | +  DISPLAY_INI_ENTRIES();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  /* }}} */
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -385,6 +386,7 @@ PHP_MINFO_FUNCTION(grpc) {
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  PHP_RINIT_FUNCTION(grpc) {
 | 
	
		
			
				|  |  |    if (!GRPC_G(initialized)) {
 | 
	
		
			
				|  |  | +    apply_ini_settings();
 | 
	
		
			
				|  |  |      grpc_init();
 | 
	
		
			
				|  |  |      register_fork_handlers();
 | 
	
		
			
				|  |  |      grpc_php_init_completion_queue(TSRMLS_C);
 |