Revision: 4218 Author: edi URL: http://bknr.net/trac/changeset/4218
Rename, part 1
U trunk/thirdparty/hunchentoot/connection-manager.lisp U trunk/thirdparty/hunchentoot/server.lisp U trunk/thirdparty/hunchentoot/specials.lisp
Modified: trunk/thirdparty/hunchentoot/connection-manager.lisp =================================================================== --- trunk/thirdparty/hunchentoot/connection-manager.lisp 2009-02-10 09:32:46 UTC (rev 4217) +++ trunk/thirdparty/hunchentoot/connection-manager.lisp 2009-02-10 10:28:58 UTC (rev 4218) @@ -29,46 +29,46 @@
(in-package :hunchentoot)
-;;; The connection-manager protocol defines how Hunchentoot schedules +;;; The connection-dispatcher protocol defines how Hunchentoot schedules ;;; request execution to worker threads or for inline execution.
-(defclass connection-manager () +(defclass connection-dispatcher () ((server :initarg :server :reader server :documentation "The Hunchentoot server instance that this -connection manager works for.")) - (:documentation "Base class for all connection managers classes. +connection dispatcher works for.")) + (:documentation "Base class for all connection dispatchers classes. Its purpose is to carry the back pointer to the server instance."))
-(defgeneric execute-acceptor (connection-manager) +(defgeneric execute-acceptor (connection-dispatcher) (:documentation "This function is called once Hunchentoot has performed all initial processing to start listening for incoming connections. It does so by calling the ACCEPT-CONNECTIONS functions of the server, taken from -the SERVER slot of the connection manager instance. +the SERVER slot of the connection dispatcher instance.
-In a multi-threaded environment, the connection manager starts a new +In a multi-threaded environment, the connection dispatcher starts a new thread and calls THUNK in that thread. In a single-threaded environment, the thunk will be called directly."))
-(defgeneric handle-incoming-connection (connection-manager socket) +(defgeneric handle-incoming-connection (connection-dispatcher socket) (:documentation "This function is called by Hunchentoot to start processing of requests on a new incoming connection. SOCKET is the usocket instance that represents the new connection (or a socket handle on LispWorks). -The connection manager starts processing requests on the incoming +The connection dispatcher starts processing requests on the incoming connection by calling the START-REQUEST-PROCESSING function of the -server instance, taken from the SERVER slot in the connection manager +server instance, taken from the SERVER slot in the connection dispatcher instance. The SOCKET argument is passed to START-REQUEST-PROCESSING as argument.
-In a multi-threaded environment, the connection manager runs this function +In a multi-threaded environment, the connection dispatcher runs this function in a separate thread. In a single-threaded environment, this function is called directly."))
-(defgeneric shutdown (connection-manager) +(defgeneric shutdown (connection-dispatcher) (:documentation "Terminate all threads that are currently associated -with the connection manager, if any.") +with the connection dispatcher, if any.") (:method ((manager t)) #+:lispworks (when-let (acceptor (server-acceptor (server manager))) @@ -76,27 +76,27 @@ ;; COMM:START-UP-SERVER (mp:process-kill acceptor))))
-(defclass single-threaded-connection-manager (connection-manager) +(defclass single-threaded-connection-dispatcher (connection-dispatcher) () - (:documentation "Connection manager that runs synchronously in the + (:documentation "Connection Dispatcher that runs synchronously in the thread that invoked the START-SERVER function."))
-(defmethod execute-acceptor ((manager single-threaded-connection-manager)) +(defmethod execute-acceptor ((manager single-threaded-connection-dispatcher)) (accept-connections (server manager)))
-(defmethod handle-incoming-connection ((manager single-threaded-connection-manager) socket) +(defmethod handle-incoming-connection ((manager single-threaded-connection-dispatcher) socket) (process-connection (server manager) socket))
-(defclass one-thread-per-connection-manager (connection-manager) +(defclass one-thread-per-connection-dispatcher (connection-dispatcher) ((acceptor-process :accessor acceptor-process :documentation "Process that accepts incoming connections and dispatches them to new processes for request execution.")) - (:documentation "Connection manager that starts one thread for + (:documentation "Connection Dispatcher that starts one thread for listening to incoming requests and one thread for each incoming connection."))
-(defmethod execute-acceptor ((manager one-thread-per-connection-manager)) +(defmethod execute-acceptor ((manager one-thread-per-connection-dispatcher)) #+:lispworks (accept-connections (server manager)) #-:lispworks @@ -108,13 +108,13 @@ (server-port (server manager))))))
#-:lispworks -(defmethod shutdown ((manager one-thread-per-connection-manager)) +(defmethod shutdown ((manager one-thread-per-connection-dispatcher)) (loop while (bt:thread-alive-p (acceptor-process manager)) do (sleep 1)))
#+:lispworks -(defmethod handle-incoming-connection ((manager one-thread-per-connection-manager) handle) +(defmethod handle-incoming-connection ((manager one-thread-per-connection-dispatcher) handle) (incf *worker-counter*) ;; check if we need to perform a global GC (when (and *cleanup-interval* @@ -137,7 +137,7 @@ port))))
#-:lispworks -(defmethod handle-incoming-connection ((manager one-thread-per-connection-manager) socket) +(defmethod handle-incoming-connection ((manager one-thread-per-connection-dispatcher) socket) (bt:make-thread (lambda () (process-connection (server manager) socket)) :name (format nil "Hunchentoot worker (client: ~A)" (client-as-string socket))))
Modified: trunk/thirdparty/hunchentoot/server.lisp =================================================================== --- trunk/thirdparty/hunchentoot/server.lisp 2009-02-10 09:32:46 UTC (rev 4217) +++ trunk/thirdparty/hunchentoot/server.lisp 2009-02-10 10:28:58 UTC (rev 4218) @@ -74,10 +74,10 @@ specified in (fractional) seconds. The precise semantics of this parameter is determined by the underlying Lisp's implementation of socket timeouts.") - (connection-manager :initarg :connection-manager + (connection-dispatcher :initarg :connection-dispatcher :initform nil - :reader server-connection-manager - :documentation "The connection manager that is + :reader server-connection-dispatcher + :documentation "The connection dispatcher that is responsible for listening to new connections and scheduling them for execution.") #+:lispworks @@ -125,8 +125,8 @@ information about a running Hunchentoot server instance."))
(defmethod initialize-instance :after ((server server) - &key connection-manager-class - connection-manager-arguments + &key connection-dispatcher-class + connection-dispatcher-arguments (threaded *supports-threads-p* threaded-specified-p) (persistent-connections-p threaded @@ -136,12 +136,12 @@ connection-timeout-provided-p) (read-timeout nil read-timeout-provided-p) (write-timeout nil write-timeout-provided-p)) - "The CONNECTION-MANAGER-CLASS and CONNECTION-MANAGER-ARGUMENTS + "The CONNECTION-DISPATCHER-CLASS and CONNECTION-DISPATCHER-ARGUMENTS arguments to the creation of a server instance determine the -connection manager instance that is created. THREADED is the user -friendly version of the CONNECTION-MANAGER-CLASS option. If it is -NIL, an unthreaded connection manager is used. It is an error to -specify both THREADED and a CONNECTION-MANAGER-CLASS argument. +connection dispatcher instance that is created. THREADED is the user +friendly version of the CONNECTION-DISPATCHER-CLASS option. If it is +NIL, an unthreaded connection dispatcher is used. It is an error to +specify both THREADED and a CONNECTION-DISPATCHER-CLASS argument.
The PERSISTENT-CONNECTIONS-P keyword argument defaults to the value of the THREADED keyword argument but can be overridden. @@ -151,19 +151,19 @@ value. If either of READ-TIMEOUT or WRITE-TIMEOUT is specified, CONNECTION-TIMEOUT is not used and may not be supplied." (declare (ignore read-timeout write-timeout)) - (when (and threaded-specified-p connection-manager-class) - (parameter-error "Can't use both THREADED and CONNECTION-MANAGER-CLASS arguments.")) + (when (and threaded-specified-p connection-dispatcher-class) + (parameter-error "Can't use both THREADED and CONNECTION-DISPATCHER-CLASS arguments.")) (unless persistent-connections-specified-p (setf (server-persistent-connections-p server) persistent-connections-p)) - (unless (server-connection-manager server) - (setf (slot-value server 'connection-manager) + (unless (server-connection-dispatcher server) + (setf (slot-value server 'connection-dispatcher) (apply #'make-instance - (or connection-manager-class + (or connection-dispatcher-class (if threaded - 'one-thread-per-connection-manager - 'single-threaded-connection-manager)) + 'one-thread-per-connection-dispatcher + 'single-threaded-connection-dispatcher)) :server server - connection-manager-arguments))) + connection-dispatcher-arguments))) (if (or read-timeout-provided-p write-timeout-provided-p) (when connection-timeout-provided-p (parameter-error "Can't have both CONNECTION-TIMEOUT and either of READ-TIMEOUT and WRITE-TIMEOUT.")) @@ -196,13 +196,13 @@ connections.") (:method ((server server)) (start-listening server) - (execute-acceptor (server-connection-manager server)))) + (execute-acceptor (server-connection-dispatcher server))))
(defgeneric stop (server) (:documentation "Stop the SERVER so that it does no longer accept requests.") (:method ((server server)) (setf (server-shutdown-p server) t) - (shutdown (server-connection-manager server)) + (shutdown (server-connection-dispatcher server)) #-:lispworks (usocket:socket-close (server-listen-socket server))))
@@ -274,7 +274,7 @@ and not all implementations provide for separate read and write timeout parameter setting.
-CONNECTION-MANAGER-CLASS specifies the name of the class to instantiate +CONNECTION-DISPATCHER-CLASS specifies the name of the class to instantiate for managing how connections are mapped to threads. You don't normally want to specify this argument unless you want to have non-standard threading behavior. See the documentation for more information. @@ -340,12 +340,8 @@ "Stops the Hunchentoot server SERVER." (stop server))
-;; connection manager API +;; connection dispatcher API
-(defconstant +new-connection-wait-time+ 2 - "Time in seconds to wait for a new connection to arrive before -performing a cleanup run.") - (defgeneric start-listening (server) (:documentation "Sets up a listen socket for the given SERVER and enables it to listen for incoming connections. This function is @@ -370,7 +366,7 @@ :function (lambda (handle) (unless (server-shutdown-p server) (handle-incoming-connection - (server-connection-manager server) handle))) + (server-connection-dispatcher server) handle))) ;; wait until the server was successfully started ;; or an error condition is returned :wait t) @@ -388,7 +384,7 @@
(defgeneric accept-connections (server) (:documentation "In a loop, accepts a connection and -dispatches it to the server's connection manager object for processing +dispatches it to the server's connection dispatcher object for processing using HANDLE-INCOMING-CONNECTION.") (:method ((server server)) #+:lispworks @@ -403,7 +399,7 @@ (set-timeouts client-connection (server-read-timeout server) (server-write-timeout server)) - (handle-incoming-connection (server-connection-manager server) + (handle-incoming-connection (server-connection-dispatcher server) client-connection)) ;; ignore condition (usocket:connection-aborted-error ())))))) @@ -445,7 +441,7 @@ finally (setf (return-code reply) +http-not-found+))))
(defgeneric process-connection (server socket) - (:documentation "This function is called by the connection manager + (:documentation "This function is called by the connection dispatcher when a new client connection has been established. Arguments are the SERVER object and a usocket socket stream object (or a LispWorks socket handle) in SOCKET. It reads the request headers and hands over
Modified: trunk/thirdparty/hunchentoot/specials.lisp =================================================================== --- trunk/thirdparty/hunchentoot/specials.lisp 2009-02-10 09:32:46 UTC (rev 4217) +++ trunk/thirdparty/hunchentoot/specials.lisp 2009-02-10 10:28:58 UTC (rev 4218) @@ -327,6 +327,10 @@ #+:lispworks t #-:lispworks bt:*supports-threads-p*)
+(defconstant +new-connection-wait-time+ 2 + "Time in seconds to wait for a new connection to arrive before +performing a cleanup run.") + (pushnew :hunchentoot *features*)
;; stuff for Nikodemus Siivola's HYPERDOC