1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

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.
This commit is contained in:
Volker Lendecke 2009-07-10 12:24:56 +02:00
parent d936d1bd84
commit 3edcd55bf1
11 changed files with 1 additions and 144 deletions

View File

@ -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);

View File

@ -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.

View File

@ -170,7 +170,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
gfree_charcnv();
gfree_interfaces();
gencache_shutdown();
secrets_shutdown();
TALLOC_FREE(ctx);

View File

@ -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 {

View File

@ -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;

View File

@ -123,7 +123,6 @@ SMBC_module_init(void * punused)
static void
SMBC_module_terminate(void)
{
gencache_shutdown();
secrets_shutdown();
gfree_all();
SMBC_initialized = false;

View File

@ -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)

View File

@ -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 );

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}