From 1e4c2e7369860be409964ad1f6f771780b5e2621 Mon Sep 17 00:00:00 2001
From: dscho <dscho>
Date: Mon, 10 Feb 2003 20:21:09 +0000
Subject: really fixed ClientConnectionGone problem

---
 ChangeLog   |  2 ++
 rfbserver.c | 16 ++++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cd982cf..700f6ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+   fixed LinuxVNC colour handling
+   fixed a bug with pthreads where the connection was not closed
    moved vncterm to main package (LinuxVNC included)
    portability fixes (IRIX, OSX, Solaris)
    more portable way to determine endianness and types of a given size
diff --git a/rfbserver.c b/rfbserver.c
index f8b273c..1403714 100644
--- a/rfbserver.c
+++ b/rfbserver.c
@@ -408,14 +408,14 @@ rfbClientConnectionGone(cl)
 #endif
 
 #ifdef HAVE_LIBPTHREAD
-    LOCK(cl->refCountMutex);
-    if(cl->refCount) {
-      UNLOCK(cl->refCountMutex);
-      if(cl->screen->backgroundLoop != FALSE)
-        WAIT(cl->deleteCond,cl->refCountMutex);
-    } else {
-      UNLOCK(cl->refCountMutex);
-    }
+    if(cl->screen->backgroundLoop != FALSE)
+      do {
+	LOCK(cl->refCountMutex);
+	i=cl->refCount;
+	UNLOCK(cl->refCountMutex);
+	if(i>0)
+	  WAIT(cl->deleteCond,cl->refCountMutex);
+      } while(i>0);
 #endif
 
     if(cl->sock>=0)
-- 
cgit v1.2.3

