[mod_python] Multiple loading of same module with winnt MPM

Graham Dumpleton graham.dumpleton at gmail.com
Fri May 11 06:54:35 EDT 2007

On 11/05/07, simon holness <simon.holness at gmail.com> wrote:
> Hi, I'm the guy who knocked up the quick fix. Yes, I think you're
> quite right and the fix is also not correct.
> The problem appears to essentially be that a whole load of processing
> is happening on the 'cache' object while it isn't locked.

It is okay as it is dealing with only read only data at that point.
When a reload is being done it accumulates the new data in temporary
data structure and replaces original later in one atomic operation in
such a way as not to cause problems.

> Do you know if there's a reason that "_lock1" is used to lock out the
> entire of _reload_required(), rather than swapping to the use of
> cache.lock ? Is it to do with the processing of the cache's children?
> or the call to _check_module() ?

The reload check is protected to stop two threads deciding at the same
time that something needs reloading. Where the code went wrong is that
cache.reload is set to 1 part way through cache entry locked code and
depending on whether reload check sees this or not is causing the
problem. I only added this reload flag late in the peace so I could
get some nice debug information but it has screwed things up in this
particular instance.

> The correct solution looks, to me, like all of the processing of the
> cache object should be guarded by its lock,  and not by the
> _ModuleCache's _lock1.

Can't be the cache entry lock as you are actually traversing many
cache entries and not just one.

I already have so changes which should work, but need to sit down and
think it through a bit more first and look back at some older versions
of this code I had if I can find them. I am sure I used to overlap the
reload lock with cache entry lock for a brief time to avoid certain
problems and not sure why the code isn't doing it anymore so have to
look at the way I was avoiding that is actually okay.

I have created an issue for this in the tracking system and any patch
will be put up against it to try.


If I can get to it, will put up something over the weekend.


More information about the Mod_python mailing list