]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dbwrap: Clarify db_open_watched API
authorVolker Lendecke <vl@samba.org>
Thu, 16 Aug 2018 09:25:54 +0000 (11:25 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 17 Aug 2018 19:29:15 +0000 (21:29 +0200)
Point out in the API that "backend" talloc_moves into the watched
database.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Aug 17 21:29:15 CEST 2018 on sn-devel-144

source3/lib/dbwrap/dbwrap_watch.c
source3/lib/dbwrap/dbwrap_watch.h
source3/lib/g_lock.c
source3/locking/share_mode_lock.c
source3/smbd/smbXsrv_session.c
source3/torture/test_dbwrap_do_locked.c
source3/torture/test_dbwrap_watch.c

index 3e91f46b428d93e9eaf8c998fe4ed3904b029686..45e17958b9263325a745fce56e6014dcf073b45b 100644 (file)
@@ -738,7 +738,7 @@ static size_t dbwrap_watched_id(struct db_context *db, uint8_t *id,
 }
 
 struct db_context *db_open_watched(TALLOC_CTX *mem_ctx,
-                                  struct db_context *backend,
+                                  struct db_context **backend,
                                   struct messaging_context *msg)
 {
        struct db_context *db;
@@ -757,9 +757,9 @@ struct db_context *db_open_watched(TALLOC_CTX *mem_ctx,
 
        ctx->msg = msg;
 
-       db->lock_order = backend->lock_order;
-       backend->lock_order = DBWRAP_LOCK_ORDER_NONE;
-       ctx->backend = talloc_move(ctx, &backend);
+       ctx->backend = talloc_move(ctx, backend);
+       db->lock_order = ctx->backend->lock_order;
+       ctx->backend->lock_order = DBWRAP_LOCK_ORDER_NONE;
 
        db->fetch_locked = dbwrap_watched_fetch_locked;
        db->do_locked = dbwrap_watched_do_locked;
index e94378f2d5ae6dc5c9cc33f57525cf2480d96c19..a836ca48e8aa6e5a39427d017212df8e194bb77d 100644 (file)
@@ -25,7 +25,7 @@
 #include "messages.h"
 
 struct db_context *db_open_watched(TALLOC_CTX *mem_ctx,
-                                  struct db_context *backend,
+                                  struct db_context **backend,
                                   struct messaging_context *msg);
 struct tevent_req *dbwrap_watched_watch_send(TALLOC_CTX *mem_ctx,
                                             struct tevent_context *ev,
index 96e5612529d519f59d1256a55a1bd8a9e54cce95..d8298b6ee33a62e6deed69db721f02a6815a947a 100644 (file)
@@ -172,7 +172,7 @@ struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       result->db = db_open_watched(result, backend, msg);
+       result->db = db_open_watched(result, &backend, msg);
        if (result->db == NULL) {
                DBG_WARNING("db_open_watched failed\n");
                TALLOC_FREE(result);
index 49d4a7c5aeceb9b3c1d0e32c99b1c2912513a97b..0bf7b9db90a874ae4239088669b7946dbc7bc496 100644 (file)
@@ -86,7 +86,7 @@ static bool locking_init_internal(bool read_only)
                return False;
        }
 
-       lock_db = db_open_watched(NULL, backend, server_messaging_context());
+       lock_db = db_open_watched(NULL, &backend, server_messaging_context());
        if (lock_db == NULL) {
                DBG_ERR("db_open_watched failed\n");
                TALLOC_FREE(backend);
index 557a43f2f8c38882c02f63f74244826c65e56722..af47f4aa8c3c17a832cae8a4092a2e8d797353e6 100644 (file)
@@ -89,7 +89,7 @@ NTSTATUS smbXsrv_session_global_init(struct messaging_context *msg_ctx)
                return status;
        }
 
-       db_ctx = db_open_watched(NULL, backend, server_messaging_context());
+       db_ctx = db_open_watched(NULL, &backend, server_messaging_context());
        if (db_ctx == NULL) {
                TALLOC_FREE(backend);
                return NT_STATUS_NO_MEMORY;
index 46b326bf16354e124bbd1bc14b9d9f9d043caf35..2e5305d4d75397b825a4ca305d6b398e8fa9f1b2 100644 (file)
@@ -97,7 +97,7 @@ bool run_dbwrap_do_locked1(int dummy)
                return false;
        }
 
-       db = db_open_watched(talloc_tos(), backend, msg);
+       db = db_open_watched(talloc_tos(), &backend, msg);
        if (db == NULL) {
                fprintf(stderr, "db_open_watched failed: %s\n",
                        strerror(errno));
index 97d5ea6393c353468ec063dcd0252efbbce3b8ee..5ef6b105ca2ae229069e8ae663c50cdcd473e4ca 100644 (file)
@@ -56,7 +56,7 @@ bool run_dbwrap_watch1(int dummy)
                goto fail;
        }
 
-       db = db_open_watched(ev, backend, msg);
+       db = db_open_watched(ev, &backend, msg);
 
        rec = dbwrap_fetch_locked(db, db, key);
        if (rec == NULL) {
@@ -153,7 +153,7 @@ bool run_dbwrap_watch2(int dummy)
                goto fail;
        }
 
-       db = db_open_watched(ev, backend, msg);
+       db = db_open_watched(ev, &backend, msg);
        if (db == NULL) {
                fprintf(stderr, "db_open_watched failed\n");
                goto fail;