degesch: make a second /disconnect always succeed

This commit is contained in:
Přemysl Eric Janouch 2017-04-20 20:25:21 +02:00
parent f45f9ab873
commit 1313a712df
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 11 additions and 2 deletions

View File

@ -4948,11 +4948,19 @@ irc_initiate_disconnect (struct server *s, const char *reason)
{
hard_assert (irc_is_connected (s));
s->manual_disconnect = true;
if (reason)
// It can take a very long time for sending QUIT to take effect
if (s->manual_disconnect)
{
log_server_error (s, s->buffer, "%s: %s", "Disconnected from server",
"connection torn down early per user request");
irc_disconnect (s);
}
else if (reason)
irc_send (s, "QUIT :%s", reason);
else
irc_send (s, "QUIT :%s", PROGRAM_NAME " " PROGRAM_VERSION);
s->manual_disconnect = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -11125,6 +11133,7 @@ handle_command_quit (struct handler_args *a)
struct str_map_iter iter;
str_map_iter_init (&iter, &a->ctx->servers);
// FIXME: we should pass the message as an argument to initiate_quit()
struct server *s;
while ((s = str_map_iter_next (&iter)))
{