From: Pekka Riikonen Date: Thu, 7 Apr 2005 12:43:58 +0000 (+0000) Subject: If during query the original command caller quits we top the X-Git-Tag: silc.toolkit.0.9.14~38 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=11702e12cc2eb96fd2ab32e72ba1bc499849d0e7 If during query the original command caller quits we top the query. --- diff --git a/CHANGES b/CHANGES index 1c756242..9dcb5dfc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Thu Apr 7 14:50:01 EEST 2005 Pekka Riikonen + + * 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 * Added some better error messages. Affected file diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 97340d5f..88ed838d 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -2893,9 +2893,13 @@ static void silc_server_new_id_real(SilcServer server, 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); diff --git a/apps/silcd/server.c b/apps/silcd/server.c index cadbdab1..2c3875a5 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -2040,8 +2040,11 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final) } /* 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; diff --git a/apps/silcd/server_query.c b/apps/silcd/server_query.c index da4a30f9..a02fcd18 100644 --- a/apps/silcd/server_query.c +++ b/apps/silcd/server_query.c @@ -323,6 +323,13 @@ void silc_server_query_send_router_reply(void *context, void *reply) 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; @@ -671,7 +678,7 @@ void silc_server_query_check_attributes(SilcServer server, /* 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; @@ -1283,6 +1290,13 @@ void silc_server_query_resolve_reply(void *context, void *reply) 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 @@ -1316,7 +1330,7 @@ void silc_server_query_send_reply(SilcServer server, 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")); @@ -1404,7 +1418,6 @@ void silc_server_query_send_reply(SilcServer server, " : "), 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)); @@ -1432,6 +1445,8 @@ void silc_server_query_send_reply(SilcServer server, 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) { diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 54a95feb..46cf87aa 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -223,6 +223,9 @@ bool silc_server_remove_clients_by_server(SilcServer server, /* 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); @@ -287,6 +290,9 @@ bool silc_server_remove_clients_by_server(SilcServer server, /* 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); @@ -1656,7 +1662,6 @@ void silc_server_kill_client(SilcServer server, 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 */