entry->client = client;
if(last_entry)
last_entry->next = entry;
+ else
+ last_entry = entry;
if(!first_entry)
first_entry = entry;
return entry;
}
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;
}
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;