From 827392a0b542ef62612e0e32b03a1ca4df21b2e2 Mon Sep 17 00:00:00 2001 From: Gerd Flaig Date: Thu, 16 Apr 2009 19:06:30 +0200 Subject: [PATCH] Kill stale update thread --- web.lisp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web.lisp b/web.lisp index 96fcb29..68870b9 100644 --- a/web.lisp +++ b/web.lisp @@ -37,6 +37,10 @@ :accessor update-queue :initform (locked-queue:create) :documentation "Updates to be sent to the browser") + (update-thread + :accessor update-thread + :initform nil + :documentation "COMET thread waiting for updates of non-NIL") (connection :accessor connection :documentation "Connection to the empire game server"))) @@ -64,7 +68,13 @@ (defun update () "Send stream of updates to client" (with-session - (locked-queue:dequeue (update-queue *empire-session*)))) + (when (update-thread *empire-session*) + (empire-log:info "~a: Killing update thread ~a." *empire-session* (update-thread *empire-session*)) + (sb-thread:terminate-thread (update-thread *empire-session*))) + (setf (update-thread *empire-session*) sb-thread:*current-thread*) + (let ((next-update (locked-queue:dequeue (update-queue *empire-session*)))) + (setf (update-thread *empire-session*) nil) + next-update))) (defmethod send ((s session) string) "Push a javascript update fragment to the client." -- 2.43.0