- if (silc_idcache_list_first(list, &id_cache)) {
- while (id_cache) {
- server_entry = (SilcServerEntry)id_cache->context;
- if (server_entry != from &&
- (tolocal || server_entry != server->id_entry) &&
- SILC_ID_COMPARE(server_entry->id, client->id,
- client->id->ip.data_len)) {
- SILC_LOG_DEBUG(("Found (local) %s",
- silc_id_render(server_entry->id, SILC_ID_SERVER)));
-
- 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, NULL);
- silc_idcache_del_by_context(server->global_list->clients, client);
- }
- server_entry = server_entry->router;
- } else {
- SILC_LOG_DEBUG(("Server locally connected"));
- /* 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, NULL);
- silc_idcache_del_by_context(server->global_list->clients, client);
-
- } else if (server->server_type == SILC_BACKUP_ROUTER && local) {
- /* If we are backup router and this client is on local list, we
- must move it to global list, as it is not currently local to
- us (we are not primary). */
- 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, NULL);
- silc_idcache_del_by_context(server->local_list->clients, client);
- }
+ silc_list_start(list);
+ while ((id_cache = silc_list_get(list))) {
+ server_entry = (SilcServerEntry)id_cache->context;
+ if (server_entry != from &&
+ (tolocal || server_entry != server->id_entry) &&
+ SILC_ID_COMPARE(server_entry->id, client->id,
+ client->id->ip.data_len)) {
+ SILC_LOG_DEBUG(("Found (local) %s",
+ silc_id_render(server_entry->id, SILC_ID_SERVER)));
+
+ if (!SILC_IS_LOCAL(server_entry) && 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_move(server->global_list->clients,
+ server->local_list->clients, client_cache);
+ }
+ server_entry = server_entry->router;
+ } else {
+ SILC_LOG_DEBUG(("Server locally connected"));
+ /* 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_move(server->global_list->clients,
+ server->local_list->clients, client_cache);
+
+ } else if (server->server_type == SILC_BACKUP_ROUTER && local) {
+ /* If we are backup router and this client is on local list, we
+ must move it to global list, as it is not currently local to
+ us (we are not primary). */
+ SILC_LOG_DEBUG(("Moving client to global list"));
+ silc_idcache_move(server->local_list->clients,
+ server->global_list->clients, client_cache);