Hey Maurice,

2010/2/1 Maurice Gittens <mainmanmauri...@gmail.com>:
> diff --git a/src/Wt/WResource.C b/src/Wt/WResource.C
>>
>> index c960b25..df8876e 100644
>> --- a/src/Wt/WResource.C
>> +++ b/src/Wt/WResource.C
>> @@ -86,7 +86,7 @@ void WResource::handle(WebRequest *webRequest,
>> WebResponse *webResponse,
>>   // lock
>>   if (!continuation) {
>>     WebSession::Handler *h = WebSession::Handler::instance();
>> -    if (h)
>> +    if (h && h->lock().owns_lock())
>>       h->lock().unlock();
>
> This patch appears on my "something might be wrong" radar.
>
> Is this not a classical race where the test for lock ownership
> succeeds but the when the unlock is called the test condition is no longer
> true because your thread got preempted?

Not really, if the thread has the lock it has exclusive access ? I
cannot see why this could be a race condition ?
(WebSession::Handler::instance() returns an object from thread-local
memory which is entirely owned by the current thread).

Usually, a thread will have the session lock on entry of a WResource
handleRequest(), but there are a few exceptions. Resources are handled
outside of the session lock and are reentrant -- but still protected
against being destructed while busy, and therefore we want to release
the session lock if we have it.

The wtwithqt support library works by doing all event handling for a
particular session inside a dedicated Qt thread, since this is the
only way to work with Qt's threading model (which binds ownership of
QObjects to a particular thread and requires that only that thread
uses signal/slots on that object). In that case the Qt thread will not
have the session lock, but the Wt thread that is handling the session
will have the lock. Functionally, this means that when using Wt in
conjunction with Qt, WResource handling will not be reentrant.

Regards,
koen

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to