{
SilcPacketContext *p = (SilcPacketContext *)context;
silc_client_notify_by_server(p->context, p->sock, p);
+ silc_socket_free(p->sock);
}
/* Destructor for the pending command callback */
SilcBuffer idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
p->context = (void *)client;
- p->sock = conn->sock;
+ p->sock = silc_socket_dup(conn->sock);
silc_client_send_command(client, conn, SILC_COMMAND_WHOIS, ++conn->cmd_ident,
1, 3, idp->data, idp->len);
/* Get the channel entry */
channel = NULL;
if (silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
channel = (SilcChannelEntry)id_cache->context;
/* Get sender Client ID */
/* Get channel entry */
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
if (!channel_id)
goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
silc_client_remove_from_channels(client, conn, client_entry);
/* Remove from cache */
- silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT,
- client_entry->id);
+ silc_idcache_del_by_context(conn->client_cache, client_entry);
/* Get signoff message */
tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
if (!channel_id)
goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
goto out;
/* Ignore my ID */
- if (!SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
+ if (SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
break;
/* Find old Client entry */
}
/* Remove the old from cache */
- silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT,
- client_entry->id);
+ silc_idcache_del_by_context(conn->client_cache, client_entry);
/* Replace old ID entry with new one on all channels. */
silc_client_replace_from_channels(client, conn, client_entry,
if (!channel_id)
goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
goto out;
/* Find Client entry */
- client_entry =
- silc_client_get_client_by_id(client, conn, client_id);
- if (!client_entry)
+ client_entry = silc_client_get_client_by_id(client, conn, client_id);
+ if (!client_entry) {
+ silc_client_notify_by_server_resolve(client, conn, packet, client_id);
goto out;
+ }
/* Get the mode */
tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
if (!channel_id)
goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
/* Get the channel entry */
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
+ SILC_LOG_DEBUG(("Old Channel ID id(%s)",
+ silc_id_render(channel->id, SILC_ID_CHANNEL)));
+
/* Free the old ID */
silc_free(channel->id);
if (!channel->id)
goto out;
- id_cache->id = (void *)channel->id;
+ SILC_LOG_DEBUG(("New Channel ID id(%s)",
+ silc_id_render(channel->id, SILC_ID_CHANNEL)));
+
+ /* Remove the old cache entry and create a new one */
+ silc_idcache_del_by_context(conn->channel_cache, channel);
+ silc_idcache_add(conn->channel_cache, channel->channel_name,
+ channel->id, channel, FALSE);
/* Notify application */
client->ops->notify(client, conn, type, channel, channel);
if (!channel_id)
goto out;
if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
- SILC_ID_CHANNEL, &id_cache))
+ &id_cache))
break;
channel = (SilcChannelEntry)id_cache->context;
if (client_entry == conn->local_entry) {
if (conn->current_channel == channel)
conn->current_channel = NULL;
- silc_idcache_del_by_id(conn->channel_cache,
- SILC_ID_CHANNEL, channel->id);
+ silc_idcache_del_by_id(conn->channel_cache, channel->id);
silc_free(channel->channel_name);
silc_free(channel->id);
silc_free(channel->key);
if (client_entry != conn->local_entry) {
/* Remove client from all channels */
silc_client_remove_from_channels(client, conn, client_entry);
- silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT,
- client_entry->id);
+ silc_idcache_del_by_context(conn->client_cache, client_entry);
if (client_entry->nickname)
silc_free(client_entry->nickname);
if (client_entry->server)
continue;
silc_client_remove_from_channels(client, conn, client_entry);
- silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT,
- client_entry->id);
+ silc_idcache_del_by_context(conn->client_cache, client_entry);
if (client_entry->nickname)
silc_free(client_entry->nickname);
if (client_entry->server)