query.
+Thu Apr 7 14:50:01 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
+
+ * During query, check if the original command caller goes
+ away. If it does, stop the query. Affected file
+ silcd/server_query.c.
+
Wed Apr 6 16:56:53 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
* Added some better error messages. Affected file
if (server->server_type == SILC_ROUTER) {
/* Add the client's public key to hash table or get the key with
GETKEY command. */
- if (entry->data.public_key)
- silc_hash_table_add(server->pk_hash, entry->data.public_key, entry);
- else
+ if (entry->data.public_key) {
+ if (!silc_hash_table_find_by_context(server->pk_hash,
+ entry->data.public_key,
+ entry, NULL))
+ silc_hash_table_add(server->pk_hash, entry->data.public_key,
+ entry);
+ } else
silc_server_send_command(server, router_sock,
SILC_COMMAND_GETKEY, ++server->cmd_ident,
1, 1, buffer->data, buffer->len);
}
/* Add public key to hash list (for whois using attributes) */
- silc_hash_table_add(server->pk_hash,
- entry->data.public_key, client);
+ if (!silc_hash_table_find_by_context(server->pk_hash,
+ entry->data.public_key,
+ client, NULL))
+ silc_hash_table_add(server->pk_hash,
+ entry->data.public_key, client);
id_entry = (void *)client;
break;
SILC_LOG_DEBUG(("Received reply from router to query"));
+ /* If the original command caller has gone away, just stop. */
+ if (query->cmd->sock->users == 1) {
+ SILC_LOG_DEBUG(("Original command caller vanished"));
+ silc_server_query_free(query);
+ return;
+ }
+
/* Check if router sent error reply */
if (cmdr && !silc_command_get_status(cmdr->payload, NULL, NULL)) {
SilcBuffer buffer;
/* If no clients were found, we only check the attributes
if the user wasn't searching for nickname/ids */
- if (!*clients) {
+ if (!(*clients)) {
no_clients = TRUE;
if (query->nickname || query->ids_count)
return;
SILC_LOG_DEBUG(("Reprocess the query"));
+ /* If the original command caller has gone away, just stop. */
+ if (query->cmd->sock->users == 1) {
+ SILC_LOG_DEBUG(("Original command caller vanished"));
+ silc_server_query_free(query);
+ return;
+ }
+
/* We have received all queries. Now re-search all information required
to complete this query. Reason we cannot save the values found in
the first search is that SilcClientEntry, SilcServerEntry and
SilcUInt32 len;
SilcBuffer idp;
int i, k, valid_count;
- char nh[256], uh[256];
+ char nh[384], uh[384];
bool sent_reply = FALSE;
SILC_LOG_DEBUG(("Sending reply to query"));
" : "), entry->nickname));
idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT);
- memset(uh, 0, sizeof(uh));
memset(nh, 0, sizeof(nh));
silc_strncat(nh, sizeof(nh), entry->nickname, strlen(entry->nickname));
memset(fempty, 0, sizeof(fempty));
memset(idle, 0, sizeof(idle));
+ memset(uh, 0, sizeof(uh));
+
silc_strncat(uh, sizeof(uh), entry->username,
strlen(entry->username));
if (!strchr(entry->username, '@') && entry->connection) {
/* Remove the client entry */
if (!server_signoff) {
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
+ client->mode = 0;
+ client->router = NULL;
+ client->connection = NULL;
id_cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
} else {
silc_idlist_del_data(client);
/* Remove the client entry */
if (!server_signoff) {
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
+ client->mode = 0;
+ client->router = NULL;
+ client->connection = NULL;
id_cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
} else {
silc_idlist_del_data(client);
if (SILC_IS_LOCAL(remote_client)) {
server->stat.my_clients--;
silc_schedule_task_del_by_context(server->schedule, remote_client);
- silc_idlist_del_data(remote_client);
}
/* Remove remote client */