if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
continue;
}
SilcChannelClientEntry chl2;
SilcHashTableList htl2;
- channel->id = NULL;
+ channel->disabled = TRUE;
silc_hash_table_list(channel->user_list, &htl2);
while (silc_hash_table_get(&htl2, NULL, (void *)&chl2)) {
/* Remove the channel entry */
if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
continue;
}
}
if (client->router != entry) {
- if (server_signoff && client->connection) {
+ if (server_signoff) {
clients = silc_realloc(clients,
sizeof(*clients) * (clients_c + 1));
clients[clients_c] = client;
/* Send the SERVER_SIGNOFF notify */
if (server_signoff) {
- SilcBuffer args;
+ SilcBuffer args, not;
/* Send SERVER_SIGNOFF notify to our primary router */
if (!server->standalone && server->router &&
silc_buffer_free(args);
}
+ /* Send to local clients */
args = silc_argument_payload_encode(argc, argv, argv_lens,
argv_types);
- /* Send to local clients */
- for (i = 0; i < clients_c; i++) {
- silc_server_send_notify_args(server, clients[i]->connection,
- FALSE, SILC_NOTIFY_TYPE_SERVER_SIGNOFF,
- argc, args);
- }
+ not = silc_notify_payload_encode_args(SILC_NOTIFY_TYPE_SERVER_SIGNOFF,
+ argc, args);
+ silc_server_packet_send_clients(server, clients, clients_c,
+ SILC_PACKET_NOTIFY, 0, FALSE,
+ not->data, not->len, FALSE);
silc_free(clients);
silc_buffer_free(args);
+ silc_buffer_free(not);
for (i = 0; i < argc; i++)
silc_free(argv[i]);
silc_free(argv);
SILC_LOG_DEBUG(("Found (local) %s",
silc_id_render(server_entry->id, SILC_ID_SERVER)));
- /* If the client is not marked as local then move it to local list
- since the server is local. */
- if (server_entry->server_type != SILC_BACKUP_ROUTER && !local) {
- SILC_LOG_DEBUG(("Moving client to local list"));
- silc_idcache_add(server->local_list->clients, client_cache->name,
- client_cache->id, client_cache->context,
- client_cache->expire);
- silc_idcache_del_by_context(server->global_list->clients, client);
+ if (!server_entry->data.send_key && server_entry->router) {
+ SILC_LOG_DEBUG(("Server not locally connected, use its router"));
+ /* If the client is not marked as local then move it to local list
+ since the server is local. */
+ if (!local) {
+ SILC_LOG_DEBUG(("Moving client to local list"));
+ silc_idcache_add(server->local_list->clients, client_cache->name,
+ client_cache->id, client_cache->context,
+ client_cache->expire);
+ silc_idcache_del_by_context(server->global_list->clients, client);
+ }
+ server_entry = server_entry->router;
+ } else {
+ /* If the client is not marked as local then move it to local list
+ since the server is local. */
+ if (server_entry->server_type != SILC_BACKUP_ROUTER && !local) {
+ SILC_LOG_DEBUG(("Moving client to local list"));
+ silc_idcache_add(server->local_list->clients, client_cache->name,
+ client_cache->id, client_cache->context,
+ client_cache->expire);
+ silc_idcache_del_by_context(server->global_list->clients, client);
+ }
}
silc_idcache_list_free(list);
SILC_LOG_DEBUG(("Found (global) %s",
silc_id_render(server_entry->id, SILC_ID_SERVER)));
- /* If the client is marked as local then move it to global list
- since the server is global. */
- if (server_entry->server_type != SILC_BACKUP_ROUTER && local) {
- SILC_LOG_DEBUG(("Moving client to global list"));
- silc_idcache_add(server->global_list->clients, client_cache->name,
- client_cache->id, client_cache->context,
- client_cache->expire);
- silc_idcache_del_by_context(server->local_list->clients, client);
+ if (!server_entry->data.send_key && server_entry->router) {
+ SILC_LOG_DEBUG(("Server not locally connected, use its router"));
+ /* If the client is marked as local then move it to global list
+ since the server is global. */
+ if (local) {
+ SILC_LOG_DEBUG(("Moving client to global list"));
+ silc_idcache_add(server->global_list->clients, client_cache->name,
+ client_cache->id, client_cache->context,
+ client_cache->expire);
+ silc_idcache_del_by_context(server->local_list->clients, client);
+ }
+ server_entry = server_entry->router;
+ } else {
+ /* If the client is marked as local then move it to global list
+ since the server is global. */
+ if (server_entry->server_type != SILC_BACKUP_ROUTER && local) {
+ SILC_LOG_DEBUG(("Moving client to global list"));
+ silc_idcache_add(server->global_list->clients, client_cache->name,
+ client_cache->id, client_cache->context,
+ client_cache->expire);
+ silc_idcache_del_by_context(server->local_list->clients, client);
+ }
}
silc_idcache_list_free(list);