diff --git a/source/clog-connection-websockets.lisp b/source/clog-connection-websockets.lisp index 92ce024..82caeb2 100644 --- a/source/clog-connection-websockets.lisp +++ b/source/clog-connection-websockets.lisp @@ -169,7 +169,7 @@ (when *verbose-output* (format t "Connection close request ~A.~%" connection)) - (when *reconnect-delay* + (when (and *clog-running* *reconnect-delay*) (when *verbose-output* (format t "Connection close request ~A delayed ~A for reconnects.~%" connection *reconnect-delay*)) diff --git a/source/clog-connection.lisp b/source/clog-connection.lisp index 6289ed9..4a4a7ce 100644 --- a/source/clog-connection.lisp +++ b/source/clog-connection.lisp @@ -41,6 +41,7 @@ script." (*reconnect-delay* variable) (*static-root* variable) (*clog-port* variable) + (*clog-running* variable) (initialize function) (random-port function) @@ -95,7 +96,7 @@ script." (defparameter *static-root* nil "Contains the static-root setting after initialization.") (defparameter *clog-port* 8080 "Port this instance of clog was started on") (defvar *plugin-paths* (make-hash-table* :test #'equalp) "Path regex -> static-root") - +(defvar *clog-running* nil "CLOG initialized and running.") (defvar *on-connect-handler* nil "New connection event handler.") @@ -212,6 +213,7 @@ the default answer. (Private)" (defun shutdown-clog () "Shutdown CLOG." + (setf *clog-running* nil) (shutdown-connection) (clrhash *connection-data*) (clrhash *connections*) diff --git a/source/clog-system.lisp b/source/clog-system.lisp index d0cded5..fe0f0bd 100644 --- a/source/clog-system.lisp +++ b/source/clog-system.lisp @@ -14,8 +14,6 @@ (defvar *url-to-on-new-window* (make-hash-table* :test 'equalp) "URL to on-new-window handlers (private)") -(defvar *clog-running* nil "If clog running.") - (defvar *clog-debug* nil "Set a debug hook that is called for every event with (event data) that must be (funcall event data).") @@ -119,8 +117,8 @@ number is chosen." (setf *extended-routing* extended-routing) (when on-new-window-handler (set-on-new-window on-new-window-handler :path "/" :boot-file boot-file)) - (unless *clog-running* - (setf *clog-running* t) + (unless clog-connection:*clog-running* + (setf clog-connection:*clog-running* t) (when (or (eql port 0) (eq port nil)) (setf port (clog-connection:random-port))) (apply #'clog-connection:initialize @@ -148,7 +146,7 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed." ;;;;;;;;;;;;;;;;;; (defun is-running-p () - *clog-running*) + clog-connection:*clog-running*) ;;;;;;;;;;;;;; ;; shutdown ;; @@ -156,10 +154,9 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed." (defun shutdown () "Shutdown CLOG." - (when *clog-running* + (when clog-connection:*clog-running* (clrhash *url-to-on-new-window*) - (clog-connection:shutdown-clog) - (setf *clog-running* nil))) + (clog-connection:shutdown-clog))) ;;;;;;;;;;;;;;;; ;; debug-mode ;;