dmitry Fri Nov 17 11:41:13 2006 UTC
Modified files:
/php-src/main main.c php.h php_globals.h
/php-src/ext/com_dotnet com_com.c com_dotnet.c com_handlers.c
com_variant.c
Log:
COM initialization/deinitialization are done only if necessary
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.707&r2=1.708&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.707 php-src/main/main.c:1.708
--- php-src/main/main.c:1.707 Fri Nov 17 10:48:53 2006
+++ php-src/main/main.c Fri Nov 17 11:41:13 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.707 2006/11/17 10:48:53 dmitry Exp $ */
+/* $Id: main.c,v 1.708 2006/11/17 11:41:13 dmitry Exp $ */
/* {{{ includes
*/
@@ -1182,7 +1182,7 @@
int retval = SUCCESS;
#ifdef PHP_WIN32
- CoInitialize(NULL);
+ PG(com_initialized) = 0;
#endif
#if PHP_SIGCHILD
@@ -1441,12 +1441,28 @@
} zend_end_try();
#ifdef PHP_WIN32
- CoUninitialize();
+ if (PG(com_initialized)) {
+ CoUninitialize();
+ PG(com_initialized) = 0;
+ }
#endif
}
/* }}} */
+/* {{{ php_com_initialize
+ */
+PHPAPI void php_com_initialize(TSRMLS_D)
+{
+#ifdef PHP_WIN32
+ if (!PG(com_initialized)) {
+ CoInitialize(NULL);
+ PG(com_initialized) = 1;
+ }
+#endif
+}
+/* }}} */
+
/* {{{ php_output_wrapper
*/
static int php_output_wrapper(const char *str, uint str_length)
http://cvs.php.net/viewvc.cgi/php-src/main/php.h?r1=1.234&r2=1.235&diff_format=u
Index: php-src/main/php.h
diff -u php-src/main/php.h:1.234 php-src/main/php.h:1.235
--- php-src/main/php.h:1.234 Fri Nov 10 09:56:37 2006
+++ php-src/main/php.h Fri Nov 17 11:41:13 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.234 2006/11/10 09:56:37 dmitry Exp $ */
+/* $Id: php.h,v 1.235 2006/11/17 11:41:13 dmitry Exp $ */
#ifndef PHP_H
#define PHP_H
@@ -325,6 +325,8 @@
PHPAPI int cfg_get_long(char *varname, long *result);
PHPAPI int cfg_get_double(char *varname, double *result);
PHPAPI int cfg_get_string(char *varname, char **result);
+
+PHPAPI void php_com_initialize(TSRMLS_D);
END_EXTERN_C()
/* PHP-named Zend macro wrappers */
http://cvs.php.net/viewvc.cgi/php-src/main/php_globals.h?r1=1.107&r2=1.108&diff_format=u
Index: php-src/main/php_globals.h
diff -u php-src/main/php_globals.h:1.107 php-src/main/php_globals.h:1.108
--- php-src/main/php_globals.h:1.107 Wed Jul 19 12:25:02 2006
+++ php-src/main/php_globals.h Fri Nov 17 11:41:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_globals.h,v 1.107 2006/07/19 12:25:02 mike Exp $ */
+/* $Id: php_globals.h,v 1.108 2006/11/17 11:41:13 dmitry Exp $ */
#ifndef PHP_GLOBALS_H
#define PHP_GLOBALS_H
@@ -138,6 +138,9 @@
char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
+#ifdef PHP_WIN32
+ zend_bool com_initialized;
+#endif
};
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_com.c?r1=1.19&r2=1.20&diff_format=u
Index: php-src/ext/com_dotnet/com_com.c
diff -u php-src/ext/com_dotnet/com_com.c:1.19
php-src/ext/com_dotnet/com_com.c:1.20
--- php-src/ext/com_dotnet/com_com.c:1.19 Tue Oct 10 17:33:02 2006
+++ php-src/ext/com_dotnet/com_com.c Fri Nov 17 11:41:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_com.c,v 1.19 2006/10/10 17:33:02 iliaa Exp $ */
+/* $Id: com_com.c,v 1.20 2006/11/17 11:41:13 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -53,6 +53,7 @@
&authid, EOAC_NONE
};
+ php_com_initialize(TSRMLS_C);
obj = CDNO_FETCH(object);
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
@@ -294,6 +295,7 @@
HRESULT res;
OLECHAR *module = NULL;
+ php_com_initialize(TSRMLS_C);
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
&module_name, &module_name_len, &code_page)) {
php_com_throw_exception(E_INVALIDARG, "Invalid arguments!"
TSRMLS_CC);
@@ -660,6 +662,7 @@
ZEND_WRONG_PARAM_COUNT();
}
+ php_com_initialize(TSRMLS_C);
if (CoCreateGuid(&retval) == S_OK && StringFromCLSID(&retval,
&guid_string) == S_OK) {
Z_TYPE_P(return_value) = IS_STRING;
Z_STRVAL_P(return_value) =
php_com_olestring_to_string(guid_string, &Z_STRLEN_P(return_value), CP_ACP, 0);
@@ -688,6 +691,7 @@
RETURN_FALSE;
}
+ php_com_initialize(TSRMLS_C);
obj = CDNO_FETCH(object);
if (sink && Z_TYPE_P(sink) == IS_ARRAY) {
@@ -748,6 +752,7 @@
RETURN_FALSE;
}
+ php_com_initialize(TSRMLS_C);
if (Z_TYPE_P(arg1) == IS_OBJECT) {
CDNO_FETCH_VERIFY(obj, arg1);
} else {
@@ -778,6 +783,7 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &timeoutms)
== FAILURE)
RETURN_FALSE;
+ php_com_initialize(TSRMLS_C);
result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms,
QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
@@ -811,6 +817,7 @@
RETVAL_FALSE;
+ php_com_initialize(TSRMLS_C);
pTL = php_com_load_typelib_via_cache(name, codepage, &cached TSRMLS_CC);
if (pTL) {
if (cached) {
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_dotnet.c?r1=1.15&r2=1.16&diff_format=u
Index: php-src/ext/com_dotnet/com_dotnet.c
diff -u php-src/ext/com_dotnet/com_dotnet.c:1.15
php-src/ext/com_dotnet/com_dotnet.c:1.16
--- php-src/ext/com_dotnet/com_dotnet.c:1.15 Sun Jan 1 13:09:48 2006
+++ php-src/ext/com_dotnet/com_dotnet.c Fri Nov 17 11:41:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_dotnet.c,v 1.15 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: com_dotnet.c,v 1.16 2006/11/17 11:41:13 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -193,6 +193,7 @@
char *where = "";
IUnknown *unk = NULL;
+ php_com_initialize(TSRMLS_C);
if (COMG(dotnet_runtime_stuff) == NULL) {
hr = dotnet_init(&where TSRMLS_CC);
if (FAILED(hr)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_handlers.c?r1=1.39&r2=1.40&diff_format=u
Index: php-src/ext/com_dotnet/com_handlers.c
diff -u php-src/ext/com_dotnet/com_handlers.c:1.39
php-src/ext/com_dotnet/com_handlers.c:1.40
--- php-src/ext/com_dotnet/com_handlers.c:1.39 Fri Oct 13 14:52:19 2006
+++ php-src/ext/com_dotnet/com_handlers.c Fri Nov 17 11:41:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_handlers.c,v 1.39 2006/10/13 14:52:19 andrei Exp $ */
+/* $Id: com_handlers.c,v 1.40 2006/11/17 11:41:13 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -667,6 +667,7 @@
php_com_dotnet_object *obj;
zend_object_value retval;
+ php_com_initialize(TSRMLS_C);
obj = emalloc(sizeof(*obj));
memset(obj, 0, sizeof(*obj));
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_variant.c?r1=1.17&r2=1.18&diff_format=u
Index: php-src/ext/com_dotnet/com_variant.c
diff -u php-src/ext/com_dotnet/com_variant.c:1.17
php-src/ext/com_dotnet/com_variant.c:1.18
--- php-src/ext/com_dotnet/com_variant.c:1.17 Mon Nov 13 15:33:40 2006
+++ php-src/ext/com_dotnet/com_variant.c Fri Nov 17 11:41:13 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_variant.c,v 1.17 2006/11/13 15:33:40 iliaa Exp $ */
+/* $Id: com_variant.c,v 1.18 2006/11/17 11:41:13 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -287,6 +287,7 @@
return;
}
+ php_com_initialize(TSRMLS_C);
if (ZEND_NUM_ARGS() == 3) {
obj->code_page = codepage;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php