From 8a0825e03af56b5be0d150845fedafd83ee01636 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 24 Apr 2004 21:36:35 +0000 Subject: Fixed quit-bouncing issue when a user is g-lined git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@717 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f226f2af5..8f0958890 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1840,6 +1840,56 @@ void kill_link(userrec *user,const char* r) } } +void kill_link_silent(userrec *user,const char* r) +{ + user_hash::iterator iter = clientlist.find(user->nick); + + char reason[MAXBUF]; + + strncpy(reason,r,MAXBUF); + + if (strlen(reason)>MAXQUIT) + { + reason[MAXQUIT-1] = '\0'; + } + + log(DEBUG,"kill_link: %s '%s'",user->nick,reason); + Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason); + log(DEBUG,"closing fd %d",user->fd); + + /* bugfix, cant close() a nonblocking socket (sux!) */ + if (user->registered == 7) { + FOREACH_MOD OnUserQuit(user); + WriteCommonExcept(user,"QUIT :%s",reason); + + // Q token must go to ALL servers!!! + char buffer[MAXBUF]; + snprintf(buffer,MAXBUF,"Q %s :%s",user->nick,reason); + NetSendToAll(buffer); + } + + /* push the socket on a stack of sockets due to be closed at the next opportunity + * 'Client exited' is an exception to this as it means the client side has already + * closed the socket, we don't need to do it. + */ + fd_reap.push_back(user->fd); + + bool do_purge = false; + + if (iter != clientlist.end()) + { + log(DEBUG,"deleting user hash value %d",iter->second); + if ((iter->second) && (user->registered == 7)) { + delete iter->second; + } + clientlist.erase(iter); + } + + if (user->registered == 7) { + purge_empty_chans(); + } +} + // looks up a users password for their connection class (/ tags) @@ -2240,7 +2290,7 @@ void ConnectUser(userrec *user) { char reason[MAXBUF]; snprintf(reason,MAXBUF,"G-Lined: %s",r); - kill_link(user,reason); + kill_link_silent(user,reason); return; } @@ -2249,7 +2299,7 @@ void ConnectUser(userrec *user) { char reason[MAXBUF]; snprintf(reason,MAXBUF,"K-Lined: %s",r); - kill_link(user,reason); + kill_link_silent(user,reason); return; } -- cgit v1.2.3