[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Aug 9 05:52:02 MDT 2012


The branch, master has been updated
       via  11d60d1 s4-ldb_wrap: Do not vasprintf() the ldb debug messages that will not be shown
       via  73f0cb5 lib/ldb: Do not vasprintf() the tevent debug messages that will not be shown
       via  7e562cf s4-events: Do not vasprintf() the tevent debug messages that will not be shown
       via  434bed7 s3-events: Do not vasprintf() the tevent debug messages that will not be shown
       via  299fc75 lib/ldb: Use tdb_exists() rather than tdb_fetch()/talloc_free()
      from  d799b25 s4-dsdb: Remove strcasecmp() fallback in replmd_ldb_message_element_attid_sort

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


- Log -----------------------------------------------------------------
commit 11d60d13dc54ff154b2a7bb53e326ed2180d473c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 19:41:05 2012 +1000

    s4-ldb_wrap: Do not vasprintf() the ldb debug messages that will not be shown
    
    This malloc() and free() actually shows up quite high on a call profile of
    provision of the AD DC.
    
    Andrew Bartlett
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Aug  9 13:51:06 CEST 2012 on sn-devel-104

commit 73f0cb5278e714740d0de75e6b0d0bf4c815491a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 19:40:45 2012 +1000

    lib/ldb: Do not vasprintf() the tevent debug messages that will not be shown
    
    This malloc() and free() actually shows up quite high on a call profile of
    provision of the AD DC.
    
    This allows the debug handler to decide if the argument list should be
    printed.
    
    Andrew Bartlett

commit 7e562cf3eb8d8aabf9b5d62a92e67221e4f07e3a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 18:34:48 2012 +1000

    s4-events: Do not vasprintf() the tevent debug messages that will not be shown
    
    This malloc() and free() actually shows up quite high on a call profile of
    provision of the AD DC.
    
    Andrew Bartlett

commit 434bed75c43d3d7854bd9433913448810d3ff511
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 18:34:28 2012 +1000

    s3-events: Do not vasprintf() the tevent debug messages that will not be shown
    
    This malloc() and free() actually shows up quite high on a call profile of
    provision of the AD DC (and this is the matching patch for source3).
    
    Andrew Bartlett

commit 299fc7522858e2d7ee6c54310a4e157c8142c74f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 9 19:58:31 2012 +1000

    lib/ldb: Use tdb_exists() rather than tdb_fetch()/talloc_free()
    
    This avoids pulling the record and doing an allocation when we just
    want to know if it exists.
    
    Andrew Bartlett

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

Summary of changes:
 lib/ldb-samba/ldb_wrap.c                           |   12 +++++++-----
 lib/ldb/ABI/{ldb-1.1.6.sigs => ldb-1.1.10.sigs}    |    1 +
 ...yldb-util-1.1.2.sigs => pyldb-util-1.1.10.sigs} |    0
 lib/ldb/common/ldb.c                               |    9 ++++-----
 lib/ldb/common/ldb_debug.c                         |   16 ++++++++++++----
 lib/ldb/include/ldb_module.h                       |    1 +
 lib/ldb/ldb_tdb/ldb_search.c                       |   14 +++++++-------
 lib/ldb/wscript                                    |    2 +-
 source3/lib/events.c                               |   10 ++++++----
 source4/lib/events/tevent_s4.c                     |   10 ++++++----
 10 files changed, 45 insertions(+), 30 deletions(-)
 copy lib/ldb/ABI/{ldb-1.1.6.sigs => ldb-1.1.10.sigs} (99%)
 copy lib/ldb/ABI/{pyldb-util-1.1.2.sigs => pyldb-util-1.1.10.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/ldb-samba/ldb_wrap.c b/lib/ldb-samba/ldb_wrap.c
index 83a0674..028bd6f 100644
--- a/lib/ldb-samba/ldb_wrap.c
+++ b/lib/ldb-samba/ldb_wrap.c
@@ -47,7 +47,6 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
 			   const char *fmt, va_list ap)
 {
 	int samba_level = -1;
-	char *s = NULL;
 	switch (level) {
 	case LDB_DEBUG_FATAL:
 		samba_level = 0;
@@ -63,10 +62,13 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
 		break;
 
 	};
-	vasprintf(&s, fmt, ap);
-	if (!s) return;
-	DEBUG(samba_level, ("ldb: %s\n", s));
-	free(s);
+	if (CHECK_DEBUGLVL(samba_level)) {
+		char *s = NULL;
+		vasprintf(&s, fmt, ap);
+		if (!s) return;
+		DEBUG(samba_level, ("ldb: %s\n", s));
+		free(s);
+	}
 }
 
 
diff --git a/lib/ldb/ABI/ldb-1.1.6.sigs b/lib/ldb/ABI/ldb-1.1.10.sigs
similarity index 99%
copy from lib/ldb/ABI/ldb-1.1.6.sigs
copy to lib/ldb/ABI/ldb-1.1.10.sigs
index f90fa13..de5026e 100644
--- a/lib/ldb/ABI/ldb-1.1.6.sigs
+++ b/lib/ldb/ABI/ldb-1.1.10.sigs
@@ -255,4 +255,5 @@ ldb_val_map_remote: struct ldb_val (struct ldb_module *, void *, const struct ld
 ldb_val_string_cmp: int (const struct ldb_val *, const char *)
 ldb_val_to_time: int (const struct ldb_val *, time_t *)
 ldb_valid_attr_name: int (const char *)
+ldb_vdebug: void (struct ldb_context *, enum ldb_debug_level, const char *, va_list)
 ldb_wait: int (struct ldb_handle *, enum ldb_wait_type)
diff --git a/lib/ldb/ABI/pyldb-util-1.1.2.sigs b/lib/ldb/ABI/pyldb-util-1.1.10.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-1.1.2.sigs
copy to lib/ldb/ABI/pyldb-util-1.1.10.sigs
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
index 779bed8..887a896 100644
--- a/lib/ldb/common/ldb.c
+++ b/lib/ldb/common/ldb.c
@@ -60,7 +60,6 @@ static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
 {
 	struct ldb_context *ldb = talloc_get_type(context, struct ldb_context);
 	enum ldb_debug_level ldb_level = LDB_DEBUG_FATAL;
-	char *s = NULL;
 
 	switch (level) {
 	case TEVENT_DEBUG_FATAL:
@@ -77,10 +76,10 @@ static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
 		break;
 	};
 
-	vasprintf(&s, fmt, ap);
-	if (!s) return;
-	ldb_debug(ldb, ldb_level, "tevent: %s", s);
-	free(s);
+	/* There isn't a tevent: prefix here because to add it means
+	 * actually printing the string, and most of the time we don't
+	 * want to show it */
+	ldb_vdebug(ldb, ldb_level, fmt, ap);
 }
 
 /*
diff --git a/lib/ldb/common/ldb_debug.c b/lib/ldb/common/ldb_debug.c
index 6aa58cc..d5e9e7a 100644
--- a/lib/ldb/common/ldb_debug.c
+++ b/lib/ldb/common/ldb_debug.c
@@ -79,11 +79,10 @@ int ldb_set_debug_stderr(struct ldb_context *ldb)
 }
 
 /*
-  log a message
+  log a message (va_list helper for ldb_tevent_debug)
 */
-void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...)
+void ldb_vdebug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, va_list ap)
 {
-	va_list ap;
 	if (ldb->debug_ops.debug == NULL) {
 		if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
 			ldb_set_debug(ldb, ldb_debug_stderr_all, ldb);
@@ -91,8 +90,17 @@ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *
 			ldb_set_debug_stderr(ldb);
 		}
 	}
-	va_start(ap, fmt);
 	ldb->debug_ops.debug(ldb->debug_ops.context, level, fmt, ap);
+}
+
+/*
+  log a message
+*/
+void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	ldb_vdebug(ldb, level, fmt, ap);
 	va_end(ap);
 }
 
diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h
index 389e8ce..6e14f4c 100644
--- a/lib/ldb/include/ldb_module.h
+++ b/lib/ldb/include/ldb_module.h
@@ -83,6 +83,7 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
 		   const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
 void ldb_debug_add(struct ldb_context *ldb, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
 void ldb_debug_end(struct ldb_context *ldb, enum ldb_debug_level level);
+void ldb_vdebug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0);
 
 #define ldb_error(ldb, ecode, reason) ldb_error_at(ldb, ecode, reason, __FILE__, __LINE__)
 #define ldb_module_error(module, ecode, reason) ldb_error_at(ldb_module_get_ctx(module), ecode, reason, __FILE__, __LINE__)
diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c
index 5e20500..e631f7b 100644
--- a/lib/ldb/ldb_tdb/ldb_search.c
+++ b/lib/ldb/ldb_tdb/ldb_search.c
@@ -212,7 +212,8 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
 {
 	void *data = ldb_module_get_private(module);
 	struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
-	TDB_DATA tdb_key, tdb_data;
+	TDB_DATA tdb_key;
+	int exists;
 
 	if (ldb_dn_is_null(dn)) {
 		return LDB_ERR_NO_SUCH_OBJECT;
@@ -224,14 +225,13 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
-	tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
+	exists = tdb_exists(ltdb->tdb, tdb_key);
 	talloc_free(tdb_key.dptr);
-	if (!tdb_data.dptr) {
-		return LDB_ERR_NO_SUCH_OBJECT;
+		
+	if (exists) {
+		return LDB_SUCCESS;
 	}
-	
-	free(tdb_data.dptr);
-	return LDB_SUCCESS;
+	return LDB_ERR_NO_SUCH_OBJECT;
 }
 
 /*
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 2971842..611eebf 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'ldb'
-VERSION = '1.1.9'
+VERSION = '1.1.10'
 
 blddir = 'bin'
 
diff --git a/source3/lib/events.c b/source3/lib/events.c
index 72fd40e..cafe598 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -434,11 +434,13 @@ static void s3_event_debug(void *context, enum tevent_debug_level level,
 		break;
 
 	};
-	if (vasprintf(&s, fmt, ap) == -1) {
-		return;
+	if (CHECK_DEBUGLVL(samba_level)) {
+		if (vasprintf(&s, fmt, ap) == -1) {
+			return;
+		}
+		DEBUG(samba_level, ("s3_event: %s", s));
+		free(s);
 	}
-	DEBUG(samba_level, ("s3_event: %s", s));
-	free(s);
 }
 
 struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx)
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c
index 469ed72..6770dd0 100644
--- a/source4/lib/events/tevent_s4.c
+++ b/source4/lib/events/tevent_s4.c
@@ -46,10 +46,12 @@ static void ev_wrap_debug(void *context, enum tevent_debug_level level,
 		break;
 
 	};
-	vasprintf(&s, fmt, ap);
-	if (!s) return;
-	DEBUG(samba_level, ("tevent: %s", s));
-	free(s);
+	if (CHECK_DEBUGLVL(samba_level)) {
+		vasprintf(&s, fmt, ap);
+		if (!s) return;
+		DEBUG(samba_level, ("tevent: %s", s));
+		free(s);
+	}
 }
 
 /*


-- 
Samba Shared Repository


More information about the samba-cvs mailing list