Named lock does not throw on timeout

Description

This code should stop early or error for a concurrent request, as the sleep() for the winner is longer than the timeout. It doesn't, it waits for the first one to finish then completes.

<cfset sessionFlag='adminRunningLock'/> <cflock name="#sessionFlag#" type="exclusive" timeout="1" throwOnTimeout="true"> <cfif structKeyExists(session,sessionFlag)>a already running. Not running again<br> Started at <cfoutput>#session[sessionFlag]#</cfoutput> <cfabort/> <cfelse>b <cfset sleep(5000)/> <cfif structKeyExists(session,sessionFlag)>d already running. Not running again !<br> Started at <cfoutput>#session[sessionFlag]#</cfoutput> <cfabort/> </cfif>e <cfset session[sessionFlag]=now()/>f </cfif> </cflock> * <cfoutput>#session[sessionFlag]#</cfoutput>

Environment

None

Activity

Show:

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 3 November 2015 at 16:43
Updated 19 May 2021 at 11:39

Flag notifications