Fixed WATCH handling in backup router. Router does not send it
authorPekka Riikonen <priikone@silcnet.org>
Sat, 2 Apr 2005 18:00:39 +0000 (18:00 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 2 Apr 2005 18:00:39 +0000 (18:00 +0000)
back to backup anymore, as backup handles the command itself.

CHANGES
apps/silcd/command.c

diff --git a/CHANGES b/CHANGES
index 32c3ebb021f7ebb4a5bd653946b4e96654de4975..c2d55609a23391a0c9ebec3dc61e88436031de18 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,10 @@ Sat Apr  2 18:09:30 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
          specified libs are used.  Pkg-config is not yet supported.
          Affected file configure.in.pre.
 
+       * Fixed WATCH command handling on backup router.  Router does not
+         send the watch command any more to backup if it originates from
+         backup.  Affected file silcd/command.c.
+
 Fri Apr  1 18:52:47 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
 
        * Changed announcing to not announce unregistered clients.
index 621ce1459b1f2054f8473741386763ace7a2f7d4..c2aecf8e02d2c28376757f69601ffc916eacba4a 100644 (file)
@@ -4097,6 +4097,7 @@ SILC_SERVER_CMD_FUNC(detach)
 SILC_SERVER_CMD_FUNC(watch)
 {
   SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+  SilcServerEntry server_entry;
   SilcServer server = cmd->server;
   char *add_nick, *del_nick;
   SilcUInt32 add_nick_len, del_nick_len, tmp_len, pk_len;
@@ -4122,12 +4123,20 @@ SILC_SERVER_CMD_FUNC(watch)
                              SILC_PACKET_COMMAND, cmd->packet->flags,
                              tmpbuf->data, tmpbuf->len, TRUE);
 
-      /* Reprocess this packet after received reply from router */
-      silc_server_command_pending(server, SILC_COMMAND_WATCH,
-                                 silc_command_get_ident(cmd->payload),
-                                 silc_server_command_watch,
-                                 silc_server_command_dup(cmd));
-      cmd->pending = TRUE;
+      /* If we are backup router, we're not expecting reply as router
+        won't be sending it. */
+      if (server->server_type != SILC_BACKUP_ROUTER) {
+       /* Reprocess this packet after received reply from router */
+       silc_server_command_pending(server, SILC_COMMAND_WATCH,
+                                   silc_command_get_ident(cmd->payload),
+                                   silc_server_command_watch,
+                                   silc_server_command_dup(cmd));
+       cmd->pending = TRUE;
+       silc_command_set_ident(cmd->payload, old_ident);
+       silc_buffer_free(tmpbuf);
+       goto out;
+      }
+
       silc_command_set_ident(cmd->payload, old_ident);
       silc_buffer_free(tmpbuf);
     } else if (context2) {
@@ -4139,9 +4148,8 @@ SILC_SERVER_CMD_FUNC(watch)
       silc_command_get_status(reply->payload, &status, NULL);
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_WATCH, status,
                                            0);
+      goto out;
     }
-
-    goto out;
   }
 
   /* We are router and keep the watch list for local cell */
@@ -4355,7 +4363,7 @@ SILC_SERVER_CMD_FUNC(watch)
     SilcBuffer tmpbuf;
     silc_command_set_ident(cmd->payload, ++server->cmd_ident);
     tmpbuf = silc_command_payload_encode_payload(cmd->payload);
-    silc_server_backup_send(server, NULL, SILC_PACKET_COMMAND,
+    silc_server_backup_send(server, cmd->sock->user_data, SILC_PACKET_COMMAND,
                            cmd->packet->flags, tmpbuf->data, tmpbuf->len,
                            FALSE, TRUE);
     silc_buffer_free(tmpbuf);