On 12/30/05, Dmitri Hrapof <yavannadil@...> wrote:
> I did the following
> (when *slime-friendly*
> (handler-bind
> ((error (lambda (condition)
> (invoke-restart (find-restart 'remove-them
> condition)))))
> (sb-sys:add-fd-handler
> (sb-bsd-sockets:socket-file-descriptor k)
> :input
> (lambda (fd)
> (declare (ignore fd))
> (loop while (op:work_pending *the-orb*)
> do (op:perform_work *the-orb*))))))
>
> and it brought no relief.
> Error was signalled, and backtrace was:
>
> 0: (SB-IMPL::HANDLER-DESCRIPTORS-ERROR)
> 1: (SB-IMPL::SUB-SERVE-EVENT NIL 0)
> 2: (SB-SYS:WAIT-UNTIL-FD-USABLE 0 :INPUT NIL)
>
> (op:perform_work) doesn't call SB-SYS:SERVE-EVENT...
> Is there any way to bind handlers for SB-IMPL::SUB-SERVE-EVENT?
> Or around REPL, so to say? Kind of "global" HANDLER-BIND?
Hi Dmitri,
Ah, right. I don't know of any /portable/ way to define a global
HANDLER-BIND for a particular condition as you suggest. In SBCL,
you'd have to hack src/code/toplevel.lisp. To work around this,
instead of working in the REPL directly, I usually have a global entry
point to the server, and have the global HANDLER-BIND be one of the
first few forms, something like this:
(defun server ()
(handler-bind (error ...)
server-body ...))
SERVER-BODY manages the fd-handlers (ensuring no active fd-handler on
exit etc.) and calls SERVE-EVENT. Would this approach be
unsatisfactory? Do you need to work in the REPL? (When working in
the REPL directly, I find the fd conditions more reminder than
irritant.)
Cheers,
--Tony
|