]> granicus.if.org Git - php/commitdiff
Fixed bug #26968 (Segfault with Interbase module built as shared)
authorArd Biesheuvel <abies@php.net>
Wed, 21 Jan 2004 10:12:17 +0000 (10:12 +0000)
committerArd Biesheuvel <abies@php.net>
Wed, 21 Jan 2004 10:12:17 +0000 (10:12 +0000)
NEWS
ext/interbase/interbase.c

diff --git a/NEWS b/NEWS
index 6713055e762d8c7cb3c5172278c728c229aaf0fe..8f064ab6ad9946766c935bf68dac3553f244292b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP 4                                                                      NEWS
   safe_mode/open_basedir). (Ilia)
 - Fixed bug #26973 (*printf() '+' modifier broken). (Jani)
 - Fixed bug #26969 (--with-openssl=shared build fails). (Jani)
+- Fixed bug #26968 (Segfault with Interbase module built as shared). (Ard)
 - Fixed bug #26949 (rand(min,max) always returns min when ZTS enabled). (Jani)
 - Fixed bug #26937 (Warning in xml.c). (Jani)
 - Fixed Bug #26927 (preg_quote() does not escape \0). (Ilia)
index 3e1ff95b3ace00ddb4552a1590d01e796b8fcc3b..81a37640fd150f889f482b1913bbf7d05cc030db 100644 (file)
@@ -594,6 +594,25 @@ PHP_RINIT_FUNCTION(ibase)
 
 PHP_MSHUTDOWN_FUNCTION(ibase)
 {
+#ifndef PHP_WIN32
+       /**
+        * When the Interbase client API library libgds.so is first loaded, it registers a call to 
+        * gds__cleanup() with atexit(), in order to clean up after itself when the process exits.
+        * This means that the library is called at process shutdown, and cannot be unloaded beforehand.
+        * PHP tries to unload modules after every request [dl()'ed modules], and right before the 
+        * process shuts down [modules loaded from php.ini]. This results in a segfault for this module.
+        * By NULLing the dlopen() handle in the module entry, Zend omits the call to dlclose(),
+        * ensuring that the module will remain present until the process exits. However, the functions
+        * and classes exported by the module will not be available until the module is 'reloaded'. 
+        * When reloaded, dlopen() will return the handle of the already loaded module. The module will
+        * be unloaded automatically when the process exits.
+        */
+       zend_module_entry *ibase_entry;
+       if (SUCCESS == zend_hash_find(&module_registry, ibase_module_entry.name, strlen(ibase_module_entry.name) +1, (void*) &ibase_entry))
+       {
+               ibase_entry->handle = NULL;
+       }
+#endif
        UNREGISTER_INI_ENTRIES();
        return SUCCESS;
 }