As data point I can reliably restart images in which I've executed this form:
(setf *restart-init-function* (lambda () (dolist (connection swank::*connections*) (format t "closing ~a~%" connection) (swank::close-connection connection nil nil))))
Without that the reliability ranges from "works most of the time" to "never ever works" depending on the OS I'm testing on. This solution uses a number of non exported swank features and I'm still not sure if it's the right direction to go. Any thoughts? Thanks, Andrew
On Fri, Nov 4, 2011 at 8:56 AM, Andrew Myers asm198@gmail.com wrote:
So I've been looking into the problem of restarting a lisp image saved from Slime. It appears to me that Swank is still blocked on the socket listening for connections in the restarted image in some cases (I'm not sure why it's inconsistent). As a result when the image is restarted it's stuck listening on a connection that will never receive data and can't execute the Swank initialization process to connect to the new socket which Slime has chosen.
I was thinking that I would implement swank-backend:save-image to shutdown Swank before dumping the image (or possibly have the restart function shutdown any existing Swank processes) so there's nothing in the way of Swank being re-initialized when the image is loaded again. (Does this sounds like a reasonable thing to do?) I'm not sure how to do this though, there only seem to be methods for shutting down the Swank server, not individual connections. Looking at other implementations of save-image wasn't very illuminating so I seem to be missing something.
It looks like the connection struct and the *connections* defvar might have what I need in it, but there is only sanctioned access to the most recently opened connection via `default-connection`. Presumably I would need to close _all_ *connections*?
Can anyone point me in the right direction?
Thanks, Andrew