[PATCH] New GF session-count removes forward reference to h.d.ws.application from server

Kambiz Darabi darabi at m-creations.net
Wed Jun 17 14:15:38 UTC 2015


The GF session-count has a default method which returns 0 and one
which specialises on 'application, lives in the hdws.application
system, and returns the number of entries in the session hashtable.

---
 source/application/application.lisp | 6 ++++--
 source/server/brokers.lisp          | 5 +++++
 source/server/misc.lisp             | 4 +---
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/source/application/application.lisp b/source/application/application.lisp
index 4524ea4..fe3ba55 100644
--- a/source/application/application.lisp
+++ b/source/application/application.lisp
@@ -79,11 +79,13 @@
                             (return-from broker-path-to-broker (nreverse path))))
                    :visit-type :path))
 
+(def method session-count ((broker application))
+  (hash-table-count (session-id->session-of broker)))
+
 (def function total-web-session-count (server)
   (bind ((sum 0))
     (map-broker-tree server (lambda (el)
-                              (when (typep el 'application)
-                                (incf sum (hash-table-count (session-id->session-of el))))))
+                              (incf sum (session-count el))))
     sum))
 
 (def function map-broker-tree (root visitor &key
diff --git a/source/server/brokers.lisp b/source/server/brokers.lisp
index d9f0614..0cac3b5 100644
--- a/source/server/brokers.lisp
+++ b/source/server/brokers.lisp
@@ -118,6 +118,11 @@
                            (lambda ()
                              (produce-response broker request))))
 
+(def generic session-count (broker)
+  (:documentation "Returns, how many sessions this broker currently maintains; default method returns 0")
+  (:method (b)
+    0))
+
 ;; the default handler of brokers start a new generic protocol to introduce a customizable point of filtering
 (def function broker/default-handler (&key broker request &allow-other-keys)
   (handle-request broker request))
diff --git a/source/server/misc.lisp b/source/server/misc.lisp
index b02e6d5..aa1d8b2 100644
--- a/source/server/misc.lisp
+++ b/source/server/misc.lisp
@@ -55,9 +55,7 @@
     (format stream "Number of failed requests:                  ~A~%" (failed-request-count-of *server*))
     (format stream "Number of client connection resets:         ~A~%" (client-connection-reset-count-of *server*))
     (format stream "Number of live web sessions:                ~A~%" (iter (for broker :in (brokers-of *server*))
-                                                                            ;; FIXME forward references for application stuff
-                                                                            (when (typep broker 'application)
-                                                                              (summing (hash-table-count (session-id->session-of broker))))))
+                                                                            (summing (session-count broker))))
     (terpri)
     (awhen (and (boundp '*application*)
                 (symbol-value '*application*))
-- 
1.9.1




More information about the cl-dwim-devel mailing list