diff options
| author | Alexander Barton <alex@barton.de> | 2011-08-02 00:56:49 +0200 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2011-08-02 00:56:49 +0200 |
| commit | 88f6fc5fd8617a2d517c1e7ed689a29dce2a217f (patch) | |
| tree | d1cbea73a930c312b85f662731af6f12a05c2ba4 | |
| parent | da897a2a14ac229dbd542f2f11c970dcb005944d (diff) | |
| download | ngircd-88f6fc5fd8617a2d517c1e7ed689a29dce2a217f.tar.gz ngircd-88f6fc5fd8617a2d517c1e7ed689a29dce2a217f.zip | |
IRC_QUIT(): disconnect directly linked servers sending QUIT
Without this patch, the server becomes removed from the network and the client structures, but the connection isn't shut down at all ...
| -rw-r--r-- | src/ngircd/irc-login.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 067703a8..73716fe2 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -653,32 +653,37 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req ) CLIENT *target; char quitmsg[LINE_LEN]; - assert( Client != NULL ); - assert( Req != NULL ); + assert(Client != NULL); + assert(Req != NULL); /* Wrong number of arguments? */ - if( Req->argc > 1 ) - return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + if (Req->argc > 1) + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, + Client_ID(Client), Req->command); if (Req->argc == 1) strlcpy(quitmsg, Req->argv[0], sizeof quitmsg); - if ( Client_Type( Client ) == CLIENT_SERVER ) - { + if (Client_Type(Client) == CLIENT_SERVER) { /* Server */ - target = Client_Search( Req->prefix ); - if( ! target ) - { - Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client )); + target = Client_Search(Req->prefix); + if (!target) { + Log(LOG_WARNING, + "Got QUIT from %s for unknown client!?", + Client_ID(Client)); return CONNECTED; } - Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true); - - return CONNECTED; - } - else - { + if (target != Client) { + Client_Destroy(target, "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); + return CONNECTED; + } else { + Conn_Close(Client_Conn(Client), "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); + return DISCONNECTED; + } + } else { if (Req->argc == 1 && quitmsg[0] != '\"') { /* " " to avoid confusion */ strlcpy(quitmsg, "\"", sizeof quitmsg); @@ -687,7 +692,8 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req ) } /* User, Service, or not yet registered */ - Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true); + Conn_Close(Client_Conn(Client), "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); return DISCONNECTED; } |