From f1007db90d50d25f513cd0ce76f1b73fc5a388b8 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 29 Jun 2002 22:36:49 +0000 Subject: [PATCH] Fixed pending command deletion to delete correctly. --- CHANGES | 7 +++++++ apps/silcd/command.c | 5 ++++- apps/silcd/command.h | 3 ++- lib/silcclient/command.c | 6 ++++-- lib/silcclient/command.h | 3 ++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 14b495b0..3e584165 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Sun Jun 30 01:30:22 EEST 2002 Pekka Riikonen + + * 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 * Return NO_SUCH_CHANNEL error in USERS for channel that is diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 1b5a3f27..0be43bee 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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++; } diff --git a/apps/silcd/command.h b/apps/silcd/command.h index 464b261b..2e3273d6 100644 --- a/apps/silcd/command.h +++ b/apps/silcd/command.h @@ -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; diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index 167d7878..c03f71af 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -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++; } diff --git a/lib/silcclient/command.h b/lib/silcclient/command.h index a334352e..b85d2e05 100644 --- a/lib/silcclient/command.h +++ b/lib/silcclient/command.h @@ -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; -- 2.24.0