Just curious, why do you care if multiple threads are reading the database
from this gateway at the same time?  

There are always "race" conditions in shared scopes, but you only need to
lock them when actually have consequences.

As far as the usage of the lock, in this case, I'd go for a named lock
rather than an application level lock.  What you're doing there is locking
the entire Application level, so if you have any other Application level
exclusive locks, they won't be able to run in parallel even if the locks are
around two completely unrelated groups of code.

<cflock name="myGatewayLock" timeout="5" type="readonly">
        <cfset getitems = Application.mygatewaymethod(args) />
</cflock>

That's my take...

Jonathon

-----Original Message-----
From: Josh Nathanson [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 16, 2007 2:38 PM
To: CF-Talk
Subject: Possible race conditions, need locking?

Hey all,

I have a gateway cfc that is cached in the Application scope.  It's reading 
data from the database. It looks like I'm seeing some evidence of race 
conditions on this cfc, i.e. data from other requests is appearing in the 
application.

I've never used locks before, just want to make sure I'm doing it right. 
Here's what my code looks like:

<cflock scope="application" timeout="5" type="readonly">
  <cfset getitems = Application.mygatewaymethod(args) />
 </cflock>

Do I have that right for what I need to do, namely prevent the threads from 
crossing when reading in the data.

-- Josh





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283826
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to