From 3d084457085232f0f8d41e187ee73065252d256e Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 24 Aug 2003 10:07:28 +0000 Subject: [PATCH] Remove channel entry in LEAVE command reply, not when sending LEAVE. --- lib/silcclient/command.c | 11 ----------- lib/silcclient/command_reply.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index 4796c3bc..557a539c 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -2327,7 +2327,6 @@ SILC_CLIENT_CMD_FUNC(leave) SilcClientCommandContext cmd = (SilcClientCommandContext)context; SilcClientConnection conn = cmd->conn; SilcChannelEntry channel; - SilcChannelUser chu; SilcBuffer buffer, idp; char *name; @@ -2361,14 +2360,6 @@ SILC_CLIENT_CMD_FUNC(leave) goto out; } - /* Remove us from channel */ - chu = silc_client_on_channel(channel, conn->local_entry); - if (chu) { - silc_hash_table_del(chu->client->channels, chu->channel); - silc_hash_table_del(chu->channel->user_list, chu->client); - silc_free(chu); - } - /* Send LEAVE command to the server */ idp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL); buffer = silc_command_payload_encode_va(SILC_COMMAND_LEAVE, 0, 1, @@ -2384,8 +2375,6 @@ SILC_CLIENT_CMD_FUNC(leave) if (conn->current_channel == channel) conn->current_channel = NULL; - silc_client_del_channel(cmd->client, cmd->conn, channel); - out: silc_client_command_free(cmd); } diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index e99abb2e..8807c056 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -1538,6 +1538,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(leave) SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data; SilcChannelID *channel_id; SilcChannelEntry channel = NULL; + SilcChannelUser chu; unsigned char *tmp; SilcUInt32 len; @@ -1563,12 +1564,24 @@ SILC_CLIENT_CMD_REPLY_FUNC(leave) goto out; } + /* Remove us from this channel. */ + chu = silc_client_on_channel(channel, conn->local_entry); + if (chu) { + silc_hash_table_del(chu->client->channels, chu->channel); + silc_hash_table_del(chu->channel->user_list, chu->client); + silc_free(chu); + } + silc_free(channel_id); } /* Notify application */ COMMAND_REPLY((SILC_ARGS, channel)); + /* Now delete the channel. */ + if (channel) + silc_client_del_channel(cmd->client, conn, channel); + out: SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LEAVE); silc_client_command_reply_free(cmd); -- 2.24.0