changed access variable name
[NeonServV5.git] / WHOHandler.c
index 994f288aa399fc3edfe462bb897679b8a10bd389..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;
 }
@@ -72,10 +79,10 @@ void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *dat
 void get_userauth(struct UserNode *user, userauth_callback_t callback, void *data) {
     struct ClientSocket *bot;
     for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
-        if(isUserOnChan(bot->user, chan))
+        if(bot->flags & SOCKET_FLAG_PREFERRED)
             break;
     }
-    if(bot == NULL) return;
+    if(bot == NULL) bot = getBots(SOCKET_FLAG_READY, NULL);
     struct WHOQueueEntry* entry = addWHOQueueEntry(bot);
     entry->type = WHOQUEUETYPE_ISONQUEUE | WHOQUEUETYPE_USERAUTH;
     entry->user = user;