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? What is idiomatic solution? 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?
Thanks, Dmitri
* 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.
Helmut Eller <heller <at> common-lisp.net> writes:
What is idiomatic solution?
I think the most idiomatic solution would be use threads instead of fd-handlers.
I'd like to stay as cross-platform as possible, so I'd prefer not to use threads while select() suffices. But thank you for your answer.
On 1/5/06, Dmitri Hrapof yavannadil@yahoo.com wrote:
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.
What platform? What is the value of swank:*communication-style*? I routinely use serve-event in combination with slime and sbcl, so I can confirm that everything should work correctly, at least if you use :fd-handler communication. Maybe you're on a threaded platform, and slime's threaded communication is somehow blocking serve-event? If that's the case, the easiest solution might be to spawn a thread that just calls into serve-event.
Thomas F. Burdick <tfb <at> ocf.berkeley.edu> writes:
What platform?
SBCL 0.9.8, Linux 2.6.13 i686
What is the value of swank:*communication-style*?
it was :spawn, now it's :fd-handler and everything works. Thanks a lot!