summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/papod.clj27
-rw-r--r--tests/integration.clj3
-rw-r--r--tests/unit.clj3
3 files changed, 20 insertions, 13 deletions
diff --git a/src/papod.clj b/src/papod.clj
index 860e7ef..a9b4e41 100644
--- a/src/papod.clj
+++ b/src/papod.clj
@@ -965,6 +965,8 @@
(swap! client assoc :network-id
(:default-network-id components)))
(swap! client assoc :registered? true)
+ (when-let [n (:n-unreg components)]
+ (swap! n (fn [v] (max 0 (dec v)))))
(when (:clients components)
(swap! (:clients components) assoc nick
{:w w :client-atom client}))
@@ -3169,6 +3171,8 @@
(case c
\i (swap! client assoc :invisible? adding?)
\T (swap! client assoc :no-ctcp? adding?)
+ \o (when-not adding?
+ (swap! client assoc :oper? false))
nil))
[(str ":" (client-target client)
" MODE " (client-target client)
@@ -3518,16 +3522,9 @@
:oper?))
@clients))
0)
- n-unreg (if clients
- (count
- (filter
- (fn [[_ m]]
- (not
- (some-> (:client-atom m)
- deref
- :registered?)))
- @clients))
- 0)]
+ n-unreg (or (some-> (:n-unreg components)
+ deref)
+ 0)]
[(numeric-reply client "251"
(str ":There are " n-users
" users and 0 invisible on 1 servers"))
@@ -3944,7 +3941,8 @@
:chan-limits (atom {})
:invites (atom {})
:whowas (atom [])
- :max-users (atom 0)}))
+ :max-users (atom 0)
+ :n-unreg (atom 0)}))
(defconst- +idle-timeout-ms+
(if-let [t (System/getenv "PAPOD_IDLE_TIMEOUT")]
@@ -3968,6 +3966,8 @@
:w w :connection-id conn-id
:socket socket})]
;; Record connection start
+ (when-let [n (:n-unreg components)]
+ (swap! n inc))
(when-let [conn (:conn components)]
@(d/transact conn
[{:db/ensure :papod.connection/attrs
@@ -3986,6 +3986,11 @@
(recur new-acc))))))
(catch Exception _)
(finally
+ ;; If still unregistered, decrement count
+ (when (and (not (:registered? @client))
+ (:n-unreg components))
+ (swap! (:n-unreg components)
+ (fn [v] (max 0 (dec v)))))
;; Clean up in-memory state FIRST (before slow I/O)
(when-let [nick (:nick @client)]
;; Record WHOWAS history (skip if QUIT already did)
diff --git a/tests/integration.clj b/tests/integration.clj
index bee3f23..7b20575 100644
--- a/tests/integration.clj
+++ b/tests/integration.clj
@@ -51,7 +51,8 @@
:chan-limits (atom {})
:invites (atom {})
:whowas (atom [])
- :max-users (atom 0)}))
+ :max-users (atom 0)
+ :n-unreg (atom 0)}))
(defn- make-client
"Creates a simulated client connection using piped streams.
diff --git a/tests/unit.clj b/tests/unit.clj
index c398350..687c91f 100644
--- a/tests/unit.clj
+++ b/tests/unit.clj
@@ -117,7 +117,8 @@
:chan-limits (atom {})
:invites (atom {})
:whowas (atom [])
- :max-users (atom 0)})))
+ :max-users (atom 0)
+ :n-unreg (atom 0)})))
(defn test-network!
[conn]