Ray, i believe what macromedia is refering to is the variable being written
and overwritten at the same time.  Not a variable being written, then
overwritten after its set.


See the note:
Race condition is a term that is not specific to ColdFusion programming, but
refers to a common issue that needs to be taken into consideration when
programming in any multithreaded environment. Simply put, a race condition
occurs anytime two threads (in this case, page requests) try to write to the
same data at the same time. The following is an example:
<cfset session.cartTotal = session.cartTotal + currentPrice>



If two requests to the page that includes this code are made at the same
time, it is possible that in the time between the right-hand side read of
the session.cartTotal, and the left-hand-side write for the second page
request to execute and modify session.cartTotal. The result is corrupt data.

see where it says corrupt data?

DRE

-----Original Message-----
From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 28, 2003 9:31 AM
To: CF-Talk
Subject: RE: Scope Locking (RE: Blue Dragon and Fusebox)

> I'm interpreting your statment that if indeed a race
> condition occurs and that a variable is overwritten at the
> same time as its being written, that it simply uses the
> second value??  I havent seen anyting to suggest this
> anywhere(do you have more info?).  

Well, wouldn't it make sense that if you set X to "FOO" at 1:00 PM, and
another thread sets it to "GOO" at one milisecond afterwards, then "GOO"
will be the final value? As it stands, my point was, do you _need_ to
care? Using both Dave's example, and mine, the answer is probably no.

> The problem would seem to me to be more severe as indeed
> macromedia has made the statment that you should avoid this
> by spending time to lock the variable.  

I respectfully disagree with their statement. Or, actually, I don't
disagree. If you want to prevent a race condition, use locking. That is
100% true. However, what Dave has said, and I'm agreeing with, is that
you should ask yourself if a race condition is that big of a deal.

> Assuming the worst case (because of lack of evidence to the
> contrary), the variable gets corrupted by this action.  I

Define "corrupted". If you REALLY need a value to be written once, then
yes, not locking it will cause "corruption". If it's ok if it gets set
more than once, then there is nothing to worry about.

> would think that the server might be negatively affected by
> such an occurence and indeed might crash.  Cf5 would crash
> when its variables became corrupted.  So, perhaps it might be
> somewhat important?  Of course I'm fairly java clueless so I
> cant make a better guess.
>  

This is NOT the case in MX however. You can overwrite values willynilly
and you should not get a crash as you would prior to MX.

  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to