I thought this was an interesting question, and I decided to write a
test script. And from my experiments with CFMX, it would seem that
timeout=0 is equivalent to no-timeout. As in, the cf thread will wait()
till it obtains the lock. My test script in essence created a deadlock.
Something that I thought is not achievable in CFLOCK'ing since the
timeout attribute is always required. But setting timeout=0 in essence
allows for deadlock scenarios.

Here's my deadlock example:

<![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>Untitled</title>
</head>

<body>
<cfparam name="d" type="numeric" default="0">
<cflock timeout="0" throwontimeout="Yes" name="dummy" type="EXCLUSIVE">
        <h1>Hello World!</h1>
        <cfif d NEQ 1>
                <cfhttp url="http#Iif(CGI.HTTPS IS 'ON', DE('s'),
DE(''))#://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#?d=1" method="GET"
resolveurl="false" throwonerror="no"></cfhttp>
                <xmp>#CFHTTP.Header#</xmp>
                <hr>
                <cfoutput>#CFHTTP.FileContent#</cfoutput>
        </cfif>
</cflock>

</body>
</html>
]]>

I don't have a CF5 playbox to crash to verify if this is true for CF5.
:P

----------------------------
James Ang
Senior Programmer
MedSeek, Inc.
[EMAIL PROTECTED]



-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 11:02 AM
To: CF-Talk
Subject: RE: cflock with timeout=0


> Can anyone tell me what the behaviour of CFLOCK is when 
> you give it a timeout value of 0? What I'm looking to do 
> is create a situation where if one user has acquired the 
> lock, any other users who reach the lock will immediately 
> skip the synchronized section. I thought the following 
> might work...
> 
> <cflock name="MyLock" timeout="0" throwontimeout="no" 
> type="exclusive">
> ...
> </cflock>
> 
> However, I can't find any documentation stating how CF 
> handles a value of 0 in the timeout field. Will it even 
> attempt to acquire the lock? In some languages a timeout 
> of 0 indicates "wait indefinetely" which is obviously
> not what I want in this case. I'm running CF5 Pro.

Well, I don't know the answer to your question, but you can easily find
this
out by simply writing some test pages with locks, and running them to
see
what happens. For example, you could place a lock around a long-running
loop, and run that from two separate browsers, or even from one browser
using a frameset. The answer that you get this way will be more reliable
than any provided by the documentation, which often contains omissions,
ambiguities, and even the occasional error.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to