- userrec* u = a->GetUser();
- /* Because ServerInstance->DoOneIteration can
- * take the user away from us in the middle of
- * our operation, we should check to see if this
- * pointer is still valid by iterating the hash.
- * It's expensive, yes, but the DoOneIteration
- * call stops it being horrendously bad.
+
+ user_hash::iterator iter = ServerInstance->clientlist->find(a->GetUser()->nick);
+ std::map<userrec*, userrec*>::iterator exemptiter = exempt.find(a->GetUser());
+ const char* preset_reason = a->GetUser()->GetOperQuit();
+ std::string reason = a->GetReason();
+ std::string oper_reason = *preset_reason ? preset_reason : a->GetOperReason();
+
+ if (reason.length() > MAXQUIT - 1)
+ reason.resize(MAXQUIT - 1);
+ if (oper_reason.length() > MAXQUIT - 1)
+ oper_reason.resize(MAXQUIT - 1);
+
+ if (a->GetUser()->registered != REG_ALL)
+ if (ServerInstance->unregistered_count)
+ ServerInstance->unregistered_count--;
+
+ if (IS_LOCAL(a->GetUser()))
+ {
+ a->GetUser()->Write("ERROR :Closing link (%s@%s) [%s]", a->GetUser()->ident, a->GetUser()->host, oper_reason.c_str());
+ if ((!a->GetUser()->sendq.empty()) && (!(*a->GetUser()->GetWriteError())))
+ a->GetUser()->FlushWriteBuf();
+ }
+
+ if (a->GetUser()->registered == REG_ALL)
+ {
+ FOREACH_MOD_I(ServerInstance,I_OnUserQuit,OnUserQuit(a->GetUser(), reason, oper_reason));
+ a->GetUser()->PurgeEmptyChannels();
+ a->GetUser()->WriteCommonQuit(reason, oper_reason);
+ }
+
+ FOREACH_MOD_I(ServerInstance,I_OnUserDisconnect,OnUserDisconnect(a->GetUser()));
+
+ if (IS_LOCAL(a->GetUser()))
+ {
+ if (ServerInstance->Config->GetIOHook(a->GetUser()->GetPort()))
+ {
+ try
+ {
+ ServerInstance->Config->GetIOHook(a->GetUser()->GetPort())->OnRawSocketClose(a->GetUser()->GetFd());
+ }
+ catch (CoreException& modexcept)
+ {
+ ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
+ }
+ }
+
+ ServerInstance->SE->DelFd(a->GetUser());
+ a->GetUser()->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.