1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

lib: Add a "mem_ctx" arg to gencache_get (unused so far)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke
2013-09-04 08:56:23 +02:00
committed by Jeremy Allison
parent f630360b7f
commit 8a7246ac2c
14 changed files with 26 additions and 23 deletions

View File

@ -96,7 +96,7 @@ static bool fetch_map_from_gencache(TALLOC_CTX *ctx,
if (key == NULL) { if (key == NULL) {
return false; return false;
} }
found = gencache_get(key, &value, NULL); found = gencache_get(key, NULL, &value, NULL);
TALLOC_FREE(key); TALLOC_FREE(key);
if (!found) { if (!found) {
return false; return false;

View File

@ -107,7 +107,8 @@ struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_S
bool gencache_set(const char *keystr, const char *value, time_t timeout); bool gencache_set(const char *keystr, const char *value, time_t timeout);
bool gencache_del(const char *keystr); bool gencache_del(const char *keystr);
bool gencache_get(const char *keystr, char **valstr, time_t *timeout); bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
time_t *ptimeout);
bool gencache_parse(const char *keystr, bool gencache_parse(const char *keystr,
void (*parser)(time_t timeout, DATA_BLOB blob, void (*parser)(time_t timeout, DATA_BLOB blob,
void *private_data), void *private_data),

View File

@ -705,7 +705,8 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
* @retval False for failure * @retval False for failure
**/ **/
bool gencache_get(const char *keystr, char **value, time_t *ptimeout) bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
time_t *ptimeout)
{ {
DATA_BLOB blob; DATA_BLOB blob;
bool ret = False; bool ret = False;

View File

@ -48,7 +48,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
if (key == NULL) { if (key == NULL) {
return false; return false;
} }
ret = gencache_get(key, &value, &timeout); ret = gencache_get(key, NULL, &value, &timeout);
if (!ret) { if (!ret) {
goto done; goto done;
} }
@ -209,7 +209,7 @@ bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired)
if (key == NULL) { if (key == NULL) {
return false; return false;
} }
ret = gencache_get(key, &value, &timeout); ret = gencache_get(key, NULL, &value, &timeout);
TALLOC_FREE(key); TALLOC_FREE(key);
if (!ret) { if (!ret) {
return false; return false;
@ -246,7 +246,7 @@ bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired)
if (key == NULL) { if (key == NULL) {
return false; return false;
} }
ret = gencache_get(key, &value, &timeout); ret = gencache_get(key, NULL, &value, &timeout);
TALLOC_FREE(key); TALLOC_FREE(key);
if (!ret) { if (!ret) {
return false; return false;
@ -431,7 +431,7 @@ static bool idmap_cache_del_xid(char t, int xid)
time_t timeout; time_t timeout;
bool ret = true; bool ret = true;
if (!gencache_get(key, &sid_str, &timeout)) { if (!gencache_get(key, NULL, &sid_str, &timeout)) {
DEBUG(3, ("no entry: %s\n", key)); DEBUG(3, ("no entry: %s\n", key));
ret = false; ret = false;
goto done; goto done;

View File

@ -101,7 +101,7 @@ bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip)
/* If the key exists then the WINS server has been marked as dead */ /* If the key exists then the WINS server has been marked as dead */
result = gencache_get(keystr, NULL, NULL); result = gencache_get(keystr, NULL, NULL, NULL);
SAFE_FREE(keystr); SAFE_FREE(keystr);
DEBUG(4, ("wins_srv_is_dead: %s is %s\n", inet_ntoa(wins_ip), DEBUG(4, ("wins_srv_is_dead: %s is %s\n", inet_ntoa(wins_ip),

View File

@ -95,7 +95,7 @@ char *sitename_fetch(const char *realm)
key = sitename_key(query_realm); key = sitename_key(query_realm);
ret = gencache_get( key, &sitename, &timeout ); ret = gencache_get( key, NULL, &sitename, &timeout );
SAFE_FREE(key); SAFE_FREE(key);
if ( !ret ) { if ( !ret ) {
DEBUG(5,("sitename_fetch: No stored sitename for %s\n", DEBUG(5,("sitename_fetch: No stored sitename for %s\n",

View File

@ -143,7 +143,7 @@ NTSTATUS check_negative_conn_cache( const char *domain, const char *server)
if (key == NULL) if (key == NULL)
goto done; goto done;
if (gencache_get(key, &value, NULL)) if (gencache_get(key, NULL, &value, NULL))
result = negative_conn_cache_valuedecode(value); result = negative_conn_cache_valuedecode(value);
done: done:
DEBUG(9,("check_negative_conn_cache returning result %d for domain %s " DEBUG(9,("check_negative_conn_cache returning result %d for domain %s "

View File

@ -156,7 +156,7 @@ bool namecache_fetch(const char *name,
return False; return False;
} }
if (!gencache_get(key, &value, &timeout)) { if (!gencache_get(key, NULL, &value, &timeout)) {
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type)); DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
SAFE_FREE(key); SAFE_FREE(key);
return False; return False;
@ -294,7 +294,7 @@ bool namecache_status_fetch(const char *keyname,
if (!key) if (!key)
return False; return False;
if (!gencache_get(key, &value, &timeout)) { if (!gencache_get(key, NULL, &value, &timeout)) {
DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n", DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
key)); key));
SAFE_FREE(key); SAFE_FREE(key);

View File

@ -183,7 +183,7 @@ char *saf_fetch( const char *domain )
return NULL; return NULL;
} }
ret = gencache_get( key, &server, &timeout ); ret = gencache_get( key, NULL, &server, &timeout );
TALLOC_FREE( key ); TALLOC_FREE( key );
@ -199,7 +199,7 @@ char *saf_fetch( const char *domain )
return NULL; return NULL;
} }
ret = gencache_get( key, &server, &timeout ); ret = gencache_get( key, NULL, &server, &timeout );
TALLOC_FREE( key ); TALLOC_FREE( key );

View File

@ -160,7 +160,7 @@ bool trustdom_cache_fetch(const char* name, struct dom_sid* sid)
if (!key) if (!key)
return False; return False;
if (!gencache_get(key, &value, &timeout)) { if (!gencache_get(key, NULL, &value, &timeout)) {
DEBUG(5, ("no entry for trusted domain %s found.\n", name)); DEBUG(5, ("no entry for trusted domain %s found.\n", name));
SAFE_FREE(key); SAFE_FREE(key);
return False; return False;
@ -191,7 +191,7 @@ uint32 trustdom_cache_fetch_timestamp( void )
time_t timeout; time_t timeout;
uint32 timestamp; uint32 timestamp;
if (!gencache_get(TDOMTSKEY, &value, &timeout)) { if (!gencache_get(TDOMTSKEY, NULL, &value, &timeout)) {
DEBUG(5, ("no timestamp for trusted domain cache located.\n")); DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
SAFE_FREE(value); SAFE_FREE(value);
return 0; return 0;

View File

@ -446,7 +446,7 @@ bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value)
goto done; goto done;
} }
if (gencache_get(cache_key, &cache_value, NULL)) { if (gencache_get(cache_key, NULL, &cache_value, NULL)) {
uint32 tmp = strtoul(cache_value, NULL, 10); uint32 tmp = strtoul(cache_value, NULL, 10);
*value = tmp; *value = tmp;
ret = True; ret = True;

View File

@ -630,7 +630,8 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s", cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s",
aprinter); aprinter);
if ((cache_key != NULL) && gencache_get(cache_key, &tmp, NULL)) { if ((cache_key != NULL) &&
gencache_get(cache_key, NULL, &tmp, NULL)) {
found = (strcmp(tmp, printer_not_found) != 0); found = (strcmp(tmp, printer_not_found) != 0);
if (!found) { if (!found) {

View File

@ -8130,12 +8130,12 @@ static bool run_local_gencache(int dummy)
return False; return False;
} }
if (!gencache_get("foo", NULL, NULL)) { if (!gencache_get("foo", NULL, NULL, NULL)) {
d_printf("%s: gencache_get() failed\n", __location__); d_printf("%s: gencache_get() failed\n", __location__);
return False; return False;
} }
if (!gencache_get("foo", &val, &tm)) { if (!gencache_get("foo", NULL, &val, &tm)) {
d_printf("%s: gencache_get() failed\n", __location__); d_printf("%s: gencache_get() failed\n", __location__);
return False; return False;
} }
@ -8159,7 +8159,7 @@ static bool run_local_gencache(int dummy)
return False; return False;
} }
if (gencache_get("foo", &val, &tm)) { if (gencache_get("foo", NULL, &val, &tm)) {
d_printf("%s: gencache_get() on deleted entry " d_printf("%s: gencache_get() on deleted entry "
"succeeded\n", __location__); "succeeded\n", __location__);
return False; return False;
@ -8212,7 +8212,7 @@ static bool run_local_gencache(int dummy)
__location__); __location__);
return false; return false;
} }
if (gencache_get("blob", &val, &tm)) { if (gencache_get("blob", NULL, &val, &tm)) {
d_printf("%s: gencache_get succeeded\n", __location__); d_printf("%s: gencache_get succeeded\n", __location__);
return false; return false;
} }

View File

@ -1512,7 +1512,7 @@ bool fetch_current_dc_from_gencache(TALLOC_CTX *mem_ctx,
if (key == NULL) { if (key == NULL) {
goto done; goto done;
} }
if (!gencache_get(key, &value, NULL)) { if (!gencache_get(key, NULL, &value, NULL)) {
goto done; goto done;
} }
p = strchr(value, ' '); p = strchr(value, ' ');