Justtechjobs.com Find a programming school near you






Online Campus Both


php-developer-list | 2002112

Re: [PHP-DEV] [PATCH 4.3.0] Win32 CoInitalize/CoUninitialize Call Move From: Frank M. Kromann (frank <email protected>)
Date: 11/25/02

+1

Looking through som old multithreaded code for other projects tells me
this is the way to do it.

- Frank

> While stess testing the recent threading fixes under the ISAPI module I
> was seeing a lot of instability in IIS after the testing finished.
> While the PHP pages would continue to load, no ASP pages would anymore.
> I have tracked this down to the placement of the Win32 CoInitialize()
> and CoUninitialize() calls. In the current 4.3.0 release candidate
> CoInitialize() and CoUninitialize() are only called once per thread
> (from the basic_globals_ctor/_dtor in basic_functions.c). According to
> Microsoft, however, at
>
http://msdn.microsoft.com/library/en-us/iisref/html/psdk/asp/devs0hm5.asp:
>
> "COM initialization, from CoInitialize or CoInitializeEx, affects the
> thread in which it's called. For this reason, you cannot initialize COM
> unless you uninitialize it before returning from your callback
> function. [ . . .] CoInitialize and CoUninitialize need to be called in
> order. If one is called twice in a row, by different ISAPIs on the same
> thread, your users may see error 270."
>
> This is exactly the error I am seeing: if I load an ASP page in a
> thread that has processed PHP pages I get the 270 error (reported as
> "Error -2147417842 (0x8001010e)"). I moved the CoInitilize call to
> PHP_RINIT_FUNCTION(basic) and CoUninitialize to
> PHP_RSHUTDOWN_FUNCTION(basic) and reran my stress testing. After
> 100,000 PHP page loads IIS now remains stable and able to process both
> ASP and PHP pages.
>
> I ran this by Zeev and he suggested that some kind of just-in-time COM
> initialization, but I'm not going to have the time to get to this full
> solution until later. In the meantime for 4.3.0 I request that the
> attached patch is applied that moves the CoInitialize or CoInitializeEx
> calls to be per-request. This is the last little fix that all the
> multi-threading bug fixing to make the ISAPI rock solid in 4.3.0
> requires. I've done a lot of testing and feel very confident about
> including this patch.
>
> Michael Sisolak
> msisolak <email protected>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php