summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-04-20 20:25:21 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-04-20 20:25:21 +0200
commit1313a712df1aeb41b5eccdc8c530d92a0c28d394 (patch)
tree2287c12ec30129ee03f582eb8366beeefed96d33
parentf45f9ab8731f3676e1998a2cc2edf8ebea71aa11 (diff)
downloadxK-1313a712df1aeb41b5eccdc8c530d92a0c28d394.tar.gz
xK-1313a712df1aeb41b5eccdc8c530d92a0c28d394.tar.xz
xK-1313a712df1aeb41b5eccdc8c530d92a0c28d394.zip
degesch: make a second /disconnect always succeed
-rw-r--r--degesch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index e7c776e..7c71095 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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)))
{