]> granicus.if.org Git - php/commitdiff
Fix use of the CorRuntimeHost; once it has been stopped for a process, it cannot...
authorWez Furlong <wez@php.net>
Thu, 18 Dec 2003 11:23:21 +0000 (11:23 +0000)
committerWez Furlong <wez@php.net>
Thu, 18 Dec 2003 11:23:21 +0000 (11:23 +0000)
request shutdown.

ext/com_dotnet/com_dotnet.c
ext/com_dotnet/com_extension.c
ext/com_dotnet/php_com_dotnet_internal.h

index a30237dd697ee27313421b8f5b8fc05bb963aa68..9b39b678e46cf73123518e5e396eebecb1f80f5d 100644 (file)
@@ -49,7 +49,7 @@ static int dotnet_init(TSRMLS_D)
        IUnknown *unk = NULL;
        OLECHAR *olename;
 
-       stuff = emalloc(sizeof(*stuff));
+       stuff = malloc(sizeof(*stuff));
        memset(stuff, 0, sizeof(*stuff));
 
        if (SUCCEEDED(CoCreateInstance(&CLSID_CorRuntimeHost, NULL, CLSCTX_ALL,
@@ -84,7 +84,7 @@ static int dotnet_init(TSRMLS_D)
                        ICorRuntimeHost_Stop(stuff->dotnet_host);
                        ICorRuntimeHost_Release(stuff->dotnet_host);
                }
-               efree(stuff);
+               free(stuff);
 
                return FAILURE;
        }
@@ -178,18 +178,30 @@ PHP_FUNCTION(com_dotnet_create_instance)
 }
 /* }}} */
 
+void php_com_dotnet_mshutdown(TSRMLS_D)
+{
+       struct dotnet_runtime_stuff *stuff = COMG(dotnet_runtime_stuff);
+       
+       if (stuff->dotnet_domain) {
+               IDispatch_Release(stuff->dotnet_domain);
+       }
+       if (stuff->dotnet_host) {
+               ICorRuntimeHost_Stop(stuff->dotnet_host);
+               ICorRuntimeHost_Release(stuff->dotnet_host);
+               stuff->dotnet_host = NULL;
+       }
+       free(stuff);
+       COMG(dotnet_runtime_stuff) = NULL;
+}
 
 void php_com_dotnet_rshutdown(TSRMLS_D)
 {
        struct dotnet_runtime_stuff *stuff = COMG(dotnet_runtime_stuff);
        
-       IDispatch_Release(stuff->dotnet_domain);
-       ICorRuntimeHost_Stop(stuff->dotnet_host);
-       ICorRuntimeHost_Release(stuff->dotnet_host);
-
-       efree(stuff);
-
-       COMG(dotnet_runtime_stuff) = NULL;
+       if (stuff->dotnet_domain) {
+               IDispatch_Release(stuff->dotnet_domain);
+               stuff->dotnet_domain = NULL;
+       }
 }
 
 #endif /* HAVE_MSCOREE_H */
index 7ff7dbb0c47282fe95a4c8386be98b34ef2ffa5f..3c562672e9d62daf6afcd99924adc16796d36d4d 100644 (file)
@@ -189,6 +189,12 @@ PHP_MINIT_FUNCTION(com_dotnet)
 PHP_MSHUTDOWN_FUNCTION(com_dotnet)
 {
        UNREGISTER_INI_ENTRIES();
+#if HAVE_MSCOREE_H
+       if (COMG(dotnet_runtime_stuff)) {
+               php_com_dotnet_mshutdown(TSRMLS_C);
+       }
+#endif
+
        zend_ts_hash_destroy(&php_com_typelibraries);
        return SUCCESS;
 }
index 150a9257928b0bac32bb62c8f1f66589225e2347..7aae5b353870b98338b973cf8f1396aee7a6109d 100644 (file)
@@ -124,6 +124,7 @@ PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC
 /* com_dotnet.c */
 PHP_FUNCTION(com_dotnet_create_instance);
 void php_com_dotnet_rshutdown(TSRMLS_D);
+void php_com_dotnet_mshutdown(TSRMLS_D);
 
 /* com_misc.c */
 zval *php_com_throw_exception(char *message TSRMLS_DC);