I am trying to identify if a cflock is running by looking for a timeout. I cannot seem to get the timeout to fire, or maybe I am missing something.
<cfset processing = 0 />
<cftry>
<cflock timeout="1" name="test" type="exclusive" throwontimeout="true">
Test...<br>
</cflock>
<cfcatch type="lock">
<cfdump var="#cfcatch#" />
<cfset processing = 1 />
<cfdump var="#cflock#" />
</cfcatch>
</cftry>
Current Processing State: <cfoutput>#processing#</cfoutput>
<cfif processing EQ 0>
<cfset processing = 1 />
<!--- nothing is being processed --->
<cftry>
<cflock timeout="5" name="test" type="exclusive" throwontimeout="true">
Before <cfoutput>#processing#</cfoutput>
<cfscript>
thread = CreateObject("java","java.lang.Thread");
thread.sleep(10000); // CF will now sleep for 10 seconds
</cfscript>
<cfset processing = 2 />
After <cfoutput>#processing#</cfoutput>
</cflock>
<cfcatch type="lock">
<cfdump var="#cfcatch#" />
<cfdump var="#cflock#" />
</cfcatch>
</cftry>
</cfif>
I have opened 2 pages, and run one right after the other. I expected that during the sleep timer of 10 seconds, that the second page running would have thrown the time out, it does not.
Version Lucee 7.0.1.100
Loader Version 7.0.0.395
Servlet Container Apache Tomcat/11.0.13
Java 21.0.9 (Eclipse Adoptium) 64bit
OS Linux (5.14.0-611.13.1.el9_7.x86_64) 64bit
Architecture 64bit