Nathan Stanford wrote:
> Well... in one way I think it is ran from the top due to the setting it to
> zero and yet when it gets to the output of the area marked bad the number is
> ok if I hit the page once but if I hit refresh while it is loading then the
> number is incorrect.
>
> Code at bottom of page with LOCKS around ALL SESSION output and cfsets...
>
> I give this is the strangest thing I have ever heard or saw.
>
> Remember Now tested on both
> ColdFusion MX on a Solaris 7 with Apache 1.3.26 Web Server
> ColdFusion 4.5 on Windows NT with IIS Web Server
Some edits for readability. Look for the markers "Point 1" and "Point 2".
<!--- Initializing session --->
<cfapplication name="test"
sessionmanagement="Yes"
sessiontimeout="#CreateTimeSpan(0, 3, 0, 0)#">
<cfif IsDefined( "Cookie.CFID" ) AND IsDefined( "Cookie.CFTOKEN" )>
<cfset localCFID = Cookie.CFID>
<cfset localCFTOKEN = Cookie.CFTOKEN>
<cfcookie name="CFID" value="#localCFID#">
<cfcookie name="CFTOKEN" value="#localCFTOKEN#">
</cfif>
<cfset request.dsnSQL ="XX">
<cfset request.dsnAS400 ="XXX">
<cfquery name="qry_checkoutcart" datasource="#request.dsnSQL#">
SELECT *
FROM OreckDealerCart
WHERE OreckDealer_id = #XXXX#
</cfquery>
<cfquery name="qry_checkoutcart1" datasource="#request.dsnSQL#">
select sum(quantity) As CartTotal
FROM OreckDealerCart
WHERE OreckDealer_id = #XXXX#
</cfquery>
<cflock timeout = "60" scope = "SESSION" type = "Exclusive">
<cfset session.dealer_id="XXXX">
<cfset session.cartquantity=0>
<cfset session.carttotal=0>
</cflock>
<!--- Point 1 --->
<cfoutput>Before Everything:<br>
<cflock timeout = "60" scope = "SESSION" type="READONLY">
Session.Carttotal:#session.carttotal#<br>
Session.CartQuantity:#session.cartquantity#<br><br>
</cflock>
</cfoutput>
<cfif qry_checkoutcart.recordcount neq 0>
<cfset counter=0>
<cfoutput query="qry_checkoutcart">
Before AS400:<br>
<cflock timeout = "60" scope = "SESSION" type="READONLY">
Session.Carttotal:#session.carttotal#<br>
Session.CartQuantity:#session.cartquantity#<br><br>
</cflock>
<cflock timeout = "60" scope = "SESSION" type = "Exclusive">
<!--- Point 2 --->
<cfset
session.cartquantity=#session.cartquantity#+#qry_checkoutcart.quantity#>
</cflock>
</cfoutput>
</cfif>
We have 2 instances of this template running at the same time. At the
time the first instance reaches Point 1, the second instance reaches
Point 2 and grabs the lock to update the value. Will the first instance
display 0 for session.cartquantity or not?
Jochem
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists