From 403d5207f06f9dfce922ca578d0a9d21b9155fb5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 2 Oct 2008 08:30:38 -0500 Subject: [PATCH] stop-server/stop-this-server split --- basis/concurrency/distributed/distributed.factor | 2 +- basis/http/http-tests.factor | 2 +- basis/io/encodings/ascii/ascii-docs.factor | 4 ++-- basis/io/servers/connection/connection-docs.factor | 13 ++++++++++--- basis/io/servers/connection/connection-tests.factor | 2 +- basis/io/servers/connection/connection.factor | 7 +++++-- basis/io/sockets/sockets-docs.factor | 2 +- basis/tools/deploy/deploy-tests.factor | 2 +- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/basis/concurrency/distributed/distributed.factor b/basis/concurrency/distributed/distributed.factor index 5e2f1bb6d1..99ad239011 100755 --- a/basis/concurrency/distributed/distributed.factor +++ b/basis/concurrency/distributed/distributed.factor @@ -10,7 +10,7 @@ SYMBOL: local-node : handle-node-client ( -- ) deserialize - [ first2 get-process send ] [ stop-server ] if* ; + [ first2 get-process send ] [ stop-this-server ] if* ; : ( addrspec -- threaded-server ) diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 9a1421a3ad..49ef03543e 100755 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -179,7 +179,7 @@ http.server.dispatchers db.tuples ; : add-quit-action - [ stop-server "Goodbye" "text/html" ] >>display + [ stop-this-server "Goodbye" "text/html" ] >>display "quit" add-responder ; : test-db "test.db" temp-file sqlite-db ; diff --git a/basis/io/encodings/ascii/ascii-docs.factor b/basis/io/encodings/ascii/ascii-docs.factor index fa496a3526..e0ab11f1a4 100644 --- a/basis/io/encodings/ascii/ascii-docs.factor +++ b/basis/io/encodings/ascii/ascii-docs.factor @@ -4,8 +4,8 @@ IN: io.encodings.ascii HELP: ascii { $class-description "ASCII encoding descriptor." } ; -ARTICLE: "ascii" "ASCII encoding" +ARTICLE: "io.encodings.ascii" "ASCII encoding" "By default, if there's a non-ASCII character in an input stream, it will be replaced with a replacement character (U+FFFD), and if a non-ASCII character is used in output, an exception is thrown." { $subsection ascii } ; -ABOUT: "ascii" +ABOUT: "io.encodings.ascii" diff --git a/basis/io/servers/connection/connection-docs.factor b/basis/io/servers/connection/connection-docs.factor index 839f3d8414..00711ce226 100755 --- a/basis/io/servers/connection/connection-docs.factor +++ b/basis/io/servers/connection/connection-docs.factor @@ -58,9 +58,11 @@ ARTICLE: "io.servers.connection" "Threaded servers" { $subsection start-server } { $subsection start-server* } { $subsection wait-for-server } +"Stopping the server:" +{ $subsection stop-server } "From within the dynamic scope of a client handler, several words can be used to interact with the threaded server:" { $subsection remote-address } -{ $subsection stop-server } +{ $subsection stop-this-server } { $subsection secure-port } { $subsection insecure-port } "Additionally, the " { $link local-address } " variable is set, as in " { $link with-client } "." ; @@ -88,7 +90,8 @@ HELP: handle-client* HELP: start-server { $values { "threaded-server" threaded-server } } -{ $description "Starts a threaded server, returning when a client handler calls " { $link stop-server } "." } ; +{ $description "Starts a threaded server." } +{ $notes "Use " { $link stop-server } " or " { $link stop-this-server } " to stop the server." } ; HELP: wait-for-server { $values { "threaded-server" threaded-server } } @@ -96,9 +99,13 @@ HELP: wait-for-server HELP: start-server* { $values { "threaded-server" threaded-server } } -{ $description "Starts a threaded server, returning as soon as it is accepting connections." } ; +{ $description "Starts a threaded server, returning as soon as it is ready to begin accepting connections." } ; HELP: stop-server +{ $values { "threaded-server" threaded-server } } +{ $description "Stops a threaded server, preventing it from accepting any more connections and returning to the caller of " { $link start-server } ". All client connections which have already been opened continue to be serviced." } ; + +HELP: stop-this-server { $description "Stops the current threaded server, preventing it from accepting any more connections and returning to the caller of " { $link start-server } ". All client connections which have already been opened continue to be serviced." } ; HELP: secure-port diff --git a/basis/io/servers/connection/connection-tests.factor b/basis/io/servers/connection/connection-tests.factor index aa8df0b16c..a3223ed2aa 100755 --- a/basis/io/servers/connection/connection-tests.factor +++ b/basis/io/servers/connection/connection-tests.factor @@ -33,7 +33,7 @@ concurrency.promises io.encodings.ascii io threads calendar ; 5 >>max-connections 1237 >>insecure - [ "Hello world." write stop-server ] >>handler + [ "Hello world." write stop-this-server ] >>handler "server" set ] unit-test diff --git a/basis/io/servers/connection/connection.factor b/basis/io/servers/connection/connection.factor index bde4e518ac..0516f24402 100755 --- a/basis/io/servers/connection/connection.factor +++ b/basis/io/servers/connection/connection.factor @@ -136,8 +136,11 @@ PRIVATE> [ wait-for-server ] bi ; -: stop-server ( -- ) - threaded-server get [ f ] change-sockets drop dispose-each ; +: stop-server ( threaded-server -- ) + [ f ] change-sockets drop dispose-each ; + +: stop-this-server ( -- ) + threaded-server get stop-server ; GENERIC: port ( addrspec -- n ) diff --git a/basis/io/sockets/sockets-docs.factor b/basis/io/sockets/sockets-docs.factor index 3c77be254c..3454f3384e 100755 --- a/basis/io/sockets/sockets-docs.factor +++ b/basis/io/sockets/sockets-docs.factor @@ -104,7 +104,7 @@ HELP: } ; HELP: with-client -{ $values { "remote" "an address specifier" } { "encoding" "an encding descriptor" } { "quot" quotation } } +{ $values { "remote" "an address specifier" } { "encoding" "an encoding descriptor" } { "quot" quotation } } { $description "Opens a network connection and calls the quotation in a new dynamic scope with " { $link input-stream } " and " { $link output-stream } " rebound to the network streams. The local address the socket is bound to is stored in the " { $link local-address } " variable." } { $errors "Throws an error if the connection cannot be established." } ; diff --git a/basis/tools/deploy/deploy-tests.factor b/basis/tools/deploy/deploy-tests.factor index 1d5b59bf0c..db4255cdb1 100755 --- a/basis/tools/deploy/deploy-tests.factor +++ b/basis/tools/deploy/deploy-tests.factor @@ -66,7 +66,7 @@ http.server.responses http.server.static io.servers.connection ; SINGLETON: quit-responder M: quit-responder call-responder* - 2drop stop-server "Goodbye" "text/html" ; + 2drop stop-this-server "Goodbye" "text/html" ; : add-quot-responder ( responder -- responder ) quit-responder "quit" add-responder ;