<!DOCTYPE html><html><head><style type="text/css">body { font-family:'DejaVu Sans Mono'; font-size:12px; background:Window}</style></head><body><div>On Fri, 04 Nov 2011 06:13:25 -0700, Andrew Myers <asm198@gmail.com> wrote:<br><br>> As data point I can reliably restart images in which I've executed this <br>> form:<br>><br>> (setf *restart-init-function*<br>> (lambda ()<br>> (dolist (connection swank::*connections*)<br>> (format t "closing ~a~%" connection)<br>> (swank::close-connection connection nil nil))))<br>><br>> Without that the reliability ranges from "works most of the time" to<br>> "never ever works" depending on the OS I'm testing on. This solution<br>> uses a number of non exported swank features and I'm still not sure if<br>> it's the right direction to go. Any thoughts?<br>> Thanks,<br>> Andrew<br>><br>> On Fri, Nov 4, 2011 at 8:56 AM, Andrew Myers <asm198@gmail.com> wrote:<br>>> So I've been looking into the problem of restarting a lisp image saved<br>>> from Slime. It appears to me that Swank is still blocked on the<br>>> socket listening for connections in the restarted image in some cases<br>>> (I'm not sure why it's inconsistent). As a result when the image is<br>>> restarted it's stuck listening on a connection that will never receive<br>>> data and can't execute the Swank initialization process to connect to<br>>> the new socket which Slime has chosen.<br>>><br>>> I was thinking that I would implement swank-backend:save-image to<br>>> shutdown Swank before dumping the image (or possibly have the restart<br>>> function shutdown any existing Swank processes) so there's nothing in<br>>> the way of Swank being re-initialized when the image is loaded again.<br>>> (Does this sounds like a reasonable thing to do?) I'm not sure how to<br>>> do this though, there only seem to be methods for shutting down the<br>>> Swank server, not individual connections. Looking at other<br>>> implementations of save-image wasn't very illuminating so I seem to be<br>>> missing something.<br>>><br>>> It looks like the connection struct and the *connections* defvar might<br>>> have what I need in it, but there is only sanctioned access to the<br>>> most recently opened connection via `default-connection`. Presumably<br>>> I would need to close _all_ *connections*?<br>>><br>>> Can anyone point me in the right direction?<br>>><br><br><br>I'm not sure this will help, but here's the way I create an executable image with swank that works (100% of the time).<br>It's SBCL specific but I'm guessing you can generalize it. <br><br>;; Shut down Swank and anyone else by terminating all threads<br>(dolist (thread (sb-thread:list-all-threads))<br> (unless (equal sb-thread:*current-thread* thread)<br> (sb-thread:terminate-thread thread)))<br>;; Set the function to run on startup of the core executable<br>(setf sb-ext:*init-hooks* (list #'start-the-servers))<br>;; Dump core and exit<br>(sb-ext:save-lisp-and-die *core* :executable t)<br><br></div><div><br></div><div>Note that since all the threads have to be shut down first, you cannot do this from within Slime, but from the command line it is:<br><br>sbcl make-core.lisp</div><div><br></div><div>Jeff</div></body></html>