]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cmd_quit.cpp
Add strerror(errno) to port bind failure on TreeSocket
[user/henk/code/inspircd.git] / src / cmd_quit.cpp
index 161bd8451fa6bb3ce36fe40fbe58ff0c4e66741b..0c5db928d5908f7cd59f0aa3096572b137c44cf6 100644 (file)
@@ -2,12 +2,9 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *                <Craig@chatspike.net>
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
  *
- * Written by Craig Edwards, Craig McLure, and others.
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
@@ -29,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance)
 
 CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
 {
-       user_hash::iterator iter = ServerInstance->clientlist.find(user->nick);
+       user_hash::iterator iter = ServerInstance->clientlist->find(user->nick);
        char reason[MAXBUF];
        std::string quitmsg = "Client exited";
 
@@ -82,21 +79,18 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
 
        FOREACH_MOD(I_OnUserDisconnect,OnUserDisconnect(user));
 
-       /* push the socket on a stack of sockets due to be closed at the next opportunity */
        if (IS_LOCAL(user))
        {
                ServerInstance->SE->DelFd(user);
-               if (find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user) != ServerInstance->local_users.end())
-               {
-                       ServerInstance->Log(DEBUG,"Delete local user");
-                       ServerInstance->local_users.erase(find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user));
-               }
+               std::vector<userrec*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user);
+               if (x != ServerInstance->local_users.end())
+                       ServerInstance->local_users.erase(x);
                user->CloseSocket();
        }
        
-       if (iter != ServerInstance->clientlist.end())
+       if (iter != ServerInstance->clientlist->end())
        {
-               ServerInstance->clientlist.erase(iter);
+               ServerInstance->clientlist->erase(iter);
        }
 
        if (user->registered == REG_ALL) {
@@ -109,6 +103,10 @@ CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
                FOREACH_MOD(I_OnPostCommand,OnPostCommand("QUIT", parameters, pcnt, user, CMD_SUCCESS, original_command));
        }
 
+       if (user->registered != REG_ALL)
+               if (ServerInstance->unregistered_count)
+                       ServerInstance->unregistered_count--;
+
        DELETE(user);
        return CMD_USER_DELETED;
 }