mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
gencache: True->true, False->false
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
5ef9184964
commit
d547d030e0
@ -63,7 +63,9 @@ static bool gencache_init(void)
|
|||||||
int open_flags = O_RDWR|O_CREAT;
|
int open_flags = O_RDWR|O_CREAT;
|
||||||
|
|
||||||
/* skip file open if it's already opened */
|
/* skip file open if it's already opened */
|
||||||
if (cache) return True;
|
if (cache) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
cache_fname = cache_path("gencache.tdb");
|
cache_fname = cache_path("gencache.tdb");
|
||||||
if (cache_fname == NULL) {
|
if (cache_fname == NULL) {
|
||||||
@ -112,7 +114,7 @@ static bool gencache_init(void)
|
|||||||
|
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
|
DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_fname = lock_path("gencache_notrans.tdb");
|
cache_fname = lock_path("gencache_notrans.tdb");
|
||||||
@ -139,7 +141,7 @@ static bool gencache_init(void)
|
|||||||
}
|
}
|
||||||
TALLOC_FREE(cache_fname);
|
TALLOC_FREE(cache_fname);
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TDB_DATA last_stabilize_key(void)
|
static TDB_DATA last_stabilize_key(void)
|
||||||
@ -295,7 +297,9 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gencache_init()) return False;
|
if (!gencache_init()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (gencache_have_val(keystr, blob, timeout)) {
|
if (gencache_have_val(keystr, blob, timeout)) {
|
||||||
DEBUG(10, ("Did not store value for %s, we already got it\n",
|
DEBUG(10, ("Did not store value for %s, we already got it\n",
|
||||||
@ -305,7 +309,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
|
|||||||
|
|
||||||
val = talloc_asprintf(talloc_tos(), CACHE_DATA_FMT, (int)timeout);
|
val = talloc_asprintf(talloc_tos(), CACHE_DATA_FMT, (int)timeout);
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
val = talloc_realloc(NULL, val, char, talloc_array_length(val)-1);
|
val = talloc_realloc(NULL, val, char, talloc_array_length(val)-1);
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
@ -383,7 +387,9 @@ bool gencache_del(const char *keystr)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gencache_init()) return False;
|
if (!gencache_init()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(10, ("Deleting cache entry (key=[%s])\n", keystr));
|
DEBUG(10, ("Deleting cache entry (key=[%s])\n", keystr));
|
||||||
|
|
||||||
@ -569,7 +575,7 @@ static void gencache_get_data_blob_parser(time_t timeout, DATA_BLOB blob,
|
|||||||
* timeout
|
* timeout
|
||||||
*
|
*
|
||||||
* @retval true when entry is successfuly fetched
|
* @retval true when entry is successfuly fetched
|
||||||
* @retval False for failure
|
* @retval false for failure
|
||||||
**/
|
**/
|
||||||
|
|
||||||
bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
|
bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
|
||||||
@ -604,7 +610,7 @@ bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
|
|||||||
*timeout = state.timeout;
|
*timeout = state.timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (was_expired != NULL) {
|
if (was_expired != NULL) {
|
||||||
@ -793,14 +799,14 @@ static int wipe_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val,
|
|||||||
* timeout
|
* timeout
|
||||||
*
|
*
|
||||||
* @retval true when entry is successfuly fetched
|
* @retval true when entry is successfuly fetched
|
||||||
* @retval False for failure
|
* @retval false for failure
|
||||||
**/
|
**/
|
||||||
|
|
||||||
bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
|
bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
|
||||||
time_t *ptimeout)
|
time_t *ptimeout)
|
||||||
{
|
{
|
||||||
DATA_BLOB blob;
|
DATA_BLOB blob;
|
||||||
bool ret = False;
|
bool ret = false;
|
||||||
|
|
||||||
ret = gencache_get_data_blob(keystr, mem_ctx, &blob, ptimeout, NULL);
|
ret = gencache_get_data_blob(keystr, mem_ctx, &blob, ptimeout, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user