Reputation: 53
In the adobe coldfusion 10 documentation, Defining the application and its event handlers in Application.cfc, there is a sample Application.cfc containing the function below. After looking at the code, I am wondering if there is a typo/bug in the following code:
<cffunction name="onSessionStart">
...
<cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Application.sessions = Application.sessions + 1>
</cflock>
...
</cffunction>
Should it be:
?
If it is (A) then I am confused. Can someone explain why?
Upvotes: 3
Views: 365
Reputation: 29870
This is a duplicate of my answer to the same question asked on the Adobe forums:
Don't be confused... it's an error in the docs. You could do Adobe a favour by commenting at the bottom of the page: they do monitor those comments (they don't always react, but the do monitor them).
onSessionStart() is intrinsically single-threaded as far as the session scope goes: it's only ever run once per session (when the session starts...). On the other hand the code in question def wants to single-thread access to that application-scoped variable as we don't want two simultaneous sessions hitting it for any given single value of it (if that makes sense).
Upvotes: 1
Reputation: 2073
You always lock the SCOPE that you are writing to. In this case it would be APPLICATION.
Upvotes: 0