Add generic client entry async operation context to the internal
context. Change the key agreement to start using it.
Add support for aborting client entry operations when the client entry
is deleted or when the connection is closed to the server.
{
SilcClientConnection conn = fsm_context;
SilcClientCommandContext cmd;
{
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
/* Finish running command threads. This will also finish waiting packet
thread, as they are always waiting for some command. If any thread is
conn->internal->op = NULL;
}
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"));
/* If event thread is running, finish it. */
if (silc_fsm_is_started(&conn->internal->event_thread)) {
SILC_LOG_DEBUG(("Finish event thread"));
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2007 Pekka Riikonen
+ Copyright (C) 1997 - 2014 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
unsigned char *key; /* Valid if application provided the key */
SilcUInt32 key_len; /* Key data length */
SilcClientKeyAgreement ke; /* Current key agreement context or NULL */
unsigned char *key; /* Valid if application provided the key */
SilcUInt32 key_len; /* Key data length */
SilcClientKeyAgreement ke; /* Current key agreement context or NULL */
+ SilcAsyncOperation op; /* Asynchronous operation with this client */
SilcAtomic32 refcnt; /* Reference counter */
SilcAtomic32 deleted; /* Flag indicating whether the client object is
SilcAtomic32 refcnt; /* Reference counter */
SilcAtomic32 deleted; /* Flag indicating whether the client object is
{
SilcClientConnection conn = fsm_context;
SilcClient client = conn->client;
{
SilcClientConnection conn = fsm_context;
SilcClient client = conn->client;
- SilcSKEParamsStruct params;
+ SilcSKEParamsStruct params = {};
SilcClientID cid;
SILC_LOG_DEBUG(("Starting key exchange protocol"));
SilcClientID cid;
SILC_LOG_DEBUG(("Starting key exchange protocol"));
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2008 Pekka Riikonen
+ Copyright (C) 2001 - 2014 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (client_entry->internal.hmac_receive)
silc_hmac_free(client_entry->internal.hmac_receive);
silc_client_ftp_session_free_client(client, client_entry);
if (client_entry->internal.hmac_receive)
silc_hmac_free(client_entry->internal.hmac_receive);
silc_client_ftp_session_free_client(client, client_entry);
+ if (client_entry->internal.op)
+ silc_async_abort(client_entry->internal.op, NULL, NULL);
+ client_entry->internal.op = NULL;
if (client_entry->internal.ke)
silc_client_abort_key_agreement(client, conn, client_entry);
silc_atomic_uninit32(&client_entry->internal.deleted);
if (client_entry->internal.ke)
silc_client_abort_key_agreement(client, conn, client_entry);
silc_atomic_uninit32(&client_entry->internal.deleted);
+ /* Abort ongoing operation */
+ if (client_entry->internal.op) {
+ SILC_LOG_DEBUG(("Aborting ongoing operation %p",
+ client_entry->internal.op));
+ silc_async_abort(client_entry->internal.op, NULL, NULL);
+ client_entry->internal.op = NULL;
+ }
+
silc_client_unref_client(client, conn, client_entry);
return TRUE;
}
silc_client_unref_client(client, conn, client_entry);
return TRUE;
}
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2007 Pekka Riikonen
+ Copyright (C) 2001 - 2014 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SilcClientListener listener; /* Listener */
SilcKeyAgreementCallback completion; /* Key agreement completion */
void *context; /* User context */
SilcClientListener listener; /* Listener */
SilcKeyAgreementCallback completion; /* Key agreement completion */
void *context; /* User context */
- SilcAsyncOperation op; /* Async operation, initiator */
};
/************************ Static utility functions **************************/
};
/************************ Static utility functions **************************/
silc_client_listener_free(ke->listener);
silc_schedule_task_del_by_context(conn->internal->schedule, client_entry);
silc_client_listener_free(ke->listener);
silc_schedule_task_del_by_context(conn->internal->schedule, client_entry);
- if (ke->op)
- silc_async_abort(ke->op, NULL, NULL);
+ if (client_entry->internal.op)
+ silc_async_abort(client_entry->internal.op, NULL, NULL);
+ client_entry->internal.op = NULL;
client_entry->internal.ke = NULL;
client_entry->internal.prv_resp = FALSE;
silc_client_unref_client(client, conn, client_entry);
client_entry->internal.ke = NULL;
client_entry->internal.prv_resp = FALSE;
silc_client_unref_client(client, conn, client_entry);
SilcClientKeyAgreement ke = client_entry->internal.ke;
SilcSKEKeyMaterial keymat;
SilcClientKeyAgreement ke = client_entry->internal.ke;
SilcSKEKeyMaterial keymat;
+ client_entry->internal.op = NULL;
switch (status) {
case SILC_CLIENT_CONN_SUCCESS:
switch (status) {
case SILC_CLIENT_CONN_SUCCESS:
params->no_authentication = TRUE;
/* Connect to the remote client. Performs key exchange automatically. */
params->no_authentication = TRUE;
/* Connect to the remote client. Performs key exchange automatically. */
- ke->op = silc_client_connect_to_client(client, params, public_key,
- private_key, hostname, port,
- silc_client_keyagr_completion,
- client_entry);
- if (!ke->op) {
+ client_entry->internal.op =
+ silc_client_connect_to_client(client, params, public_key,
+ private_key, hostname, port,
+ silc_client_keyagr_completion,
+ client_entry);
+ if (!client_entry->internal.op) {
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ERROR,
NULL, context);
silc_client_keyagr_free(client, conn, client_entry);
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ERROR,
NULL, context);
silc_client_keyagr_free(client, conn, client_entry);
params->no_authentication = TRUE;
/* Perform key exchange protocol */
params->no_authentication = TRUE;
/* Perform key exchange protocol */
- ke->op = silc_client_key_exchange(client, params, public_key,
- private_key, stream, SILC_CONN_CLIENT,
- silc_client_keyagr_completion,
- client_entry);
- if (!ke->op) {
+ client_entry->internal.op =
+ silc_client_key_exchange(client, params, public_key,
+ private_key, stream, SILC_CONN_CLIENT,
+ silc_client_keyagr_completion,
+ client_entry);
+ if (!client_entry->internal.op) {
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ERROR,
NULL, context);
silc_client_keyagr_free(client, conn, client_entry);
completion(client, conn, client_entry, SILC_KEY_AGREEMENT_ERROR,
NULL, context);
silc_client_keyagr_free(client, conn, client_entry);
{
SilcClient client = listener->client;
SilcClientConnection conn;
{
SilcClient client = listener->client;
SilcClientConnection conn;
- SilcSKEParamsStruct params;
+ SilcSKEParamsStruct params = {};
const char *hostname = NULL, *ip = NULL;
SilcUInt16 port;
const char *hostname = NULL, *ip = NULL;
SilcUInt16 port;