summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-12-18 11:23:21 +0000
committerWez Furlong <wez@php.net>2003-12-18 11:23:21 +0000
commit09907c6b93c07894f0bda63f489f61fac57ef768 (patch)
tree4efcd732c99eea209cb6e3642909d6d7b4b5469a
parent48a2b2a3d30f6a89b2fa5dfc6cfdaeef0bdf621c (diff)
downloadphp-git-09907c6b93c07894f0bda63f489f61fac57ef768.tar.gz
Fix use of the CorRuntimeHost; once it has been stopped for a process, it cannot be restarted, so we keep it alive for the duration of the process, and instead close down the application domain in
request shutdown.
-rw-r--r--ext/com_dotnet/com_dotnet.c30
-rw-r--r--ext/com_dotnet/com_extension.c6
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h1
3 files changed, 28 insertions, 9 deletions
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c
index a30237dd69..9b39b678e4 100644
--- a/ext/com_dotnet/com_dotnet.c
+++ b/ext/com_dotnet/com_dotnet.c
@@ -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 */
diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
index 7ff7dbb0c4..3c562672e9 100644
--- a/ext/com_dotnet/com_extension.c
+++ b/ext/com_dotnet/com_extension.c
@@ -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;
}
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index 150a925792..7aae5b3538 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -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);