]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Optimized userlist() (a lot faster with many users online)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 9 May 2005 16:05:07 +0000 (16:05 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 9 May 2005 16:05:07 +0000 (16:05 +0000)
Fixed bug where another users buffer could end up in the buffer of an
exiting client before they quit

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1345 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspircd.cpp

index 36d593fdba646c9383f9d73e7c31a8508e64fbc7..eaedeeb50c6dfe1c2e484b6a4f01a5e150c16396 100644 (file)
@@ -1499,32 +1499,31 @@ void userlist(userrec *user,chanrec *c)
        }
 
        snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-       for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+
+        std::vector<char*> *ulist = c->GetUsers();
+       for (int i = 0; i < ulist->size(); i++)
        {
-               if (has_channel(i->second,c))
+               char* o = (*ulist)[i];
+               userrec* otheruser = (userrec*)o;
+               if ((!has_channel(user,c)) && (strchr(otheruser->modes,'i')))
                {
-                       if (isnick(i->second->nick))
-                       {
-                               if ((!has_channel(i->second,c)) && (strchr(i->second->modes,'i')))
-                               {
-                                       /* user is +i, and source not on the channel, does not show
-                                        * nick in NAMES list */
-                                       continue;
-                               }
-                               strlcat(list,cmode(i->second,c),MAXBUF);
-                               strlcat(list,i->second->nick,MAXBUF);
-                               strlcat(list," ",MAXBUF);
-                               if (strlen(list)>(480-NICKMAX))
-                               {
-                                       /* list overflowed into
-                                        * multiple numerics */
-                                       WriteServ(user->fd,"%s",list);
-                                       snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-                               }
-                       }
+                       /* user is +i, and source not on the channel, does not show
+                        * nick in NAMES list */
+                       continue;
+               }
+               strlcat(list,cmode(otheruser,c),MAXBUF);
+               strlcat(list,otheruser->nick,MAXBUF);
+               strlcat(list," ",MAXBUF);
+               if (strlen(list)>(480-NICKMAX))
+               {
+                       /* list overflowed into
+                        * multiple numerics */
+                       WriteServ(user->fd,"%s",list);
+                       snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
                }
        }
-       /* if whats left in the list isnt empty, send it */     if (list[strlen(list)-1] != ':')
+       /* if whats left in the list isnt empty, send it */
+       if (list[strlen(list)-1] != ':')
        {
                WriteServ(user->fd,"%s",list);
        }
@@ -4287,6 +4286,7 @@ int InspIRCd(char** argv, int argc)
                                                int currfd = current->fd;
                                                int floodlines = 0;
                                                // add the data to the users buffer
+                                               if (result > 0)
                                                if (!current->AddBuffer(data))
                                                {
                                                        // AddBuffer returned false, theres too much data in the user's buffer and theyre up to no good.