- user_hash::iterator iter = Instance->clientlist.find(user->nick);
-
-/*
- * I'm pretty sure returning here is causing a desync when part of the net thinks a user is gone,
- * and another part doesn't. We want to broadcast the quit/kill before bailing so the net stays in sync.
- *
- * I can't imagine this blowing up, so I'm commenting it out. We still check
- * before playing with a bad iterator below in our if(). DISCUSS THIS BEFORE YOU DO ANYTHING. --w00t
- *
- * if (iter == clientlist.end())
- * return;
- */
- std::string reason = quitreason;
-
- if (reason.length() > MAXQUIT - 1)
- reason.resize(MAXQUIT - 1);
-
- if (IS_LOCAL(user))
- user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
-
- if (user->registered == REG_ALL)
- {
- user->PurgeEmptyChannels();
- FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
- user->WriteCommonExcept("QUIT :%s",reason.c_str());
- }
-
- if (IS_LOCAL(user))
- user->FlushWriteBuf();
-
- FOREACH_MOD_I(Instance,I_OnUserDisconnect,OnUserDisconnect(user));
-
- if (IS_LOCAL(user))
- {
- if (Instance->Config->GetIOHook(user->GetPort()))
- {
- try
- {
- Instance->Config->GetIOHook(user->GetPort())->OnRawSocketClose(user->fd);
- }
- catch (ModuleException& modexcept)
- {
- Instance->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
- }
- }
-
- Instance->SE->DelFd(user);
- user->CloseSocket();
- }
-
- /*
- * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
- * if they were an oper with +sn +qQ.
- */
- if (user->registered == REG_ALL)
- {
- if (IS_LOCAL(user))
- Instance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
- else
- Instance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,reason.c_str());
- user->AddToWhoWas();
- }
-
- if (iter != Instance->clientlist.end())
- {
- Instance->Log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
- if (IS_LOCAL(user))
- {
- if (find(Instance->local_users.begin(),Instance->local_users.end(),user) != Instance->local_users.end())
- Instance->local_users.erase(find(Instance->local_users.begin(),Instance->local_users.end(),user));
- }
- Instance->clientlist.erase(iter);
- DELETE(user);
- }