Yeah, sorry. Feels like a Friday here, so I'm treating it like one and you were an innocent bystander. You can use my login example, as I didn't mention who I was working for or any of that.
-nathan strutz http://www.dopefly.com/ Burns, John D wrote: > Ouch, that was a bit of a low blow. I'm asking not for personal > enlightenment but to confirm what I already believed to be true before I > pass the data on to coworkers. I know there are always a few different > opinions about odd things so I figured I'd ask a quick question before > compiling my content. > > For instance, your login problem is a great personal example. Mind if I > use that as an example? > > Thanks for the response. > > > John Burns > Certified Advanced ColdFusion MX Developer > Wyle Laboratories, Inc. | Web Developer > > > -----Original Message----- > From: Nathan Strutz [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 31, 2005 12:37 PM > To: CF-Talk > Subject: Re: When to use CFLOCK (MX 6.1 and above) > > Burns, John D wrote: > >>I know there were some discussions on here recently about when you do >>and don't need to use cflock and some discussion about changes on when > > >>you needed to from 5 to 6.1. Can anyone give a quick recap of that or > > >>point me to the archives on where I could find that discussion? I >>can't seem to find it via the search. I'm looking for some facts and >>reasoning behind why you do or don't need to use cflock in certain >>situations. Thanks. >> >>John Burns >>Certified Advanced ColdFusion MX Developer > > > > And you wonder why I've never gotten my certification... ;) > > I'll recap for you. > > CF5 & below, you had to cflock every shared scope variable or your > server would crash. Sometimes many times an hour (trust me). CFMX of > course fixes that. > > Now you need to lock for race conditions. CFMX is multi-threaded, so two > people can be doing the exact same thing at the exact same time. It's > good in the way that your server can do a lot at once, but sometimes > that's not safe. > > For instance, the generic example, an application-scoped hit counter. > User A and user B hit a page at the same time, but A's thread goes > through first. A's thread reads the variable, currently 100, and adds > one to it, however, before it's set back into memory, user B reads it, > it's 100. User A completes the process, setting the counter at 101. User > B, having read it at 100, sets it to 101 as well. This race condition > caused the hit counter to be off by 1. > > It seems unlikely, but believe me, these kinds of things can happen very > easily, especially when you increase the amout of work you're doing with > the shared scope. Looping, etc., will create issues with just 2 people > using an application. > > Now here's a real life example. We have a login form. When you log in, > we validate your credentials, erase previous session variables and set > some new ones, then the request is forwarded to another page to set some > session variables and output them. If you double-click the login button, > 2 requests are sent to the server. The first thread is attempting to > output your session variables while the first thread is deleting them > for a fresh login. The server throws an undefined variable exception on > the first thread, and thus, I get an email. After some creative locking, > I've eliminated the error altogether, even though customers never saw it > to begin with. > > I should blog this & refer it to people... ehh. > > -nathan strutz > http://www.dopefly.com/ > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201035 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

