silcclient: Add generic client entry operation context
[silc.git] / lib / silcclient / client.c
index 38afc4537e297fb61f6ad6f1b88cc85c32571286..f72a4a7201ec64dba1f2b37f87457fbe1b81ebe6 100644 (file)
@@ -391,6 +391,9 @@ SILC_FSM_STATE(silc_client_connection_st_close)
 {
   SilcClientConnection conn = fsm_context;
   SilcClientCommandContext cmd;
+  SilcList list;
+  SilcIDCacheEntry entry;
+  SilcClientEntry client_entry;
 
   /* Finish running command threads.  This will also finish waiting packet
      thread, as they are always waiting for some command.  If any thread is
@@ -416,6 +419,20 @@ SILC_FSM_STATE(silc_client_connection_st_close)
     conn->internal->op = NULL;
   }
 
+  /* Abort ongoing client entry operations */
+  if (conn->internal->client_cache) {
+    if (silc_idcache_get_all(conn->internal->client_cache, &list)) {
+      silc_list_start(list);
+      while ((entry = silc_list_get(list))) {
+       client_entry = entry->context;
+       if (client_entry->internal.op) {
+         silc_async_abort(client_entry->internal.op, NULL, NULL);
+         client_entry->internal.op = NULL;
+       }
+      }
+    }
+  }
+
   /* If event thread is running, finish it. */
   if (silc_fsm_is_started(&conn->internal->event_thread)) {
     SILC_LOG_DEBUG(("Finish event thread"));