Send RESUMED to backup router last.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 9 Oct 2003 09:45:10 +0000 (09:45 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 9 Oct 2003 09:45:10 +0000 (09:45 +0000)
apps/silcd/server_backup.c

index 48cff69b13e147c9efa6fd4870cb3c718dff62e7..72becccc7e04d63e982ad90de711ff389372a622 100644 (file)
@@ -944,7 +944,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
   SilcServerBackupProtocolContext ctx = protocol->context;
   SilcServer server = ctx->server;
   SilcServerEntry server_entry;
-  SilcSocketConnection sock;
+  SilcSocketConnection sock = NULL;
   unsigned char data[2];
   int i;
 
@@ -1133,7 +1133,9 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
                                           server->router, TRUE);
 
       /* We as primary router now must send RESUMED packets to all servers
-        and routers so that they know we are back. */
+        and routers so that they know we are back.   For backup router we
+        send the packet last so that we give the backup as much time as
+        possible to deal with message routing at this critical moment. */
       for (i = 0; i < server->config->param.connections_max; i++) {
        sock = server->sockets[i];
        if (!sock || !sock->user_data ||
@@ -1142,6 +1144,11 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
             sock->type != SILC_SOCKET_TYPE_SERVER))
          continue;
 
+       /* Send to backup last */
+       if (sock == ctx->sock)
+         continue;
+
+      send_to_backup:
        server_entry = sock->user_data;
        server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
@@ -1158,6 +1165,13 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        silc_server_packet_queue_purge(server,sock);
       }
 
+      /* Now send the same packet to backup */
+      if (sock != ctx->sock) {
+       sleep(1);
+       sock = ctx->sock;
+       goto send_to_backup;
+      }
+
       /* We are now resumed and are back as primary router in the cell. */
       SILC_LOG_INFO(("We are now the primary router of our cell again"));
       server->wait_backup = FALSE;