REPL Server: Fix 'stop-server-and-clients!'.
authorMark H Weaver <mhw@netris.org>
Tue, 4 Feb 2014 17:18:22 +0000 (12:18 -0500)
committerMark H Weaver <mhw@netris.org>
Wed, 12 Feb 2014 16:21:46 +0000 (11:21 -0500)
commit5ecc58113a0a50d7a5840e9bfccce25b4f8b30ce
tree91878c7b19254d313e5b75e00c85c1c3dc8b2e22
parentb61025ce0f6f14541b23d93f14dfc60022b91ad6
REPL Server: Fix 'stop-server-and-clients!'.

* module/system/repl/server.scm: Import (ice-9 match) and (srfi srfi-1).
  (*open-sockets*): Add comment.  This is now a list of pairs with a
  'force-close' procedure in the cdr.
  (close-socket!): Add comment noting that it is unsafe to call this
  from another thread.
  (add-open-socket!): Add 'force-close' argument, and put it in the cdr
  of the '*open-sockets*' entry.
  (stop-server-and-clients!): Use 'match'.  Remove the first element
  from *open-sockets* immediately.  Call the 'force-close' procedure
  instead of 'close-socket!'.
  (errs-to-retry): New variable.
  (run-server): Add a pipe, used in the 'force-close' procedure to
  cleanly shut down the server.  Put the server socket into non-blocking
  mode.  Use 'select' to monitor both the server socket and the pipe.
  Don't call 'add-open-socket!' on the client-socket.  Close the pipe
  and the server socket cleanly when we're asked to shut down.
  (serve-client): Call 'add-open-socket!' with a 'force-close' procedure
  that cancels the thread.  Set the thread cleanup handler to call
  'close-socket!', instead of calling it in the main body.

* doc/ref/api-evaluation.texi (REPL Servers): Add a caveat to the manual
  entry for 'stop-servers-and-clients!'.
doc/ref/api-evaluation.texi
module/system/repl/server.scm