wez             Thu Dec 18 06:23:22 2003 EDT

  Modified files:              
    /php-src/ext/com_dotnet     com_dotnet.c com_extension.c 
                                php_com_dotnet_internal.h 
  Log:
  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.
  
Index: php-src/ext/com_dotnet/com_dotnet.c
diff -u php-src/ext/com_dotnet/com_dotnet.c:1.2 php-src/ext/com_dotnet/com_dotnet.c:1.3
--- php-src/ext/com_dotnet/com_dotnet.c:1.2     Thu Aug 14 16:31:38 2003
+++ php-src/ext/com_dotnet/com_dotnet.c Thu Dec 18 06:23:21 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_dotnet.c,v 1.2 2003/08/14 20:31:38 wez Exp $ */
+/* $Id: com_dotnet.c,v 1.3 2003/12/18 11:23:21 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -49,7 +49,7 @@
        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 @@
                        ICorRuntimeHost_Stop(stuff->dotnet_host);
                        ICorRuntimeHost_Release(stuff->dotnet_host);
                }
-               efree(stuff);
+               free(stuff);
 
                return FAILURE;
        }
@@ -178,18 +178,30 @@
 }
 /* }}} */
 
+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: php-src/ext/com_dotnet/com_extension.c
diff -u php-src/ext/com_dotnet/com_extension.c:1.4 
php-src/ext/com_dotnet/com_extension.c:1.5
--- php-src/ext/com_dotnet/com_extension.c:1.4  Sat Dec  6 12:31:40 2003
+++ php-src/ext/com_dotnet/com_extension.c      Thu Dec 18 06:23:21 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_extension.c,v 1.4 2003/12/06 17:31:40 wez Exp $ */
+/* $Id: com_extension.c,v 1.5 2003/12/18 11:23:21 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -189,6 +189,12 @@
 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: php-src/ext/com_dotnet/php_com_dotnet_internal.h
diff -u php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.3 
php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.4
--- php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.3        Fri Oct 17 16:52:17 
2003
+++ php-src/ext/com_dotnet/php_com_dotnet_internal.h    Thu Dec 18 06:23:21 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_com_dotnet_internal.h,v 1.3 2003/10/17 20:52:17 wez Exp $ */
+/* $Id: php_com_dotnet_internal.h,v 1.4 2003/12/18 11:23:21 wez Exp $ */
 
 #ifndef PHP_COM_DOTNET_INTERNAL_H
 #define PHP_COM_DOTNET_INTERNAL_H
@@ -124,6 +124,7 @@
 /* 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);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to