From 3edcd55bf140d09833284ba5a0f04f86b04ef7dc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 10 Jul 2009 12:24:56 +0200 Subject: Remove gencache_init/shutdown gencache_get/set/del/iterate call gencache_init() internally anyway. And we've been very lazy calling gencache_shutdown, so this seems not really required. --- source3/include/proto.h | 2 -- source3/lib/gencache.c | 21 +-------------------- source3/lib/netapi/netapi.c | 1 - source3/libads/dns.c | 8 -------- source3/libsmb/dsgetdcname.c | 12 ------------ source3/libsmb/libsmb_context.c | 1 - source3/libsmb/namecache.c | 34 ---------------------------------- source3/libsmb/namequery.c | 12 ------------ source3/libsmb/trustdom_cache.c | 34 ---------------------------------- source3/torture/torture.c | 16 ---------------- source3/utils/net_cache.c | 4 ---- 11 files changed, 1 insertion(+), 144 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 52ca7826ed..23bd22aadc 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -515,8 +515,6 @@ void pull_file_id_24(char *buf, struct file_id *id); /* The following definitions come from lib/gencache.c */ -bool gencache_init(void); -bool gencache_shutdown(void); bool gencache_set(const char *keystr, const char *value, time_t timeout); bool gencache_del(const char *keystr); bool gencache_get(const char *keystr, char **valstr, time_t *timeout); diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index c94fb78541..06eb29345b 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -49,7 +49,7 @@ static struct tdb_context *cache; * false on failure **/ -bool gencache_init(void) +static bool gencache_init(void) { char* cache_fname = NULL; @@ -78,25 +78,6 @@ bool gencache_init(void) } -/** - * Cache shutdown function. Closes opened cache tdb file. - * - * @return true on successful closing the cache or - * false on failure during cache shutdown - **/ - -bool gencache_shutdown(void) -{ - int ret; - /* tdb_close routine returns -1 on error */ - if (!cache) return False; - DEBUG(5, ("Closing cache file\n")); - ret = tdb_close(cache); - cache = NULL; - return ret != -1; -} - - /** * Set an entry in the cache file. If there's no such * one, then add it. diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 2f8474b37f..e80879a1d2 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -170,7 +170,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) gfree_charcnv(); gfree_interfaces(); - gencache_shutdown(); secrets_shutdown(); TALLOC_FREE(ctx); diff --git a/source3/libads/dns.c b/source3/libads/dns.c index 3a9e849668..5cf768de67 100644 --- a/source3/libads/dns.c +++ b/source3/libads/dns.c @@ -754,10 +754,6 @@ bool sitename_store(const char *realm, const char *sitename) bool ret = False; char *key; - if (!gencache_init()) { - return False; - } - if (!realm || (strlen(realm) == 0)) { DEBUG(0,("sitename_store: no realm\n")); return False; @@ -795,10 +791,6 @@ char *sitename_fetch(const char *realm) const char *query_realm; char *key; - if (!gencache_init()) { - return NULL; - } - if (!realm || (strlen(realm) == 0)) { query_realm = lp_realm(); } else { diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 8dee6926d2..9552ad1f22 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -133,10 +133,6 @@ static NTSTATUS dsgetdcname_cache_delete(TALLOC_CTX *mem_ctx, { char *key; - if (!gencache_init()) { - return NT_STATUS_INTERNAL_DB_ERROR; - } - key = dsgetdcname_cache_key(mem_ctx, domain_name); if (!key) { return NT_STATUS_NO_MEMORY; @@ -160,10 +156,6 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, char *key; bool ret = false; - if (!gencache_init()) { - return NT_STATUS_INTERNAL_DB_ERROR; - } - key = dsgetdcname_cache_key(mem_ctx, domain_name); if (!key) { return NT_STATUS_NO_MEMORY; @@ -357,10 +349,6 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, struct NETLOGON_SAM_LOGON_RESPONSE_EX r; NTSTATUS status; - if (!gencache_init()) { - return NT_STATUS_INTERNAL_DB_ERROR; - } - key = dsgetdcname_cache_key(mem_ctx, domain_name); if (!key) { return NT_STATUS_NO_MEMORY; diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 98885876b3..8b22ee5023 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -123,7 +123,6 @@ SMBC_module_init(void * punused) static void SMBC_module_terminate(void) { - gencache_shutdown(); secrets_shutdown(); gfree_all(); SMBC_initialized = false; diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c index d3230cffef..dcfc609dcd 100644 --- a/source3/libsmb/namecache.c +++ b/source3/libsmb/namecache.c @@ -45,14 +45,6 @@ bool namecache_enable(void) return False; } - /* Init namecache by calling gencache initialisation */ - - if (!gencache_init()) { - DEBUG(2, ("namecache_enable: " - "Couldn't initialise namecache on top of gencache.\n")); - return False; - } - /* I leave it for now, though I don't think we really * need this (mimir, 27.09.2002) */ DEBUG(5, ("namecache_enable: enabling netbios namecache, timeout %d " @@ -102,14 +94,6 @@ bool namecache_store(const char *name, int i; bool ret; - /* - * we use gecache call to avoid annoying debug messages about - * initialised namecache again and again... - */ - if (!gencache_init()) { - return False; - } - if (name_type > 255) { return False; /* Don't store non-real name types. */ } @@ -186,10 +170,6 @@ bool namecache_fetch(const char *name, return False; } - if (!gencache_init()) { - return False; - } - if (name_type > 255) { return False; /* Don't fetch non-real name types. */ } @@ -233,9 +213,6 @@ bool namecache_delete(const char *name, int name_type) bool ret; char *key; - if (!gencache_init()) - return False; - if (name_type > 255) { return False; /* Don't fetch non-real name types. */ } @@ -274,10 +251,6 @@ static void flush_netbios_name(const char *key, void namecache_flush(void) { - if (!gencache_init()) { - return; - } - /* * iterate through each NBT cache's entry and flush it * by flush_netbios_name function @@ -312,10 +285,6 @@ bool namecache_status_store(const char *keyname, int keyname_type, time_t expiry; bool ret; - if (!gencache_init()) { - return False; - } - key = namecache_status_record_key(keyname, keyname_type, name_type, keyip); if (!key) @@ -348,9 +317,6 @@ bool namecache_status_fetch(const char *keyname, char *value = NULL; time_t timeout; - if (!gencache_init()) - return False; - key = namecache_status_record_key(keyname, keyname_type, name_type, keyip); if (!key) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 50fb9f1620..05143270b9 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -76,9 +76,6 @@ bool saf_store( const char *domain, const char *servername ) return False; } - if ( !gencache_init() ) - return False; - key = saf_key( domain ); expire = time( NULL ) + lp_parm_int(-1, "saf","ttl", SAF_TTL); @@ -108,9 +105,6 @@ bool saf_join_store( const char *domain, const char *servername ) return False; } - if ( !gencache_init() ) - return False; - key = saf_join_key( domain ); expire = time( NULL ) + lp_parm_int(-1, "saf","join ttl", SAFJOIN_TTL); @@ -134,9 +128,6 @@ bool saf_delete( const char *domain ) return False; } - if ( !gencache_init() ) - return False; - key = saf_join_key(domain); ret = gencache_del(key); SAFE_FREE(key); @@ -171,9 +162,6 @@ char *saf_fetch( const char *domain ) return NULL; } - if ( !gencache_init() ) - return False; - key = saf_join_key( domain ); ret = gencache_get( key, &server, &timeout ); diff --git a/source3/libsmb/trustdom_cache.c b/source3/libsmb/trustdom_cache.c index d891c0768e..eb52b3588d 100644 --- a/source3/libsmb/trustdom_cache.c +++ b/source3/libsmb/trustdom_cache.c @@ -48,12 +48,6 @@ bool trustdom_cache_enable(void) { - /* Init trustdom cache by calling gencache initialisation */ - if (!gencache_init()) { - DEBUG(2, ("trustdomcache_enable: Couldn't initialise trustdom cache on top of gencache.\n")); - return False; - } - return True; } @@ -68,12 +62,6 @@ bool trustdom_cache_enable(void) bool trustdom_cache_shutdown(void) { - /* Close trustdom cache by calling gencache shutdown */ - if (!gencache_shutdown()) { - DEBUG(2, ("trustdomcache_shutdown: Couldn't shutdown trustdom cache on top of gencache.\n")); - return False; - } - return True; } @@ -114,13 +102,6 @@ bool trustdom_cache_store(char* name, char* alt_name, const DOM_SID *sid, fstring sid_string; bool ret; - /* - * we use gecache call to avoid annoying debug messages - * about initialised trustdom - */ - if (!gencache_init()) - return False; - DEBUG(5, ("trustdom_store: storing SID %s of domain %s\n", sid_string_dbg(sid), name)); @@ -165,10 +146,6 @@ bool trustdom_cache_fetch(const char* name, DOM_SID* sid) char *key = NULL, *value = NULL; time_t timeout; - /* init the cache */ - if (!gencache_init()) - return False; - /* exit now if null pointers were passed as they're required further */ if (!sid) return False; @@ -209,10 +186,6 @@ uint32 trustdom_cache_fetch_timestamp( void ) time_t timeout; uint32 timestamp; - /* init the cache */ - if (!gencache_init()) - return False; - if (!gencache_get(TDOMTSKEY, &value, &timeout)) { DEBUG(5, ("no timestamp for trusted domain cache located.\n")); SAFE_FREE(value); @@ -233,10 +206,6 @@ bool trustdom_cache_store_timestamp( uint32 t, time_t timeout ) { fstring value; - /* init the cache */ - if (!gencache_init()) - return False; - fstr_sprintf(value, "%d", t ); if (!gencache_set(TDOMTSKEY, value, timeout)) { @@ -267,9 +236,6 @@ static void flush_trustdom_name(const char* key, const char *value, time_t timeo void trustdom_cache_flush(void) { - if (!gencache_init()) - return; - /* * iterate through each TDOM cache's entry and flush it * by flush_trustdom_name function diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 8cebc2adcc..e3c4084e0c 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -5800,11 +5800,6 @@ static bool run_local_gencache(int dummy) time_t tm; DATA_BLOB blob; - if (!gencache_init()) { - d_printf("%s: gencache_init() failed\n", __location__); - return False; - } - if (!gencache_set("foo", "bar", time(NULL) + 1000)) { d_printf("%s: gencache_set() failed\n", __location__); return False; @@ -5878,17 +5873,6 @@ static bool run_local_gencache(int dummy) return False; } - if (!gencache_shutdown()) { - d_printf("%s: gencache_shutdown() failed\n", __location__); - return False; - } - - if (gencache_shutdown()) { - d_printf("%s: second gencache_shutdown() succeeded\n", - __location__); - return False; - } - return True; } diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c index 5e7db38515..74d8d29b4b 100644 --- a/source3/utils/net_cache.c +++ b/source3/utils/net_cache.c @@ -171,12 +171,10 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) if (gencache_set(keystr, datastr, timeout)) { d_printf("New cache entry stored successfully.\n"); - gencache_shutdown(); return 0; } d_fprintf(stderr, "Entry couldn't be added. Perhaps there's already such a key.\n"); - gencache_shutdown(); return -1; } @@ -275,7 +273,6 @@ static int net_cache_list(struct net_context *c, int argc, const char **argv) return 0; } gencache_iterate(print_cache_entry, NULL, pattern); - gencache_shutdown(); return 0; } @@ -297,7 +294,6 @@ static int net_cache_flush(struct net_context *c, int argc, const char **argv) return 0; } gencache_iterate(delete_cache_entry, NULL, pattern); - gencache_shutdown(); return 0; } -- cgit