summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index 0f4cd6e..58b68a4 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2462,6 +2462,14 @@ irc_remove_user_from_channel (struct user *user, struct channel *channel)
irc_channel_unlink_user (channel, iter);
}
+static void
+irc_left_channel (struct channel *channel)
+{
+ // TODO: shouldn't we decrease reference count on the channel?
+ LIST_FOR_EACH (struct channel_user, iter, channel->users)
+ irc_channel_unlink_user (channel, iter);
+}
+
// --- Core functionality ------------------------------------------------------
// Most of the core IRC code comes from ZyklonB which is mostly blocking.
@@ -2755,6 +2763,12 @@ on_irc_disconnected (struct server *s)
s->socket = -1;
s->state = IRC_DISCONNECTED;
+ struct str_map_iter iter;
+ str_map_iter_init (&iter, &s->irc_channels);
+ struct channel *channel;
+ while ((channel = str_map_iter_next (&iter)))
+ irc_left_channel (channel);
+
user_unref (s->irc_user);
s->irc_user = NULL;
@@ -3388,7 +3402,12 @@ irc_handle_kick (struct server *s, const struct irc_message *msg)
// It would be is weird for this to be false
if (user && channel)
- irc_remove_user_from_channel (user, channel);
+ {
+ if (irc_is_this_us (s, target))
+ irc_left_channel (channel);
+ else
+ irc_remove_user_from_channel (user, channel);
+ }
if (buffer)
{
@@ -3563,7 +3582,12 @@ irc_handle_part (struct server *s, const struct irc_message *msg)
// It would be is weird for this to be false
if (user && channel)
- irc_remove_user_from_channel (user, channel);
+ {
+ if (irc_is_this_us (s, msg->prefix))
+ irc_left_channel (channel);
+ else
+ irc_remove_user_from_channel (user, channel);
+ }
if (buffer)
{