[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Dec 8 08:40:02 MST 2011


The branch, master has been updated
       via  664eb70 s3-dbwrap: & is not required when taking a function pointer
       via  4856033 s3-dbwrap: Make dbwrap_fallback_wipe private
       via  d9e5368 s3-dbwrap: Avoid an "else" by an early return
       via  5cda77d s3-dbwrap: Make dbwrap_fallback_parse_record private
       via  527dc2e s3-dbwrap: Make dbwrap_fallback_fetch private
       via  b6d5dfc s3-dbwrap: use wrappers where appropriate
       via  883419a s3-dbwrap: Use simpler code for logging keys
       via  14d3889 s3: Fix some 64-bit warnings
       via  4552c28 s3: Fix some blank line endings
      from  6316335 s3: Fix typos

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


- Log -----------------------------------------------------------------
commit 664eb70e746428f765cd7aded06d36c5363a2ed8
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 14:02:27 2011 +0100

    s3-dbwrap: & is not required when taking a function pointer
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Thu Dec  8 16:39:29 CET 2011 on sn-devel-104

commit 4856033410db98b44d76e82f649634e13eba221f
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 14:01:27 2011 +0100

    s3-dbwrap: Make dbwrap_fallback_wipe private

commit d9e5368fcccf02164c2bdc0fc679b71e7cfa510f
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 13:59:33 2011 +0100

    s3-dbwrap: Avoid an "else" by an early return

commit 5cda77d5996acb26648fbb0231ddc8b20e626cc0
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 13:58:19 2011 +0100

    s3-dbwrap: Make dbwrap_fallback_parse_record private
    
    We have the private fallback in dbwrap_parse_record anyway

commit 527dc2ed52c78b1ae114207736883759638db5d1
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 13:56:07 2011 +0100

    s3-dbwrap: Make dbwrap_fallback_fetch private

commit b6d5dfc16db83790e833397ee35ea28711b8cec8
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 8 13:51:19 2011 +0100

    s3-dbwrap: use wrappers where appropriate

commit 883419a50b9c0c6e0b5644f7f1147ddf24627458
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Dec 7 14:50:54 2011 +0100

    s3-dbwrap: Use simpler code for logging keys

commit 14d388928501f9cc56cef04375fdb08e052fd44a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Dec 2 15:03:05 2011 +0100

    s3: Fix some 64-bit warnings

commit 4552c28d6db35d1d0b8dfdb145235eef629fbf35
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Dec 5 10:49:48 2011 +0100

    s3: Fix some blank line endings

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

Summary of changes:
 source3/lib/dbwrap/dbwrap.c         |   48 ++++++++++++++++++--------------
 source3/lib/dbwrap/dbwrap_open.c    |   17 ++---------
 source3/lib/dbwrap/dbwrap_private.h |   12 --------
 source3/lib/dbwrap/dbwrap_tdb.c     |   51 +++++++++++++++++++---------------
 source3/lib/dbwrap/dbwrap_util.c    |    6 ++--
 source3/smbd/oplock.c               |   20 ++++++++-----
 6 files changed, 73 insertions(+), 81 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c
index 7d96926..83c02f5 100644
--- a/source3/lib/dbwrap/dbwrap.c
+++ b/source3/lib/dbwrap/dbwrap.c
@@ -28,12 +28,13 @@
  * Fall back using fetch_locked if no genuine fetch operation is provided
  */
 
-NTSTATUS dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
-			       TDB_DATA key, TDB_DATA *data)
+static NTSTATUS dbwrap_fallback_fetch(struct db_context *db,
+				      TALLOC_CTX *mem_ctx,
+				      TDB_DATA key, TDB_DATA *data)
 {
 	struct db_record *rec;
 
-	rec = db->fetch_locked(db, mem_ctx, key);
+	rec = dbwrap_fetch_locked(db, mem_ctx, key);
 	if (rec == NULL) {
 		return NT_STATUS_UNSUCCESSFUL;
 	}
@@ -58,17 +59,17 @@ static int dbwrap_fallback_exists(struct db_context *db, TDB_DATA key)
  * Fall back using fetch if no genuine parse operation is provided
  */
 
-int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
-				 int (*parser)(TDB_DATA key,
-					       TDB_DATA data,
-					       void *private_data),
-				 void *private_data)
+static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
+					int (*parser)(TDB_DATA key,
+						      TDB_DATA data,
+						      void *private_data),
+					void *private_data)
 {
 	TDB_DATA data;
 	int res;
 	NTSTATUS status;
 
-	status = db->fetch(db, talloc_tos(), key, &data);
+	status = dbwrap_fetch(db, talloc_tos(), key, &data);
 	if (!NT_STATUS_IS_OK(status)) {
 		return -1;
 	}
@@ -81,7 +82,7 @@ int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
 
 static int delete_record(struct db_record *rec, void *data)
 {
-	NTSTATUS status = rec->delete_rec(rec);
+	NTSTATUS status = dbwrap_record_delete(rec);
 	return NT_STATUS_IS_OK(status) ? 0 : -1;
 }
 
@@ -89,9 +90,9 @@ static int delete_record(struct db_record *rec, void *data)
  * Fallback wipe ipmlementation using traverse and delete if no genuine
  * wipe operation is provided
  */
-int dbwrap_fallback_wipe(struct db_context *db)
+static int dbwrap_fallback_wipe(struct db_context *db)
 {
-	NTSTATUS status = dbwrap_trans_traverse(db, &delete_record, NULL);
+	NTSTATUS status = dbwrap_trans_traverse(db, delete_record, NULL);
 	return NT_STATUS_IS_OK(status) ? 0 : -1;
 }
 
@@ -133,7 +134,9 @@ NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
 	if (value == NULL) {
 		return NT_STATUS_INVALID_PARAMETER;
 	}
-
+	if (db->fetch == NULL) {
+		return dbwrap_fallback_fetch(db, mem_ctx, key, value);
+	}
 	return db->fetch(db, mem_ctx, key, value);
 }
 
@@ -154,12 +157,12 @@ NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key,
 	struct db_record *rec;
 	NTSTATUS status;
 
-	rec = db->fetch_locked(db, talloc_tos(), key);
+	rec = dbwrap_fetch_locked(db, talloc_tos(), key);
 	if (rec == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	status = rec->store(rec, data, flags);
+	status = dbwrap_record_store(rec, data, flags);
 	TALLOC_FREE(rec);
 	return status;
 }
@@ -169,11 +172,11 @@ NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key)
 	struct db_record *rec;
 	NTSTATUS status;
 
-	rec = db->fetch_locked(db, talloc_tos(), key);
+	rec = dbwrap_fetch_locked(db, talloc_tos(), key);
 	if (rec == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
-	status = rec->delete_rec(rec);
+	status = dbwrap_record_delete(rec);
 	TALLOC_FREE(rec);
 	return status;
 }
@@ -228,15 +231,18 @@ int dbwrap_parse_record(struct db_context *db, TDB_DATA key,
 		parser = dbwrap_null_parser;
 	}
 
-	if (db->parse_record) {
-		return db->parse_record(db, key, parser, private_data);
-	} else {
-		return dbwrap_fallback_parse_record(db, key, parser, private_data);
+	if (db->parse_record == NULL) {
+		return dbwrap_fallback_parse_record(db, key, parser,
+						    private_data);
 	}
+	return db->parse_record(db, key, parser, private_data);
 }
 
 int dbwrap_wipe(struct db_context *db)
 {
+	if (db->wipe == NULL) {
+		return dbwrap_fallback_wipe(db);
+	}
 	return db->wipe(db);
 }
 
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index ef500e1..6b8be2d 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Database interface wrapper
 
@@ -8,12 +8,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -109,16 +109,5 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
 		result = db_open_tdb(mem_ctx, name, hash_size,
 				     tdb_flags, open_flags, mode);
 	}
-
-	if ((result != NULL) && (result->fetch == NULL)) {
-		result->fetch = dbwrap_fallback_fetch;
-	}
-	if ((result != NULL) && (result->parse_record == NULL)) {
-		result->parse_record = dbwrap_fallback_parse_record;
-	}
-	if ((result != NULL) && (result->wipe == NULL)) {
-		result->wipe = dbwrap_fallback_wipe;
-	}
-
 	return result;
 }
diff --git a/source3/lib/dbwrap/dbwrap_private.h b/source3/lib/dbwrap/dbwrap_private.h
index e7bd480..1491a13 100644
--- a/source3/lib/dbwrap/dbwrap_private.h
+++ b/source3/lib/dbwrap/dbwrap_private.h
@@ -59,17 +59,5 @@ struct db_context {
 	bool persistent;
 };
 
-NTSTATUS dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
-			       TDB_DATA key, TDB_DATA *data);
-
-
-int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
-				 int (*parser)(TDB_DATA key,
-					       TDB_DATA data,
-					       void *private_data),
-				 void *private_data);
-
-int dbwrap_fallback_wipe(struct db_context *db);
-
 #endif /* __DBWRAP_PRIVATE_H__ */
 
diff --git a/source3/lib/dbwrap/dbwrap_tdb.c b/source3/lib/dbwrap/dbwrap_tdb.c
index ffdb906..6a4636a 100644
--- a/source3/lib/dbwrap/dbwrap_tdb.c
+++ b/source3/lib/dbwrap/dbwrap_tdb.c
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Database interface wrapper around tdb
    Copyright (C) Volker Lendecke 2005-2007
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -32,21 +32,33 @@ struct db_tdb_ctx {
 static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag);
 static NTSTATUS db_tdb_delete(struct db_record *rec);
 
+static void db_tdb_log_key(const char *prefix, TDB_DATA key)
+{
+	size_t len;
+	char *keystr;
+
+	if (DEBUGLEVEL < 10) {
+		return;
+	}
+	len = key.dsize;
+	if (DEBUGLEVEL == 10) {
+		/*
+		 * Only fully spam at debuglevel > 10
+		 */
+		len = MIN(10, key.dsize);
+	}
+	keystr = hex_encode_talloc(talloc_tos(), (unsigned char *)(key.dptr),
+				   len);
+	DEBUG(10, ("%s key %s\n", prefix, keystr));
+	TALLOC_FREE(keystr);
+}
+
 static int db_tdb_record_destr(struct db_record* data)
 {
 	struct db_tdb_ctx *ctx =
 		talloc_get_type_abort(data->private_data, struct db_tdb_ctx);
 
-	/* This hex_encode_talloc() call allocates memory on data context. By way how current 
-	   __talloc_free() code works, it is OK to allocate in the destructor as 
-	   the children of data will be freed after call to the destructor and this 
-	   new 'child' will be caught and freed correctly.
-	 */
-	DEBUG(10, (DEBUGLEVEL > 10
-		   ? "Unlocking key %s\n" : "Unlocking key %.20s\n",
-		   hex_encode_talloc(data, (unsigned char *)data->key.dptr,
-			      data->key.dsize)));
-
+	db_tdb_log_key("Unlocking", data->key);
 	tdb_chainunlock(ctx->wtdb->tdb, data->key);
 	return 0;
 }
@@ -95,14 +107,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
 						       struct db_tdb_ctx);
 	struct tdb_fetch_locked_state state;
 
-	/* Do not accidently allocate/deallocate w/o need when debug level is lower than needed */
-	if(DEBUGLEVEL >= 10) {
-		char *keystr = hex_encode_talloc(talloc_tos(), (unsigned char*)key.dptr, key.dsize);
-		DEBUG(10, (DEBUGLEVEL > 10
-			   ? "Locking key %s\n" : "Locking key %.20s\n",
-			   keystr));
-		TALLOC_FREE(keystr);
-	}
+	db_tdb_log_key("Locking", key);
 
 	if (tdb_chainlock(ctx->wtdb->tdb, key) != 0) {
 		DEBUG(3, ("tdb_chainlock failed\n"));
@@ -376,7 +381,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
 	struct db_context *result = NULL;
 	struct db_tdb_ctx *db_tdb;
 	struct loadparm_context *lp_ctx;
-	
+
 	result = talloc_zero(mem_ctx, struct db_context);
 	if (result == NULL) {
 		DEBUG(0, ("talloc failed\n"));
diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c
index 48bd9bb..3c224fe 100644
--- a/source3/lib/dbwrap/dbwrap_util.c
+++ b/source3/lib/dbwrap/dbwrap_util.c
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Utility functions for the dbwrap API
    Copyright (C) Volker Lendecke 2007
@@ -11,12 +11,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 1bf957d..2d3ce5f 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -460,8 +460,9 @@ void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx
 	message_to_share_mode_entry(&msg, (char *)data->data);
 
 	DEBUG(10, ("Got oplock async level 2 break message from pid %s: "
-		   "%s/%lu\n", server_id_str(talloc_tos(), &src),
-		   file_id_string_tos(&msg.id), msg.share_file_id));
+		   "%s/%llu\n", server_id_str(talloc_tos(), &src),
+		   file_id_string_tos(&msg.id),
+		   (unsigned long long)msg.share_file_id));
 
 	fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
 
@@ -510,9 +511,10 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
 	/* De-linearize incoming message. */
 	message_to_share_mode_entry(&msg, (char *)data->data);
 
-	DEBUG(10, ("Got oplock break message from pid %s: %s/%lu\n",
-		   server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
-		   msg.share_file_id));
+	DEBUG(10, ("Got oplock break message from pid %s: %s/%llu\n",
+		   server_id_str(talloc_tos(), &src),
+		   file_id_string_tos(&msg.id),
+		   (unsigned long long)msg.share_file_id));
 
 	fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
 
@@ -705,9 +707,11 @@ static void process_oplock_break_response(struct messaging_context *msg_ctx,
 	/* De-linearize incoming message. */
 	message_to_share_mode_entry(&msg, (char *)data->data);
 
-	DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %llu\n",
-		   server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
-		   msg.share_file_id, (unsigned long long)msg.op_mid));
+	DEBUG(10, ("Got oplock break response from pid %s: %s/%llu mid %llu\n",
+		   server_id_str(talloc_tos(), &src),
+		   file_id_string_tos(&msg.id),
+		   (unsigned long long)msg.share_file_id,
+		   (unsigned long long)msg.op_mid));
 
 	sconn = msg_ctx_to_sconn(msg_ctx);
 	if (sconn != NULL) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list