From: Pekka Riikonen Date: Tue, 19 Apr 2005 09:02:21 +0000 (+0000) Subject: Changed SilcIDCache API to have context in destructor. X-Git-Tag: autodist.1.2~24 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=f0c9e76901250d71009257a1643763e6c129814e Changed SilcIDCache API to have context in destructor. --- diff --git a/CHANGES b/CHANGES index 2ebf810f..2fe70b29 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Tue Apr 19 11:57:35 EEST 2005 Pekka Riikonen + + * Added context to the SilcIDCache destructor. Affected + files are lib/silccore/silcidcache.[ch], + lib/silcclient/client.c and silcd/server.c. + Mon Apr 18 09:53:28 EEST 2005 Pekka Riikonen * Added pkg-config check to configure. diff --git a/lib/configure.ad b/lib/configure.ad index f52573cb..ff9e2a3c 100644 --- a/lib/configure.ad +++ b/lib/configure.ad @@ -51,7 +51,7 @@ SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient" # Do the releases and library versioning according to following rules: # # - If any code has changed in library, increment [LIB]_REVISION -# - If functions were added, set [LIB]_REVISION to 0 +# - If functions were added, removed or changed, set [LIB]_REVISION to 0 # - If functions were added, removed or changed, increment [LIB]_CURRENT # - If functions were added, increment [LIB]_AGE # - If functions were removed, set [LIB]_AGE to 0 @@ -68,14 +68,14 @@ SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient" LIB_BASE_VERSION=1.0 # libsilc versions -LIBSILC_CURRENT=4 # prev = 3 +LIBSILC_CURRENT=5 # prev = 4 LIBSILC_REVISION=0 # prev = 0 -LIBSILC_AGE=3 # prev = 2 +LIBSILC_AGE=3 # prev = 3 # libsilcclient versions -LIBSILCCLIENT_CURRENT=4 # prev = 3 +LIBSILCCLIENT_CURRENT=4 # prev = 4 LIBSILCCLIENT_REVISION=0 # prev = 0 -LIBSILCCLIENT_AGE=3 # prev = 2 +LIBSILCCLIENT_AGE=3 # prev = 3 # Substitute the version numbers AC_SUBST(LIB_BASE_VERSION) diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index d4546038..61191981 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -254,11 +254,11 @@ silc_client_add_connection(SilcClient client, conn->remote_port = port; conn->context = context; conn->internal->client_cache = - silc_idcache_alloc(0, SILC_ID_CLIENT, NULL, FALSE, TRUE); + silc_idcache_alloc(0, SILC_ID_CLIENT, NULL, NULL, FALSE, TRUE); conn->internal->channel_cache = silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, - FALSE, TRUE); + NULL, FALSE, TRUE); conn->internal->server_cache = silc_idcache_alloc(0, SILC_ID_SERVER, NULL, - FALSE, TRUE); + NULL, FALSE, TRUE); conn->internal->pending_commands = silc_dlist_init(); conn->internal->ftp_sessions = silc_dlist_init(); diff --git a/lib/silccore/silcidcache.c b/lib/silccore/silcidcache.c index da86f743..62fb5af0 100644 --- a/lib/silccore/silcidcache.c +++ b/lib/silccore/silcidcache.c @@ -67,6 +67,7 @@ struct SilcIDCacheStruct { SilcHashTable name_table; SilcHashTable context_table; SilcIDCacheDestructor destructor; + void *context; SilcIdType type; unsigned int delete_id : 1; unsigned int delete_name : 1; @@ -102,6 +103,7 @@ struct SilcIDCacheListStruct { SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type, SilcIDCacheDestructor destructor, + void *destructor_context, bool delete_id, bool delete_name) { SilcIDCache cache; @@ -123,6 +125,7 @@ SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type, cache->context_table = silc_hash_table_alloc(count, silc_hash_ptr, NULL, NULL, NULL, NULL, NULL, TRUE); cache->destructor = destructor; + cache->context = destructor_context; cache->type = id_type; cache->delete_id = delete_id; cache->delete_name = delete_name; @@ -344,7 +347,7 @@ static void silc_idcache_purge_foreach(void *key, void *context, if (ret == TRUE) { /* Call the destructor */ if (cache->destructor) - cache->destructor(cache, c); + cache->destructor(cache, c, cache->context); /* Free the entry, it has been deleted from the hash tables */ silc_idcache_destructor(NULL, c, NULL); @@ -385,7 +388,7 @@ bool silc_idcache_purge_by_context(SilcIDCache cache, void *context) if (ret == TRUE) { /* Call the destructor */ if (cache->destructor) - cache->destructor(cache, c); + cache->destructor(cache, c, cache->context); /* Free the entry, it has been deleted from the hash tables */ silc_idcache_destructor(NULL, c, NULL); diff --git a/lib/silccore/silcidcache.h b/lib/silccore/silcidcache.h index 69c5290f..b5612d39 100644 --- a/lib/silccore/silcidcache.h +++ b/lib/silccore/silcidcache.h @@ -111,7 +111,8 @@ typedef struct SilcIDCacheListStruct *SilcIDCacheList; * SYNOPSIS * * typedef void (*SilcIDCacheDestructor)(SilcIDCache cache, - * SilcIDCacheEntry entry); + * SilcIDCacheEntry entry, + * void *context); * * DESCRIPTION * @@ -122,7 +123,8 @@ typedef struct SilcIDCacheListStruct *SilcIDCacheList; * ***/ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache, - SilcIDCacheEntry entry); + SilcIDCacheEntry entry, + void *context); #define SILC_ID_CACHE_EXPIRE 3600 #define SILC_ID_CACHE_EXPIRE_DEF (time(NULL) + SILC_ID_CACHE_EXPIRE) @@ -134,7 +136,9 @@ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache, * SYNOPSIS * * SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type, - * SilcIDCacheDestructor destructor); + * SilcIDCacheDestructor destructor, + * void *destructor_context, + * bool delete_id, bool delete_name); * * DESCRIPTION * @@ -150,6 +154,7 @@ typedef void (*SilcIDCacheDestructor)(SilcIDCache cache, ***/ SilcIDCache silc_idcache_alloc(SilcUInt32 count, SilcIdType id_type, SilcIDCacheDestructor destructor, + void *destructor_context, bool delete_id, bool delete_name); /****f* silccore/SilcIDCacheAPI/silc_idcache_free