perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: [mp2] Our API is not perl thread-safe
Date Thu, 24 Mar 2005 03:24:20 GMT
Stas Bekman wrote:
> First of all we have to separate the objects in two groups: those 
> created by users (1) and those created by Apache/mp2 (2).
> (1) things which are completely under user control look easy, for 
> example if you create an APR::Table object, we can clone it by copying 
> the table in the spawned thread. The question is what pool should we use 
> for that purpose? We can't use the pool from the parent thread. Since 
> the parent thread may be killed before the child one (for detached 
> threads). and if it's APR::Pool object itself that needs to be cloned, 
> which pool do we use to clone it? How do we avoid leaks?
> Ideas? I'm not sure it's doable at all.
> (2) Things are even harder with objects created by Apache/mp2. I mean 
> how in the world are we going to clone things like $r or $c? there are 
> all kind of things attached to those objects, including sockets, etc. 
> and now we suddenly need to free those objects too.
> Here I'm even more lost.

I think I've an idea that may work. All that automatic cloning business is 
really unwanted in the mod_perl environment. I think if we try to empty 
the cloned objects of the pointer to the C struct, it will render them 
unusable in the spawned threads, but it'll prevent multiple destruction 
problem. Next we can try and see if we can properly clone objects, one 
class at a time.

Unfortunately due to the badly-designed by the perl core CLONE function 
it's going to be quite a hassle to do even that, as you can see from 
Example::CLONE. :(

I'll try with APR::Pool first.

Stas, who enjoys talking to himself...

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message