Re: [PATCH] Automatic module globals management

From: Date: Thu, 08 Jun 2006 18:03:29 +0000
Subject: Re: [PATCH] Automatic module globals management
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-23998@lists.php.net to get a copy of this message
I read the whole thread. I agree with Sara. While I understand where Steph is coming from, I still think this is a good change. It would allow us to use this method in the current tree right away, and for PECL authors who want to stay compatible with older versions they can use the old & ugly way of doing it until they feel comfortable in changing over. I also second Sara on the naming changes of the macros. They ones suggested by Dmitry didn't appeal to me either :) Andi At 05:15 AM 6/8/2006, Dmitry Stogov wrote:
Hi, The attached patch (for PHP_5_2) implements automatic management of module globals. The problem that module globals must be unregistered before extension unloading, because "globls_dtor" function is unloaded together with extension and cannot be called. To solve this problem extension writers now use the following pattern: PHP_MSHUTDOWN_FUNCTION(mod_name) { -#ifdef ZTS
-       ts_free_id(mod_name_globals_id);
-#else
-       mod_name_globals_dtor(&mod_name_globals TSRMLS_CC);
-#endif With my patch, extension writers should just extend module descriptor with globals descriptor and ctor/dtor callbacks.
        PHP_RSHUTDOWN(mod_name),
        PHP_MINFO(mod_name),
        NO_VERSION_YET,
-       STANDARD_MODULE_PROPERTIES
+       NULL,
+       ZEND_MG(mod_name),
+       ZEND_MGCTOR(mod_name),
+       ZEND_MGCTOR(mod_name),
+       STANDARD_MODULE_PROPERTIES_EX2
}; Old extensions are source compatible and may work without modification. The patch modifies only several extensions, but will modify others too. I like commit the patch into HEAD and PHP_5_2. Any objections, additional ideas? Thanks. Dmitry.


« previous php.internals (#23998) next »