summaryrefslogtreecommitdiff
path: root/lib/ldb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-07-08 10:03:38 +1200
committerAndrew Bartlett <abartlet@samba.org>2016-07-19 13:41:11 +0200
commitb5d6f7bef14438fad0352a19feb7e660cff88bfe (patch)
treecf1ee6b1c38421400b39644919161b56f199404f /lib/ldb
parentda66a89bb4a1ef58a10a84f85ad35294605b9896 (diff)
downloadsamba-b5d6f7bef14438fad0352a19feb7e660cff88bfe.tar.gz
ldb: Add better debugging to ldb_wait()
To keep line lengths short, the code is re-factored to the early return pattern. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'lib/ldb')
-rw-r--r--lib/ldb/common/ldb.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
index a824c7a1e27..606725603a0 100644
--- a/lib/ldb/common/ldb.c
+++ b/lib/ldb/common/ldb.c
@@ -596,7 +596,9 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if ((handle->status != LDB_SUCCESS) &&
(handle->ldb->err_string == NULL)) {
/* if no error string was setup by the backend */
- ldb_asprintf_errstring(handle->ldb, "ldb_wait: %s (%d)",
+ ldb_asprintf_errstring(handle->ldb,
+ "ldb_wait from %s with LDB_ASYNC_DONE: %s (%d)",
+ handle->location,
ldb_strerror(handle->status),
handle->status);
}
@@ -614,19 +616,21 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if (ret != 0) {
return ldb_operr(handle->ldb);
}
- if (handle->status != LDB_SUCCESS) {
- if (handle->ldb->err_string == NULL) {
- /*
- * if no error string was setup by the backend
- */
- ldb_asprintf_errstring(handle->ldb,
- "ldb_wait: %s (%d)",
- ldb_strerror(handle->status),
- handle->status);
- }
+ if (handle->status == LDB_SUCCESS) {
+ return LDB_SUCCESS;
+ }
+ if (handle->ldb->err_string != NULL) {
return handle->status;
}
- break;
+ /*
+ * if no error string was setup by the backend
+ */
+ ldb_asprintf_errstring(handle->ldb,
+ "ldb_wait from %s with LDB_WAIT_NONE: %s (%d)",
+ handle->location,
+ ldb_strerror(handle->status),
+ handle->status);
+ return handle->status;
case LDB_WAIT_ALL:
while (handle->state != LDB_ASYNC_DONE) {
@@ -635,32 +639,38 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
return ldb_operr(handle->ldb);
}
if (handle->status != LDB_SUCCESS) {
- if (handle->ldb->err_string == NULL) {
- /*
- * if no error string was setup by the
- * backend
- */
- ldb_asprintf_errstring(handle->ldb,
- "ldb_wait: %s (%d)",
- ldb_strerror(handle->status),
- handle->status);
+ if (handle->ldb->err_string != NULL) {
+ return handle->status;
}
- return handle->status;
- }
- }
- if (handle->status != LDB_SUCCESS) {
- if (handle->ldb->err_string == NULL) {
/*
- * if no error string was setup by the backend
+ * if no error string was setup by the
+ * backend
*/
ldb_asprintf_errstring(handle->ldb,
- "ldb_wait: %s (%d)",
+ "ldb_wait from %s with "
+ "LDB_WAIT_ALL: %s (%d)",
+ handle->location,
ldb_strerror(handle->status),
handle->status);
+ return handle->status;
}
+ }
+ if (handle->status == LDB_SUCCESS) {
+ return LDB_SUCCESS;
+ }
+ if (handle->ldb->err_string != NULL) {
return handle->status;
}
- break;
+ /*
+ * if no error string was setup by the backend
+ */
+ ldb_asprintf_errstring(handle->ldb,
+ "ldb_wait from %s with LDB_WAIT_ALL,"
+ " LDB_ASYNC_DONE: %s (%d)",
+ handle->location,
+ ldb_strerror(handle->status),
+ handle->status);
+ return handle->status;
}
return LDB_SUCCESS;