I run a long-lived lisp image that I access remotely, and I'd like to be able to update slime dynamically without stopping and restarting the whole image. The catch is that after the re-load, I need to restart the Swank listener thread in case the code for its function has changed. Although the current CVS version of Slime can stop a running Swank server by using kill-nth-thread, it doesn't expose the socket that the thread was listening to. Subsequent threads can't bind to the port number because there is already a socket using it, and without a reference to the socket object, it can't be closed.
The attached patch provides this access by defining a new package variable, *listener-sockets*. There are also two new functions: stop-server and restart-server. I'm using SBCL 2.6.18, and I have only tested this code with :spawn style servers, but even though I don't use :fd-handler or :sigio, I have provided code for them if anyone is interested in trying it out.
With these changes, an online update to a remote lisp should be possible from the Slime REPL as follows:
<cvs update slime> (load ".../swank.asd") (asdf:oos 'asdf:load-op 'swank) (swank:restart-server :port 4005 :style :spawn :dont-close t) <slime-disconnect and restart emacs>
This code works well for me, but I'm not very familiar with Slime implementation details, so it would not surprise me if I've missed something important in my patch. I hope it proves useful to others.
Thanks, -A
* Alan Caulkins [2007-12-01 10:25+0100] writes:
This code works well for me, but I'm not very familiar with Slime implementation details, so it would not surprise me if I've missed something important in my patch. I hope it proves useful to others.
A way to close those sockets is a good feature. The implementation could be improved a bit, though. For now I committed the patch as it was.
Helmut.