To CFLOCK or not, that is the question (again)

There's still questions about whether things should be <CFLOCK>'ed or not. This particular discussion happened on twitter where a developer was concerned that his session would bleed over into another user's session. To be clear, this was a major bug in the server. It happened back in the CF5 days. Suddenly there was a massive shift to get all the developers to cflock all of their session/application code. All of it. If it's not already obvious, there's performance rammifications behind this.

These days, 4, almost 5, versions later, gone are the days where you had to worry about session collision. Note, I'm not saying, don't use cflock. I'm saying, use them for an entirely different reason. Race conditions. If you have a session.user.isloggedIn and that's structure holding a boolean value and it should only ever be either true or false, but the timing of flip between true or false is important then you should be concerned which functions are messing with it. If there's a possibility that anything more than one function is flipping the value from true or false at any given moment, then you have the potential for a race condition.

From Wikipedia:
"A race condition or race hazard is a flaw in an electronic system or process whereby the output or result of the process is unexpectedly and critically dependent on the sequence or timing of other events"

The important part of this quote being: critically dependent on the sequence or timing.

By putting <cflock type="exclusive">, you're forcing other processes that are manipulating that session variable to wait in line via single threading. <cflock type="readonly"> allows mutli-threading reading of the variable so anything can get at it, except when it's busy being exclusive.

Also, cflock isn't exlcusive to sessions / applications. You may run into a process where you need a variable to be watched carefully (the internals of a cfobject as an example). Then, you use exclusive NAMED locks (e.g. <cflock name="somename" type="exclusive">).

As a side note, Application.cfc's onApplicationStart() / OnSessionStart() are already single threaded, you don't need to worry about cflocking. What you do need to worry about is if you have a restart configuration in OnRequestStart or OnRequest that re-initializes application / session vars by calling <cfset onSessionStart()> or <cfset onApplicationStart>, this is not thread safe and subjected to race conditions.

Setting up your own Craftbukkit Minecraft server on a CentOS Server at Rackspace Cloud

Setting up your own craftbukkit minecraft server on rackspace cloud sounds a little daunting, but it's really not. Here's 23 steps to walk you through it. ;)

Read more...

Processing Directive - CodeBass Radio

If you've been living under a rock, there's a new internet radio station called Codebass Radio where geek and music combine. The executive producer and person responsible for it all, Vicky Rider, has been pulling together an impressive list of geeks to make this all happen. The geeks came together and made their own Adobe AIR based media player, Mediaslurp.

Codebass Radio has been growing into its own little community on twitter #CodeBassRadio. I joked to Vicky that I was going to make a station on Codebass and it was going to play music for the hard of hearing (read: a lot of bass). She, of course, was receptive to the idea and kept pestering me about it. Months went by and I finally managed to submit Episode 1 to her on the 21st of October.

So, it appears I have a regular timeslot now after Daria's Cheat Sheet. I've named the show Processing Directive and hopefully a new episode will appear every week at 3PM EST. Not sure if repeats will happen during the week, but you might have to keep tabs on @CodeBass on twitter to get the daily schedule. I'll be mostly playing Techno / Industrial tunes, but I have no qualms about tossing in dubstep or bass heavy metal if I need to. I've been told that what I have is good coding music, so if I can make the hour fly while you're coding, I think I've done a decent job.

Processing Directive, putting the bass back in CodeBass Radio. ;)

Oh, there's plenty of room for shows, so if this is just up your alley and you'd like to give it a shot, you should contact Vicky.  If I can do it, you most certainly can.