Re: Apache2/Modperl2 fails to preload Win32::OLE at server startup

[prev] [thread] [next] [Date index for 2004/11/30]

From: Stas Bekman
Subject: Re: Apache2/Modperl2 fails to preload Win32::OLE at server startup
Date: 17:24 on 30 Nov 2004
Jan Dubois wrote:
> On Tue, 30 Nov 2004, Stas Bekman wrote:
> 
>>What about the solution of ithreads? Originally ithreads were storing
>>their context in ThreadLocalStorage, and this didn't work under mp2,
>>so it was rewritten to store the context in a perl PL_ interpreter
>>global, now ithreads can be run inside the same thread.
> 
> 
> I'm not sure what you are referring to.  As far as I know the Perl context
> for a thread is still stored in TLS.  Can you point me to the relevant
> changes and/or the PL_ name you are talking about?

The main self context is not stored in TLS since 5.8.1. If it was it would 
be impossible to load and run ithreads::shared under mp2.

ext/threads/threads.xs:

void Perl_ithread_set (pTHX_ ithread* thread)
{
   SV* thread_sv = newSViv(PTR2IV(thread));
   if(!hv_store(PL_modglobal, "threads::self", 12, thread_sv,0)) {
     croak("%s\n","Internal error, couldn't set TLS");
   }
}

>>Could the same solution be applied for COM context? Make it
>>independent from threads?
> 
> 
> You will have to ask Microsoft about this. Something tells me their
> answer will be: "Don't use COM, use .NET".
> 
> For Win32::OLE this could be solved by only using the free-threaded
> apartment model, which is already done by default. But you will still
> need to initialize each new thread to join that apartment.  I guess each
> Perl interpreter could keep a global cache of thread ids and just try
> to call CoInitialize() when it hasn't been run in this thread before.
> Of course this will require all Perl interpreters to use the same
> COM threading model, but that is not really a big restriction.

Sounds like database connection pooling :)


        -- 
        __________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

(message missing)

Re: Apache2/Modperl2 fails to preload Win32::OLE at server startup
Stas Bekman 17:24 on 30 Nov 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52