[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-3078-g2954b2b

Volker Lendecke vlendec at samba.org
Thu Jul 3 14:00:27 GMT 2008


The branch, v3-3-test has been updated
       via  2954b2be563149380e1fae7fe088b98d6cbd42e7 (commit)
       via  16062dfc3dcc8f1ca0024a3ae21effb889c7ffc0 (commit)
       via  c4e6de9e34e1ff76552ce6d4e72b343fb5f33306 (commit)
      from  cfd59383d680e41a885e546842b0eb8585123acb (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 2954b2be563149380e1fae7fe088b98d6cbd42e7
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 3 15:58:37 2008 +0200

    Return timed out entries from gencache_get if timeout param != NULL
    
    net cache get was the only one interested in the timeout. That single caller
    can take care of the timeout itself then.
    
    With this API change idmap_cache.c can be converted to gencache.

commit 16062dfc3dcc8f1ca0024a3ae21effb889c7ffc0
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 3 15:15:57 2008 +0200

    Pass NULL to gencache_get when we are not interested in the timeout value

commit c4e6de9e34e1ff76552ce6d4e72b343fb5f33306
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 3 15:14:01 2008 +0200

    Fix indentation

-----------------------------------------------------------------------

Summary of changes:
 source/lib/gencache.c          |   25 +++++++++++++++----------
 source/libads/dns.c            |    3 +--
 source/libsmb/namecache.c      |    6 ++----
 source/libsmb/namequery.c      |    3 +--
 source/libsmb/trustdom_cache.c |    6 ++----
 source/torture/torture.c       |    4 ++--
 source/utils/net_cache.c       |    3 ++-
 source/winbindd/idmap_ad.c     |    2 +-
 8 files changed, 26 insertions(+), 26 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/gencache.c b/source/lib/gencache.c
index b773f83..1b4342a 100644
--- a/source/lib/gencache.c
+++ b/source/lib/gencache.c
@@ -166,15 +166,16 @@ bool gencache_del(const char *keystr)
  *
  * @param keystr string that represents a key of this entry
  * @param valstr buffer that is allocated and filled with the entry value
- *        buffer's disposing must be done outside
- * @param timeout pointer to a time_t that is filled with entry's
- *        timeout
+ *               buffer's disposing must be done outside
+ * @param timeout If == NULL, the caller is not interested in timed out
+ *                entries. If != NULL, return the timeout timestamp, the
+ *                caller must figure out itself if this entry is timed out.
  *
  * @retval true when entry is successfuly fetched
  * @retval False for failure
  **/
 
-bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
+bool gencache_get(const char *keystr, char **valstr, time_t *ptimeout)
 {
 	TDB_DATA databuf;
 	time_t t;
@@ -207,9 +208,13 @@ bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
 		   "timeout = %s", t > time(NULL) ? "valid" :
 		   "expired", keystr, endptr+1, ctime(&t)));
 
-	if (t <= time(NULL)) {
+	if ((t <= time(NULL)) && (ptimeout == NULL)) {
+
+		/*
+		 * The entry is expired, and the caller isn't interested in
+		 * timed out ones. Delete it.
+		 */
 
-		/* We're expired, delete the entry */
 		tdb_delete_bystring(cache, keystr);
 
 		SAFE_FREE(databuf.dptr);
@@ -224,15 +229,15 @@ bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
 			return False;
 		}
 	}
-	
+
 	SAFE_FREE(databuf.dptr);
 
-	if (timeout) {
-		*timeout = t;
+	if (ptimeout) {
+		*ptimeout = t;
 	}
 
 	return True;
-} 
+}
 
 /**
  * Get existing entry from the cache file.
diff --git a/source/libads/dns.c b/source/libads/dns.c
index 3a9e849..a8825d3 100644
--- a/source/libads/dns.c
+++ b/source/libads/dns.c
@@ -790,7 +790,6 @@ bool sitename_store(const char *realm, const char *sitename)
 char *sitename_fetch(const char *realm)
 {
 	char *sitename = NULL;
-	time_t timeout;
 	bool ret = False;
 	const char *query_realm;
 	char *key;
@@ -807,7 +806,7 @@ char *sitename_fetch(const char *realm)
 
 	key = sitename_key(query_realm);
 
-	ret = gencache_get( key, &sitename, &timeout );
+	ret = gencache_get( key, &sitename, NULL );
 	SAFE_FREE(key);
 	if ( !ret ) {
 		DEBUG(5,("sitename_fetch: No stored sitename for %s\n",
diff --git a/source/libsmb/namecache.c b/source/libsmb/namecache.c
index ba706e5..1f462ba 100644
--- a/source/libsmb/namecache.c
+++ b/source/libsmb/namecache.c
@@ -200,7 +200,6 @@ bool namecache_fetch(const char *name,
 			int *num_names)
 {
 	char *key, *value;
-	time_t timeout;
 
 	/* exit now if null pointers were passed as they're required further */
 	if (!ip_list || !num_names) {
@@ -225,7 +224,7 @@ bool namecache_fetch(const char *name,
 		return False;
 	}
 
-	if (!gencache_get(key, &value, &timeout)) {
+	if (!gencache_get(key, &value, NULL)) {
 		DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
 		SAFE_FREE(key);
 		return False;
@@ -367,7 +366,6 @@ bool namecache_status_fetch(const char *keyname,
 {
 	char *key = NULL;
 	char *value = NULL;
-	time_t timeout;
 
 	if (!gencache_init())
 		return False;
@@ -377,7 +375,7 @@ bool namecache_status_fetch(const char *keyname,
 	if (!key)
 		return False;
 
-	if (!gencache_get(key, &value, &timeout)) {
+	if (!gencache_get(key, &value, NULL)) {
 		DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
 					key));
 		SAFE_FREE(key);
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index 24d7ee1..9b50d20 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -112,7 +112,6 @@ bool saf_delete( const char *domain )
 char *saf_fetch( const char *domain )
 {
 	char *server = NULL;
-	time_t timeout;
 	bool ret = False;
 	char *key = NULL;
 
@@ -126,7 +125,7 @@ char *saf_fetch( const char *domain )
 
 	key = saf_key( domain );
 
-	ret = gencache_get( key, &server, &timeout );
+	ret = gencache_get( key, &server, NULL );
 
 	SAFE_FREE( key );
 
diff --git a/source/libsmb/trustdom_cache.c b/source/libsmb/trustdom_cache.c
index 6755de3..92dde0c 100644
--- a/source/libsmb/trustdom_cache.c
+++ b/source/libsmb/trustdom_cache.c
@@ -164,7 +164,6 @@ bool trustdom_cache_store(char* name, char* alt_name, const DOM_SID *sid,
 bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 {
 	char *key = NULL, *value = NULL;
-	time_t timeout;
 
 	/* init the cache */
 	if (!gencache_init())
@@ -179,7 +178,7 @@ bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 	if (!key)
 		return False;
 	
-	if (!gencache_get(key, &value, &timeout)) {
+	if (!gencache_get(key, &value, NULL)) {
 		DEBUG(5, ("no entry for trusted domain %s found.\n", name));
 		SAFE_FREE(key);
 		return False;
@@ -207,14 +206,13 @@ bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 uint32 trustdom_cache_fetch_timestamp( void )
 {
 	char *value = NULL;
-	time_t timeout;
 	uint32 timestamp;
 
 	/* init the cache */
 	if (!gencache_init()) 
 		return False;
 		
-	if (!gencache_get(TDOMTSKEY, &value, &timeout)) {
+	if (!gencache_get(TDOMTSKEY, &value, NULL)) {
 		DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
 		SAFE_FREE(value);
 		return 0;
diff --git a/source/torture/torture.c b/source/torture/torture.c
index d8add20..98dd900 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -4933,7 +4933,7 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 
-	if (!gencache_get("foo", &val, &tm)) {
+	if (!gencache_get("foo", &val, NULL)) {
 		d_printf("%s: gencache_get() failed\n", __location__);
 		return False;
 	}
@@ -4957,7 +4957,7 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 			
-	if (gencache_get("foo", &val, &tm)) {
+	if (gencache_get("foo", &val, NULL)) {
 		d_printf("%s: gencache_get() on deleted entry "
 			 "succeeded\n", __location__);
 		return False;
diff --git a/source/utils/net_cache.c b/source/utils/net_cache.c
index 4e9ae18..21fcc91 100644
--- a/source/utils/net_cache.c
+++ b/source/utils/net_cache.c
@@ -225,7 +225,8 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv)
 		return -1;
 	}
 
-	if (gencache_get(keystr, &valuestr, &timeout)) {
+	if (gencache_get(keystr, &valuestr, &timeout)
+	    && (timeout > time(NULL))) {
 		print_cache_entry(keystr, valuestr, timeout, NULL);
 		return 0;
 	}
diff --git a/source/winbindd/idmap_ad.c b/source/winbindd/idmap_ad.c
index ca1cf81..1a41f4f 100644
--- a/source/winbindd/idmap_ad.c
+++ b/source/winbindd/idmap_ad.c
@@ -347,7 +347,7 @@ again:
 	if ( u_filter) {
 		filter = talloc_asprintf_append_buffer(filter, "%s))", u_filter);
 		CHECK_ALLOC_DONE(filter);
-			TALLOC_FREE(u_filter);
+		TALLOC_FREE(u_filter);
 	}
 	if ( g_filter) {
 		filter = talloc_asprintf_append_buffer(filter, "%s))", g_filter);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list