diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 14:38:24 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-08 14:38:24 +0000 |
commit | 93876363f89ea7a451ba1e18407e08a539854208 (patch) | |
tree | 25b70293d4358ce4af60e355a4b3a8483d666699 /src/users.cpp | |
parent | 6ab1d0dffb8084bf6a2ad8a446a3836fa3760c8a (diff) |
kill_link() and Server::QuitUser() -> userrec::QuitUser() (static member) - this cant be a normal member as it causes the userrec to be deleted, and "delete this" is bad, mmm'k
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4789 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/users.cpp b/src/users.cpp index 34c347cb9..8a48a641c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -634,7 +634,7 @@ void DeleteOper(userrec* user) } } -void kill_link(userrec *user,const char* r) +void userrec::QuitUser(userrec *user,const std::string &quitreason) { user_hash::iterator iter = clientlist.find(user->nick); @@ -648,20 +648,19 @@ void kill_link(userrec *user,const char* r) * if (iter == clientlist.end()) * return; */ + std::string reason = quitreason; - char reason[MAXBUF]; - - strlcpy(reason,r,MAXQUIT-1); - log(DEBUG,"kill_link: %s %d '%s'",user->nick,user->fd,reason); + if (reason.length() > MAXQUIT - 1) + reason.resize(MAXQUIT - 1); if (IS_LOCAL(user)) - Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason); + Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str()); if (user->registered == REG_ALL) { purge_empty_chans(user); FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,reason)); - WriteCommonExcept(user,"QUIT :%s",reason); + WriteCommonExcept(user,"QUIT :%s",reason.c_str()); } if (IS_LOCAL(user)) @@ -698,7 +697,7 @@ void kill_link(userrec *user,const char* r) if (user->registered == REG_ALL) { if (IS_LOCAL(user)) - WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason); + WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str()); AddWhoWas(user); } @@ -709,10 +708,7 @@ void kill_link(userrec *user,const char* r) { fd_ref_table[user->fd] = NULL; if (find(local_users.begin(),local_users.end(),user) != local_users.end()) - { local_users.erase(find(local_users.begin(),local_users.end(),user)); - log(DEBUG,"Delete local user"); - } } clientlist.erase(iter); DELETE(user); @@ -868,13 +864,13 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip) if (local_users.size() > Config->SoftLimit) { - kill_link(_new,"No more connections allowed"); + userrec::QuitUser(_new,"No more connections allowed"); return; } if (local_users.size() >= MAXCLIENTS) { - kill_link(_new,"No more connections allowed"); + userrec::QuitUser(_new,"No more connections allowed"); return; } @@ -890,7 +886,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip) */ if ((unsigned)socket >= MAX_DESCRIPTORS) { - kill_link(_new,"Server is full"); + userrec::QuitUser(_new,"Server is full"); return; } char* e = matches_exception(ipaddr); @@ -901,7 +897,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip) { char reason[MAXBUF]; snprintf(reason,MAXBUF,"Z-Lined: %s",r); - kill_link(_new,reason); + userrec::QuitUser(_new,reason); return; } } @@ -910,7 +906,7 @@ void AddClient(int socket, int port, bool iscached, insp_inaddr ip) { if (!ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT)) { - kill_link(_new, "Internal error handling connection"); + userrec::QuitUser(_new, "Internal error handling connection"); return; } } @@ -1099,14 +1095,14 @@ void force_nickchange(userrec* user,const char* newnick) if (MOD_RESULT) { ServerInstance->stats->statsCollisions++; - kill_link(user,"Nickname collision"); + userrec::QuitUser(user,"Nickname collision"); return; } if (matches_qline(newnick)) { ServerInstance->stats->statsCollisions++; - kill_link(user,"Nickname collision"); + userrec::QuitUser(user,"Nickname collision"); return; } |