Fixed SERVER_SIGNOFF notify handling on backup router.
[silc.git] / apps / silcd / packet_receive.c
index 29744f2c08d240330b6a1bfd86309e9bf697ca10..1fa6f7525c74dd82fb82c65aef3e09621d71188e 100644 (file)
@@ -1306,9 +1306,20 @@ void silc_server_notify(SilcServer server,
     }
     silc_free(server_id);
 
-    /* Sending SERVER_SIGNOFF is not right way to signoff local connection */
-    if (SILC_IS_LOCAL(server_entry))
+    /* For local entrys SERVER_SIGNOFF is processed only on backup router.
+       It is possible that router sends server signoff for a server.  If
+       backup router has it as local connection it will be closed. */
+    if (SILC_IS_LOCAL(server_entry) &&
+       server->server_type == SILC_BACKUP_ROUTER) {
+      sock = server_entry->connection;
+      SILC_LOG_DEBUG(("Closing connection %s after SERVER_SIGNOFF",
+                     sock->hostname));
+      SILC_SET_DISCONNECTING(sock);
+      if (sock->user_data)
+       silc_server_free_sock_user_data(server, sock, NULL);
+      silc_server_close_connection(server, sock);
       break;
+    }
 
     /* Remove all servers that are originated from this server, and
        remove the clients of those servers too. */