updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 3 May 2002 16:36:49 +0000 (16:36 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 3 May 2002 16:36:49 +0000 (16:36 +0000)
CHANGES
apps/silcd/command.c
lib/silcclient/client_resume.c
lib/silcclient/command_reply.c
lib/silcclient/command_reply.h

diff --git a/CHANGES b/CHANGES
index 1ff1a6c33bde2d9b500c088550bd3527f8d8f5a2..8388cc15d6c41062cbebaa34623870409bb502cb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Fri May  3 18:36:51 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Fixed rekey protocol with PFS in the client library.
index 0d222bd360af1463a468fb2f1ef2cafe70341521..cedebbd4bf80cdd66012e7f2e4b3d299658dc1d8 100644 (file)
@@ -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 ?
index e7d88301fd117df33e7dfc7dfd20d45ab1a536a6..72abe19db25a54a192d223e652f45c1321775ed7 100644 (file)
@@ -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]);
index 73d553cb9685e5cd5569637e667b0f1d1476ea6d..ac40809fdbcd3619b30c1cd9b978466383122d3b 100644 (file)
@@ -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. */
index cace424a8ce030b5696868dd93a282f4a02aeba2..c2e4e641f01e8036faeea094d6bab11e778b4eea 100644 (file)
@@ -46,6 +46,7 @@ struct SilcClientCommandReplyContextStruct {
   SilcClientCommandPendingCallbacks callbacks;
   SilcUInt32 callbacks_count;
   SilcUInt16 ident;
+  SilcUInt8 users;
 };
 
 /* Macros */