[slime-devel] Slime, SBCL and add-fd-handler
Helmut Eller
heller at common-lisp.net
Fri Jan 6 09:10:27 UTC 2006
* Dmitri Hrapof [2006-01-05 17:03+0100] writes:
> Hello!
> I'm using add-fd-handler in my server,
> and everything works in raw terminal.
> However, when I start server from Slime,
> I have to call (SB-IMPL::SERVE-EVENT) manually to
> get my callbacks called and client's request
> answered.
> Is this expected behaviour?
No.
> What is idiomatic solution?
I think the most idiomatic solution would be use threads instead of
fd-handlers.
> It seems to me
> I've done everything as Araneida does:
>
> (defun make-repl-friendly (s)
> (when *repl-friendly*
> (%SYSDEP
> "adds callbacks for socket"
> #+sbcl
> (sb-sys:add-fd-handler
> (sb-bsd-sockets:socket-file-descriptor s)
> :input
> #'(lambda (fd)
> (declare (ignore fd))
> (loop while (op:work_pending *the-orb*)
> do (op:perform_work *the-orb*)))))))
>
> Where should I dig?
How do you wait for incoming requests? Fd-handlers are usually called
when an I/O operation would block (and, of course, explicit calls to
serve-event). In the usual SLIME/SBCL setup, the main thread blocks
in a call to READ and should call fd-handlers. Note that the main
thread writes its output to the *inferior-lisp* buffer and not the
*slime-repl* buffer (SLIME creates its own "repl thread" for the its
REPL).
Maybe you can find out something by looking at the backtraces for each
thread: list the thread with `M-x slime-list-threads' and press `d' to
invoke the debugger on the selected thread.
Helmut.
More information about the slime-devel
mailing list