[SCM] Samba Shared Repository - branch master updated - tevent-0-9-8-651-gcd749ef
Volker Lendecke
vlendec at samba.org
Wed Sep 23 10:51:05 MDT 2009
The branch, master has been updated
via cd749ef8bd271b1de0212e25c67f87283ba7582b (commit)
via aece84f22de9aceb150a04b68dea18abcff968b2 (commit)
via 76d95b9a2dcfff9df1865ffff74f0e9c32bce609 (commit)
from adf66e75c060e6462b9f8819944d0f8ff1ef2c1b (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit cd749ef8bd271b1de0212e25c67f87283ba7582b
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 23 15:47:05 2009 +0200
s3:gencache: Make gencache_del() return success for expired entries
This fixes nasty error messages from "net cache flush"
commit aece84f22de9aceb150a04b68dea18abcff968b2
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 23 15:41:06 2009 +0200
s3:gencache: Remove some over-paranoid locking
commit 76d95b9a2dcfff9df1865ffff74f0e9c32bce609
Author: Volker Lendecke <vl at samba.org>
Date: Wed Sep 23 15:21:40 2009 +0200
s3:gencache: Add a "was_expired" argument to gencache_get_data_blob
This is set to true if the routine returns failure due to an existing but
expired entry.
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 2 +-
source3/lib/gencache.c | 52 +++++++++++++++++++++++++----------------
source3/libsmb/dsgetdcname.c | 2 +-
source3/torture/torture.c | 4 +-
4 files changed, 36 insertions(+), 24 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f2350e7..d664a26 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -535,7 +535,7 @@ 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);
bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
- time_t *timeout);
+ time_t *timeout, bool *was_expired);
bool gencache_stabilize(void);
bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index ee1f4b7..d3631b9 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -208,9 +208,9 @@ done:
bool gencache_del(const char *keystr)
{
- bool exists;
+ bool exists, was_expired;
bool ret = false;
- char *value;
+ DATA_BLOB value;
if (keystr == NULL) {
return false;
@@ -220,23 +220,26 @@ bool gencache_del(const char *keystr)
DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr));
- if (tdb_lock_bystring(cache_notrans, keystr) == -1) {
- DEBUG(5, ("Could not lock key for %s\n", keystr));
- return false;
- }
-
/*
* We delete an element by setting its timeout to 0. This way we don't
* have to do a transaction on gencache.tdb every time we delete an
* element.
*/
- exists = gencache_get(keystr, &value, NULL);
+ exists = gencache_get_data_blob(keystr, &value, NULL, &was_expired);
+
+ if (!exists && was_expired) {
+ /*
+ * gencache_get_data_blob has implicitly deleted this
+ * entry, so we have to return success here.
+ */
+ return true;
+ }
+
if (exists) {
- SAFE_FREE(value);
+ data_blob_free(&value);
ret = gencache_set(keystr, "", 0);
}
- tdb_unlock_bystring(cache_notrans, keystr);
return ret;
}
@@ -273,24 +276,25 @@ static bool gencache_pull_timeout(char *val, time_t *pres, char **pendptr)
**/
bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
- time_t *timeout)
+ time_t *timeout, bool *was_expired)
{
TDB_DATA databuf;
time_t t;
char *endptr;
+ bool expired = false;
if (keystr == NULL) {
- return false;
+ goto fail;
}
if (tdb_data_cmp(string_term_tdb_data(keystr),
last_stabilize_key()) == 0) {
DEBUG(10, ("Can't get %s as a key\n", keystr));
- return false;
+ goto fail;
}
if (!gencache_init()) {
- return False;
+ goto fail;
}
databuf = tdb_fetch_bystring(cache_notrans, keystr);
@@ -302,12 +306,12 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
if (databuf.dptr == NULL) {
DEBUG(10, ("Cache entry with key = %s couldn't be found \n",
keystr));
- return False;
+ goto fail;
}
if (!gencache_pull_timeout((char *)databuf.dptr, &t, &endptr)) {
SAFE_FREE(databuf.dptr);
- return False;
+ goto fail;
}
DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, "
@@ -317,7 +321,7 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
if (t == 0) {
/* Deleted */
SAFE_FREE(databuf.dptr);
- return False;
+ goto fail;
}
if (t <= time(NULL)) {
@@ -331,7 +335,9 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
gencache_set(keystr, "", 0);
SAFE_FREE(databuf.dptr);
- return False;
+
+ expired = true;
+ goto fail;
}
if (blob != NULL) {
@@ -341,7 +347,7 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
if (blob->data == NULL) {
SAFE_FREE(databuf.dptr);
DEBUG(0, ("memdup failed\n"));
- return False;
+ goto fail;
}
}
@@ -352,6 +358,12 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
}
return True;
+
+fail:
+ if (was_expired != NULL) {
+ *was_expired = expired;
+ }
+ return false;
}
struct stabilize_state {
@@ -503,7 +515,7 @@ bool gencache_get(const char *keystr, char **value, time_t *ptimeout)
DATA_BLOB blob;
bool ret = False;
- ret = gencache_get_data_blob(keystr, &blob, ptimeout);
+ ret = gencache_get_data_blob(keystr, &blob, ptimeout, NULL);
if (!ret) {
return false;
}
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 99d21eb..98b6594 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -331,7 +331,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- if (!gencache_get_data_blob(key, &blob, NULL)) {
+ if (!gencache_get_data_blob(key, &blob, NULL, NULL)) {
return NT_STATUS_NOT_FOUND;
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 98694ed..9e1ac76 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5863,7 +5863,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (!gencache_get_data_blob("foo", &blob, NULL)) {
+ if (!gencache_get_data_blob("foo", &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
return False;
}
@@ -5887,7 +5887,7 @@ static bool run_local_gencache(int dummy)
return False;
}
- if (gencache_get_data_blob("foo", &blob, NULL)) {
+ if (gencache_get_data_blob("foo", &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() on deleted entry "
"succeeded\n", __location__);
return False;
--
Samba Shared Repository
More information about the samba-cvs
mailing list