diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-02 20:09:44 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-02 20:09:44 +0000 |
commit | 6fffe28853f4b64db3c266d45f140a5284d3dc2a (patch) | |
tree | 32dae262072573f0b9dc1ff8bf2d2efb1bc80d75 /src/inspircd.cpp | |
parent | 53a6b186b667f0a6f04004fcb3fc348e3a031889 (diff) |
Yet MORE fixes to crashes on quit
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@359 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 3f4de91d1..062a07995 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -3235,40 +3235,44 @@ void handle_quit(char **parameters, int pcnt, userrec *user) { user_hash::iterator iter = clientlist.find(user->nick); - /* theres more to do here, but for now just close the socket */ - if (pcnt == 1) + if (user->registered == 7) { - if (parameters[0][0] == ':') + /* theres more to do here, but for now just close the socket */ + if (pcnt == 1) + { + if (parameters[0][0] == ':') + { + *parameters[0]++; + } + Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,parameters[0]); + WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,parameters[0]); + WriteCommonExcept(user,"QUIT :%s%s",PrefixQuit,parameters[0]); + } + else { - *parameters[0]++; + Write(user->fd,"ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host); + WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host); + WriteCommonExcept(user,"QUIT :Client exited"); } - Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,parameters[0]); - WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,parameters[0]); - WriteCommonExcept(user,"QUIT :%s%s",PrefixQuit,parameters[0]); - } - else - { - Write(user->fd,"ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host); - WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host); - WriteCommonExcept(user,"QUIT :Client exited"); + FOREACH_MOD OnUserQuit(user); + AddWhoWas(user); } - FOREACH_MOD OnUserQuit(user); - - /* confucious say, he who close nonblocking socket, get nothing! */ - Blocking(user->fd); - close(user->fd); - NonBlocking(user->fd); - AddWhoWas(user); - + /* push the socket on a stack of sockets due to be closed at the next opportunity */ + fd_reap.push_back(user->fd); + if (iter != clientlist.end()) { - log(DEBUG,"deleting user hash value"); - delete iter->second; + log(DEBUG,"deleting user hash value %d",iter->second); + if ((iter->second) && (user->registered == 7)) { + delete iter->second; + } clientlist.erase(iter); } - - purge_empty_chans(); + + if (user->registered == 7) { + purge_empty_chans(); + } } void handle_who(char **parameters, int pcnt, userrec *user) |