Skip to content

Commit 6fc130d

Browse files
committed
Add next-connection-id
1 parent a538f2b commit 6fc130d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

http/connection.lisp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
:initform (local-time:now)
4242
:accessor connection-open-time)))
4343

44-
(defvar *connection* nil)
44+
(let ((counter 0))
45+
(defun next-connection-id ()
46+
(excl:incf-atomic counter)))
4547

46-
(defvar *global-connection-indexer* 0)
48+
(defvar *connection* nil)
4749

4850
;; TODO: Use weak hash table
4951
(defvar *connection-table* (make-hash-table))
@@ -81,7 +83,7 @@
8183
(error "Expect IPv4 address, got ~A" address))
8284
(format nil "~{~A~,^.~}" (coerce address 'list))))
8385
(let ((connection (make-instance 'connection
84-
:id (excl:incf-atomic *global-connection-indexer*)
86+
:id (next-connection-id)
8587
:listener listener
8688
:socket socket
8789
:input-stream stream

0 commit comments

Comments
 (0)