[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sun Feb 28 09:41:26 MST 2010


The branch, master has been updated
       via  fb98f60... tdb: If tdb_parse_record does not find a record, return -1 instead of 0
      from  0e9882a... s3: Fix but 7145 -- duplicate sam and unix accounts

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fb98f60594b6cabc52d0f2f49eda08f793ba4748
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 27 19:26:01 2010 +0100

    tdb: If tdb_parse_record does not find a record, return -1 instead of 0

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

Summary of changes:
 lib/tdb/common/tdb.c |    5 ++++-
 lib/tdb/docs/README  |   19 +++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 7317a3a..953c811 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -222,6 +222,8 @@ TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key)
  *
  * This is interesting for all readers of potentially large data structures in
  * the tdb records, ldb indexes being one example.
+ *
+ * Return -1 if the record was not found.
  */
 
 int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
@@ -238,9 +240,10 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
 	hash = tdb->hash_fn(&key);
 
 	if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) {
+		/* record not found */
 		tdb_trace_1rec_ret(tdb, "tdb_parse_record", key, -1);
 		tdb->ecode = TDB_ERR_NOEXIST;
-		return 0;
+		return -1;
 	}
 	tdb_trace_1rec_ret(tdb, "tdb_parse_record", key, 0);
 
diff --git a/lib/tdb/docs/README b/lib/tdb/docs/README
index c02ee0e..fe0e258 100644
--- a/lib/tdb/docs/README
+++ b/lib/tdb/docs/README
@@ -105,6 +105,25 @@ TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
    caller must free the resulting data
 
 ----------------------------------------------------------------------
+int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
+		     int (*parser)(TDB_DATA key, TDB_DATA data,
+				   void *private_data),
+		     void *private_data);
+
+   Hand a record to a parser function without allocating it.
+
+   This function is meant as a fast tdb_fetch alternative for large records
+   that are frequently read. The "key" and "data" arguments point directly
+   into the tdb shared memory, they are not aligned at any boundary.
+
+   WARNING: The parser is called while tdb holds a lock on the record. DO NOT
+   call other tdb routines from within the parser. Also, for good performance
+   you should make the parser fast to allow parallel operations.
+
+   tdb_parse_record returns -1 if the record was not found.  If the record was
+   found, the return value of "parser" is passed up to the caller.
+
+----------------------------------------------------------------------
 int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);
 
    check if an entry in the database exists 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list