(CC'd sbcl-help rather than sbcl-devel.)
On 12/28/05, Dmitri Hrapof <yavannadil@...> wrote:
> What is the right way to automatically remove bogus handlers?
> In my server I (ADD-FD-HANDLER <listening-socket> :input
> (PERFORM-WORK)), followed by (ADD-FD-HANDLER <accepted-socket> :input
> (PERFORM-WORK)) to leave slime REPL free. Everything is fine until
> client quits and condition is signalled. Of course I can choose
> REMOVE-THEM restart manually, but is it possible to do it automatically?
> Where do I (HANDLER-BIND)? I beg your pardon, but I'm not very good with
> condition system yet...
I surround (PERFORM-WORK) in a HANDLER-BIND form and use FIND-RESTART
in the handler body, followed by INVOKE-RESTART, something along these
((error (lambda (condition)
(find-restart 'remove-them condition)))))
(You probably want to check that the 'remove-them symbol has been
imported into your package.)
However, SBCL currently signals an ERROR for bogus handlers, so you'd
probably want to do more condition processing to discriminate real
client-closed-connection conditions from, say, disk-full conditions.=20
(Perhaps depending on whether the restart exists or not?)
I submitted a patch a while back which defined a condition for this
situation, but, ah, it breaks the build because CLOS isn't up when
this file is loading, so it only works when patching a running system.
I haven't had time to look into it, sigh.
Hope this helps,