fixed WHOHandler.c WHO queue
authorpk910 <philipp@zoelle1.de>
Wed, 17 Aug 2011 02:59:23 +0000 (04:59 +0200)
committerpk910 <philipp@zoelle1.de>
Wed, 17 Aug 2011 03:04:33 +0000 (05:04 +0200)
WHOHandler.c

index df0d399c3a0ba7b5d3f00c1d4b37d30536e1439d..3e07192ea24025c8c82f35ff12c299b5e8e2a137 100644 (file)
@@ -32,6 +32,8 @@ static struct WHOQueueEntry* addWHOQueueEntry(struct ClientSocket *client) {
     entry->client = client;
     if(last_entry)
         last_entry->next = entry;
+    else
+        last_entry = entry;
     if(!first_entry)
         first_entry = entry;
     return entry;
@@ -46,9 +48,14 @@ static struct WHOQueueEntry* getNextWHOQueueEntry(struct ClientSocket *client, i
     }
     if(entry == NULL) return NULL;
     if(freeEntry) {
-        first_entry = first_entry->next;
-        if(last_entry == first_entry)
-            last_entry = NULL;
+        if(entry == first_entry)
+            first_entry = entry->next;
+        if(entry == last_entry) {
+            struct WHOQueueEntry *last;
+            for(last = first_entry; last; last = last->next)
+                if(last->next == NULL) break;
+            last_entry = last;
+        }
     }
     return entry;
 }