From: Pekka Riikonen Date: Fri, 3 May 2002 16:36:49 +0000 (+0000) Subject: updates. X-Git-Tag: silc.toolkit.0.9~12 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=c62f4fe7f1d0c717d3bb37fc01fb691b089838c1 updates. --- diff --git a/CHANGES b/CHANGES index 1ff1a6c3..8388cc15 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Fri May 3 18:36:51 EEST 2002 Pekka Riikonen + + * Added reference counter to the command reply context in + the client library. Affected files are + lib/silcclient/command_reply.[ch]. + Fri May 3 11:37:10 EEST 2002 Pekka Riikonen * Fixed rekey protocol with PFS in the client library. diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 0d222bd3..cedebbd4 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -4902,6 +4902,8 @@ SILC_SERVER_CMD_FUNC(detach) /* Send the user mode notify to notify that client is detached */ client->mode |= SILC_UMODE_DETACHED; client->data.status &= ~SILC_IDLIST_STATUS_RESUMED; + client->last_command = 0; + client->fast_command = 0; if (!server->standalone) silc_server_send_notify_umode(server, server->router->connection, server->server_type == SILC_SERVER ? diff --git a/lib/silcclient/client_resume.c b/lib/silcclient/client_resume.c index e7d88301..72abe19d 100644 --- a/lib/silcclient/client_resume.c +++ b/lib/silcclient/client_resume.c @@ -29,6 +29,7 @@ SILC_CLIENT_CMD_FUNC(resume_users); #define RESUME_CALL_COMPLETION(client, session, s) \ do { \ + SILC_LOG_DEBUG(("Calling completion")); \ session->success = s; \ silc_schedule_task_add(client->schedule, 0, \ silc_client_resume_call_completion, session, \ @@ -208,6 +209,8 @@ SILC_TASK_CALLBACK(silc_client_resume_call_completion) SilcClientResumeSession session = context; int i; + SILC_LOG_DEBUG(("Session completed")); + for (i = 0; i < session->cmd_idents_count; i++) silc_client_command_pending_del(session->conn, SILC_COMMAND_IDENTIFY, session->cmd_idents[i]); diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 73d553cb..ac40809f 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -96,6 +96,7 @@ void silc_client_command_reply_process(SilcClient client, /* Allocate command reply context. This must be free'd by the command reply routine receiving it. */ ctx = silc_calloc(1, sizeof(*ctx)); + ctx->users++; ctx->client = client; ctx->sock = sock; ctx->payload = payload; @@ -134,11 +135,26 @@ void silc_client_command_reply_process(SilcClient client, } } +/* Duplicate Command Reply Context by adding reference counter. The context + won't be free'd untill it hits zero. */ + +SilcClientCommandReplyContext +silc_client_command_reply_dup(SilcClientCommandReplyContext cmd) +{ + cmd->users++; + SILC_LOG_DEBUG(("Command reply context %p refcnt %d->%d", cmd, + cmd->users - 1, cmd->users)); + return cmd; +} + /* Free command reply context and its internals. */ void silc_client_command_reply_free(SilcClientCommandReplyContext cmd) { - if (cmd) { + cmd->users--; + SILC_LOG_DEBUG(("Command reply context %p refcnt %d->%d", cmd, + cmd->users + 1, cmd->users)); + if (cmd->users < 1) { silc_command_payload_free(cmd->payload); silc_free(cmd); } @@ -225,8 +241,7 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd, client_entry->fingerprint_len = fingerprint_len; } - if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) - client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING; + client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING; /* Notify application */ if (!cmd->callbacks_count && notify) @@ -394,8 +409,7 @@ silc_client_command_reply_identify_save(SilcClientCommandReplyContext cmd, name, info, NULL, 0); } - if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) - client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING; + client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING; /* Notify application */ if (notify) @@ -1594,22 +1608,6 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd, /* Check if we have this client cached already. */ client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id); if (!client_entry || !client_entry->username || !client_entry->realname) { - if (client_entry) { - if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) { - /* Attach to this resolving and wait until it finishes */ - silc_client_command_pending(conn, SILC_COMMAND_NONE, - client_entry->resolve_cmd_ident, - get_clients, cmd); - wait_res = TRUE; - - silc_buffer_pull(&client_id_list, idp_len); - silc_buffer_pull(&client_mode_list, 4); - continue; - } - client_entry->status |= SILC_CLIENT_STATUS_RESOLVING; - client_entry->resolve_cmd_ident = conn->cmd_ident + 1; - } - /* No we don't have it (or it is incomplete in information), query it from the server. Assemble argument table that will be sent for the WHOIS command later. */ diff --git a/lib/silcclient/command_reply.h b/lib/silcclient/command_reply.h index cace424a..c2e4e641 100644 --- a/lib/silcclient/command_reply.h +++ b/lib/silcclient/command_reply.h @@ -46,6 +46,7 @@ struct SilcClientCommandReplyContextStruct { SilcClientCommandPendingCallbacks callbacks; SilcUInt32 callbacks_count; SilcUInt16 ident; + SilcUInt8 users; }; /* Macros */