-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> CFLOCK should be used on writes of session,server, and
> application variables
That's mostly right. Except that you MUST also put a readonly lock
around reads to session,application, and server variables. If you
don't lock the reads, then the write locks are useless. The one way
to get around that is to enable automatic read locking in the CF
Administrator, but as you mentioned, there's a performance hit there.
Here's why you must lock reads:
When CF is about to grant an exclusive lock, it first checks to see
if there are any other exclusive or readonly locks in effect. CF has
no clue about concurrent access to anything (unless you turn on one
of the automatic options). If you lock writes, that's great, but CF
then has no idea when any reads are going on. CF would grant the
lock for writing, and could then allow a million other sessions to
access the variable for reading while you're writing to it. When you
place the readonly locks around reads to variables, then CF knows
where those reads are occurring (sort of. CF doesn't care about
reads, only about locks, but that's another can of worms I'll not be
opening today...). Once CF is made aware of those reads, it is able
to correctly deny any exclusive locks if any readonly locks are in
effect, AND it can also deny those readonly locks if there's an
exclusive lock in effect elsewhere.
> CFLOCK should be used on reads of CFX_Tags (though I just saw
> that so I am not sure about that)
You only NEED to lock (exclusively, not readonly) and CFX tags that
are NOT threadsafe. Since it's tough to tell if a tag IS threadsafe,
you *should* lock tags that you're not sure about, but that *could*
be an unnecessary performance hit. Check with the tag's author to
see if it's threadsafe, but you can't always trust the author either.
They may have intended to make the tag threadsafe and missed *one
little thing*, in which case the tag WILL cause problems unless
locked.
> Locking should not be initiated at server level as it will
> severly impede performance
I wouldn't say 'severly', but it's defiantely a hit. Would someone
with more free time than I care to setup a test bed and give us some
numbers? I have a few ideas on how to structure the test that I
could share if anyone's got the time to do it up right...
> Reading memory variables is ok as long as you are sure that
> the write to them has been locked
See above -- locking writes to variables is completely useless unless
you also lock the reads.
So... To re-summarize:
* Always, Always, Always lock all accesses to server, application,
and session variables.
* Lock CFX tags unless you're certain that they ARE threadsafe.
* If you're running an ISP, then you'll want to enable full automatic
checking or at least automatic read locking in the CF Administrator.
It's a performance hit, but it's better than having one ignorant CF
Coder bringing your entire server down on a daily basis... (Been
there, done that, got the T-Shirt....)
* Locking writes without also locking all reads is completely
useless.
Best regards,
Zac Bedell
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!!!
iQA/AwUBOYgk8AraVoMWBwRBEQKANgCgrRPU7Re4BgcvNGLe3dh13oA0DwoAniug
00fgEc0CtaPJJyC9FpeIo7nE
=CsOP
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.