summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-11-17 11:40:52 +0000
committerDmitry Stogov <dmitry@php.net>2006-11-17 11:40:52 +0000
commitc06f9e1efe5375abcbb507876e04e893885e4ade (patch)
tree1fec799294f4e5db9b88dcbaa46f62aa6a6886a4 /main
parentcb4b75f155950d57979c5c69c37e78d46f60d3d7 (diff)
downloadphp-git-c06f9e1efe5375abcbb507876e04e893885e4ade.tar.gz
COM initialization/deinitialization are done only if necessary
Diffstat (limited to 'main')
-rw-r--r--main/main.c20
-rw-r--r--main/php.h2
-rw-r--r--main/php_globals.h3
3 files changed, 23 insertions, 2 deletions
diff --git a/main/main.c b/main/main.c
index 87a0f95802..be300e43d2 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1073,7 +1073,7 @@ int php_request_startup(TSRMLS_D)
int retval = SUCCESS;
#ifdef PHP_WIN32
- CoInitialize(NULL);
+ PG(com_initialized) = 0;
#endif
#if PHP_SIGCHILD
@@ -1325,12 +1325,28 @@ void php_request_shutdown(void *dummy)
} 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_body_write_wrapper
*/
static int php_body_write_wrapper(const char *str, uint str_length)
diff --git a/main/php.h b/main/php.h
index 6ff3bfe7da..a3825a4659 100644
--- a/main/php.h
+++ b/main/php.h
@@ -329,6 +329,8 @@ PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userda
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 */
diff --git a/main/php_globals.h b/main/php_globals.h
index d20ebb1ef7..c17a1e947b 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -152,6 +152,9 @@ struct _php_core_globals {
char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
+#ifdef PHP_WIN32
+ zend_bool com_initialized;
+#endif
};