silcd: Fixed IDENTIFY command reply handling for channels
authorPekka Riikonen <priikone@silcnet.org>
Mon, 8 Jun 2009 05:58:35 +0000 (08:58 +0300)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 8 Jun 2009 05:58:35 +0000 (08:58 +0300)
The IDENTIFY comamnd reply for channels were broken because the channel ID
parsing always failed.  This would cause issues like USERS command not
returning the users for a channel, making the channel appear empty, in some
specific cases.

Fixed also the USERS command reply to not query the channel information
from router more than once.

apps/silcd/command_reply.c
apps/silcd/command_reply.h

index 47c7a3f5315aad7e49dfb9c552d44e14077072b2..bb32bb2b11b730048440f4d4e6e3b07b72316962 100644 (file)
@@ -603,7 +603,7 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
   char *name, *info;
   SilcClientID client_id;
   SilcServerID server_id;
-  SilcChannelID*channel_id;
+  SilcChannelID channel_id;
   SilcClientEntry client;
   SilcServerEntry server_entry;
   SilcChannelEntry channel;
@@ -652,7 +652,7 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
         to global list since server didn't have it in the lists so it must be
         global. */
       client = silc_idlist_add_client(server->global_list,
-                                     nick[0] ? strdup(nick) : NULL, 
+                                     nick[0] ? strdup(nick) : NULL,
                                      info ? strdup(info) : NULL, NULL,
                                      silc_id_dup(&client_id, SILC_ID_CLIENT),
                                      silc_packet_get_context(cmd->sock),
@@ -1287,7 +1287,7 @@ SILC_SERVER_CMD_REPLY_FUNC(users)
     if (!channel) {
       SilcBuffer idp;
 
-      if (server->server_type != SILC_SERVER)
+      if (cmd->pending || server->server_type != SILC_SERVER)
        goto out;
 
       idp = silc_id_payload_encode(SILC_ID_GET_ID(id), SILC_ID_CHANNEL);
@@ -1302,6 +1302,8 @@ SILC_SERVER_CMD_REPLY_FUNC(users)
       silc_server_command_pending(server, SILC_COMMAND_IDENTIFY,
                                  server->cmd_ident,
                                  silc_server_command_reply_users, cmd);
+
+      cmd->pending = TRUE;
       return;
     }
   }
index 2b3671871c173146f07853c7abcebf191800b175..bee08124d893cdb14cbbed7491e057094a11654e 100644 (file)
@@ -49,6 +49,7 @@ typedef struct {
   SilcServerCommandPendingCallbacks callbacks;
   SilcUInt32 callbacks_count;
   SilcUInt16 ident;
+  unsigned int pending : 1;
 } *SilcServerCommandReplyContext;
 
 /* Macros */