]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Add better debugging to ldb_wait()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 7 Jul 2016 22:03:38 +0000 (10:03 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 Jul 2016 11:41:11 +0000 (13:41 +0200)
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>
lib/ldb/common/ldb.c

index a824c7a1e27fb3a7455d58eb0ecd425c3d1e9cb4..606725603a0599bd8afc92d28fe2d6f9d2603e0a 100644 (file)
@@ -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;