From 36afeec6f6bf93fef4ebab7d48a613eb9bf52c7e Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 17 Aug 2011 04:59:23 +0200 Subject: [PATCH] fixed WHOHandler.c WHO queue --- WHOHandler.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/WHOHandler.c b/WHOHandler.c index df0d399..3e07192 100644 --- a/WHOHandler.c +++ b/WHOHandler.c @@ -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; } -- 2.20.1