aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/degesch.c b/degesch.c
index a6826d6..f87b4f9 100644
--- a/degesch.c
+++ b/degesch.c
@@ -3517,10 +3517,9 @@ initiate_quit (struct app_context *ctx)
// Destroy the user interface
input_stop (&ctx->input);
+ // Initiate a connection close
struct str_map_iter iter;
str_map_iter_init (&iter, &ctx->servers);
-
- // Initiate a connection close
struct server *s;
while ((s = str_map_iter_next (&iter)))
{
@@ -3541,11 +3540,8 @@ initiate_quit (struct app_context *ctx)
}
static void
-irc_disconnect (struct server *s)
+irc_destroy_transport (struct server *s)
{
- hard_assert (irc_is_connected (s));
-
- // Get rid of the dead socket
if (s->transport
&& s->transport->cleanup)
s->transport->cleanup (s);
@@ -3560,11 +3556,11 @@ irc_disconnect (struct server *s)
str_reset (&s->read_buffer);
str_reset (&s->write_buffer);
+}
- // All of our timers have lost their meaning now
- irc_cancel_timers (s);
-
- // Reset state bound to the connection
+static void
+irc_destroy_state (struct server *s)
+{
struct str_map_iter iter;
str_map_iter_init (&iter, &s->irc_channels);
struct channel *channel;
@@ -3588,6 +3584,22 @@ irc_disconnect (struct server *s)
server_free_specifics (s);
server_init_specifics (s);
+}
+
+static void
+irc_disconnect (struct server *s)
+{
+ hard_assert (irc_is_connected (s));
+
+ struct str_map_iter iter;
+ str_map_iter_init (&iter, &s->irc_buffer_map);
+ struct buffer *buffer;
+ while ((buffer = str_map_iter_next (&iter)))
+ log_server_status (s, buffer, "Disconnected from server");
+
+ irc_cancel_timers (s);
+ irc_destroy_transport (s);
+ irc_destroy_state (s);
// Take any relevant actions
if (s->ctx->quitting)