Remove channel entry in LEAVE command reply, not when sending LEAVE.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 24 Aug 2003 10:07:28 +0000 (10:07 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 24 Aug 2003 10:07:28 +0000 (10:07 +0000)
lib/silcclient/command.c
lib/silcclient/command_reply.c

index 4796c3bce389a51e59309cf72cd63c05b4a306c9..557a539c9c8186daa7d4e62a3c345c43372dd95f 100644 (file)
@@ -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);
 }
index e99abb2e219463b824dd18b89b3ec9f63dcb0347..8807c056b4bbd7e1af846e8cf694e40d831cdc0e 100644 (file)
@@ -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);