On Wed, Oct 29, 2003 at 08:38:34AM -0700, Joshua Ginsberg wrote:

> Forgive me, I'm a pretty inexperienced C programmer. Define "race
> conditions".

This is basic to any form of multi-threaded or concurrent programming.
In AOLserver, it is every bit as relevent to coding in Tcl as it is to
C.  Look it up, e.g.:

  http://www.hyperdictionary.com/computing/race+condition

> > Is it possible for ns_conn state to return "filter", then to finish
> > processing the filter and actually be in state "tcl" at the time you
> > try to abort the filter processing?  If so what happens (what breaks)
> > when this occurs?

For your code, this is a potential race condition to worry about.
Ideally, you want the checking of the current ns_conn state and the
calling of the appropriate flavor of conn abort function to be an
atomic operation, as if they are not, you may be vulnerable to a race.

Of course, in your case when the race condition bites you maybe all
that happens is your ns_stop call errors out.  If that's all, then it
may be a lot simpler to catch the ns_stop failure and retry, rather
than fix the race condition in the first place via mutex locking or
whatever.

But you definitely need to think about these sorts of things when
doing ANY programming involving more than one thread.

> Let's say a particular fault handler redirects the client. After it
> redirects the client, all processing of this conn should simply cease,
> lest needless errors populate your logfiles. But what do you call to do

Oh.  Above, I've been assuming that you're calling your ns_stop proc
from some thread OTHER than the conn thread.  Which was, hm, kind of
foolish.  Sounds like you're actually calling it from the conn thread
itself.  If you are, then you only have one thread involved and there
aren't any potential race conditions to worry about, and nothing I
said above is immediately relevant.

--
Andrew Piskorski <[EMAIL PROTECTED]>
http://www.piskorski.com


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to