Fixed pending command deletion to delete correctly.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 29 Jun 2002 22:36:49 +0000 (22:36 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 29 Jun 2002 22:36:49 +0000 (22:36 +0000)
CHANGES
apps/silcd/command.c
apps/silcd/command.h
lib/silcclient/command.c
lib/silcclient/command.h

diff --git a/CHANGES b/CHANGES
index 14b495b0787f3606f928a2201d3203ac12ba60a3..3e5841656aa103c4e49300b0810bb425d9f9cfb9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Sun Jun 30 01:30:22 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * Fixed pending command deletion in server and client library
+         to check the whole list instead of breaking after first found.
+         The affected files are silcd/command.[ch] and 
+         lib/silcclient/command.[ch].
+
 Sat Jun 29 17:40:12 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * Return NO_SUCH_CHANNEL error in USERS for channel that is
index 1b5a3f27676cc78db9b2cb15bd97cef9e0356acc..0be43bee6cc0c0b44c83dc2e535c25f0d2780744 100644 (file)
@@ -366,7 +366,9 @@ void silc_server_command_pending_del(SilcServer server,
 
   silc_dlist_start(server->pending_commands);
   while ((r = silc_dlist_get(server->pending_commands)) != SILC_LIST_END) {
-    if (r->reply_cmd == reply_cmd && r->ident == ident) {
+    if ((r->reply_cmd == reply_cmd || (r->reply_cmd == SILC_COMMAND_NONE &&
+                                       r->reply_check))
+        && r->ident == ident) {
       silc_dlist_del(server->pending_commands, r);
       silc_free(r);
     }
@@ -394,6 +396,7 @@ silc_server_command_pending_check(SilcServer server,
       callbacks = silc_realloc(callbacks, sizeof(*callbacks) * (i + 1));
       callbacks[i].context = r->context;
       callbacks[i].callback = r->callback;
+      r->reply_check = TRUE;
       ctx->ident = ident;
       i++;
     }
index 464b261b7f8efacc8d881d945a2831b42b8b47f6..2e3273d6142c9bc029539f3ccd0f0e94689241c6 100644 (file)
@@ -63,9 +63,10 @@ typedef struct {
 typedef struct SilcServerCommandPendingStruct {
   SilcServer server;
   SilcCommand reply_cmd;
+  SilcUInt16 ident;
+  unsigned int reply_check : 8;
   SilcCommandCb callback;
   void *context;
-  SilcUInt16 ident;
   struct SilcServerCommandPendingStruct *next;
 } SilcServerCommandPending;
 
index 167d787830a6d1acf25fde54cbbf5f2561212e97..c03f71aff18fdcabb67fd7351bbcd1c65405c52c 100644 (file)
@@ -124,10 +124,11 @@ void silc_client_command_pending_del(SilcClientConnection conn,
 
   silc_dlist_start(conn->pending_commands);
   while ((r = silc_dlist_get(conn->pending_commands)) != SILC_LIST_END) {
-    if (r->reply_cmd == reply_cmd && r->ident == ident) {
+    if ((r->reply_cmd == reply_cmd || (r->reply_cmd == SILC_COMMAND_NONE &&
+                                      r->reply_check))
+       && r->ident == ident) {
       silc_dlist_del(conn->pending_commands, r);
       silc_free(r);
-      break;
     }
   }
 }
@@ -153,6 +154,7 @@ silc_client_command_pending_check(SilcClientConnection conn,
       callbacks = silc_realloc(callbacks, sizeof(*callbacks) * (i + 1));
       callbacks[i].context = r->context;
       callbacks[i].callback = r->callback;
+      r->reply_check = TRUE;
       ctx->ident = ident;
       i++;
     }
index a334352ed9c691c9959aff0f2cadc757d19aef29..b85d2e05a18399c4bb3fdf6ede4ed556c32e0f94 100644 (file)
@@ -60,9 +60,10 @@ struct SilcClientCommandContextStruct {
    executed after command reply has been executed. */
 typedef struct SilcClientCommandPendingStruct {
   SilcCommand reply_cmd;
+  SilcUInt16 ident;
+  unsigned int reply_check : 8;
   SilcCommandCb callback;
   void *context;
-  SilcUInt16 ident;
   struct SilcClientCommandPendingStruct *next;
 } SilcClientCommandPending;