[tbnl-devel] Re: Hunchentoot for SBCL and other Lisps

Travis Cross travis at travislists.com
Sun Oct 1 21:57:34 UTC 2006


Edi Weitz wrote:
> Is there a guarantee in SBCL that the cleanup forms of an
> UNWIND-PROTECT are executed when a thread is killed?

In my experience, it seems to work most of the time, but I'd have to
ask someone with more sb-thread-internals-jitsu to fill in whether
there is an actual guarantee in place or not.

My understanding is that because of issues with shared memory
between threads, killing a thread should always be considered a bit
drastic, as there is no real guarantee that it won't corrupt the
entire lisp image. [1]

When I write listeners such as this, to provide for a normal
shutdown I close over a function that flips a flag variable telling
the listener to stop, then initiates a socket connection to the
listener to break the socket-accept block. [2]

It seems that something like this [3] might be the correct solution
here as well.  For a normal shutdown, one tends to prefer to let
current workers finish their tasks up anyway.  Providing for both
the 'clean' shutdown and the 'nuke them all and take your chances'
approach would probably be the most flexible interface.

Cheers,

-- Travis

[1] See this thread (which sf.net fragmented):
http://sourceforge.net/mailarchive/forum.php?thread_id=14295329&forum_id=4134
http://sourceforge.net/mailarchive/forum.php?thread_id=14649427&forum_id=4134
http://sourceforge.net/mailarchive/forum.php?thread_id=14649430&forum_id=4134

Nikodemus Siivola:
"No question about it. As long as we don't have safe-points and
otherwise run in an uninterruptible state, then not just killing,
but generally interrupting and even partially unwinding another
thread is basically a horrible, yet dangerously seductive idea.

"It is simple enough to write code that checks for "kill yourself"
message, and deal with it, and that is what threaded applications
should do."

[2] The (currently SBCL-only) code that I use for doing this is here:

http://code.tcross.org/releases/cl-listener-0.1.0.tar.gz
http://code.tcross.org/releases/cl-sockets-0.1.0.tar.gz

... or for the darcs-inclined:

http://darcs.tcross.org/cl-listener/
http://darcs.tcross.org/cl-sockets/

[3] Global special variables, gray streams, or conditions can of
course be used to achieve the same ends.



More information about the Tbnl-devel mailing list