Compatible with dl()
@@ -166,6 +166,25 @@ PHP_MINIT_FUNCTION(swow)
}
/* }}} */
+#define SWOW_COMPATIBLE_WITH_DL 1 // TODO: fix it in php-src
+#ifdef SWOW_COMPATIBLE_WITH_DL
+static int swow_clean_module_function(zval *el, void *arg)
+{
+ zend_function *fe = (zend_function *) Z_PTR_P(el);
+ int module_number = *(int *)arg;
+ if (fe->common.type == ZEND_INTERNAL_FUNCTION && fe->internal_function.module->module_number == module_number) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+}
+
+static void swow_clean_module_functions(int module_number)
+{
+ zend_hash_apply_with_argument(CG(function_table), swow_clean_module_function, (void *) &module_number);
+}
+#endif
+
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(swow)
@@ -186,6 +205,12 @@ PHP_MSHUTDOWN_FUNCTION(swow)
}
}
+#ifdef SWOW_COMPATIBLE_WITH_DL
+ if (type == MODULE_TEMPORARY) {
+ swow_clean_module_functions(module_number);
+ }
+#endif
+
swow_wrapper_shutdown();
return SUCCESS;
