[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Tue May 17 14:55:03 UTC 2016


The branch, master has been updated
       via  404acae dbwrap_ctdb: Remove get_my_vnn dependency
       via  1dcdd86 dbwrap_ctdb: Fix some 32-bit hickups
       via  3bd368b ctdbd_conn: Remove messages.h dependency
       via  46be182 dbwrap: Add "msg_ctx" to db_open_ctdb
       via  3fe3226 dbwrap_ctdb: Pass in ctdbd_connection
       via  0a367f5 dbwrap_ctdb: Add "conn" to db_ctdb_ctx
       via  e3fcf90 dbwrap_ctdb: Align loop index with terminator
       via  069d79b lib: Move async message handling out of ctdbd_conn
       via  33c8861 ctdbd_conn: Expose ctdb socket readability handler
       via  120f867 ctdbd_conn: "sockname" is not needed anymore
       via  0b8896d ctdbd_conn: Simplify two DEBUGs
       via  a1309d5 ctdbd_conn: remove ctdb_processes_exist
      from  b3b2fee python/tests/dns_forwarder: fix for python 2.6

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


- Log -----------------------------------------------------------------
commit 404acae05c9fa8a537e3dbf6480caa266940ec0a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 16:31:25 2016 +0200

    dbwrap_ctdb: Remove get_my_vnn dependency
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Tue May 17 16:54:36 CEST 2016 on sn-devel-144

commit 1dcdd862e58bb23927a9778166c1d91db513532a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 16:07:12 2016 +0200

    dbwrap_ctdb: Fix some 32-bit hickups
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3bd368b12dc5b4bd6500a4bb49f2d9d536580d59
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 24 17:39:44 2016 +0200

    ctdbd_conn: Remove messages.h dependency
    
    This removes a circular dependency
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 46be182ccb931d689f85b0a5ef6e25cb886b59ce
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 24 17:37:07 2016 +0200

    dbwrap: Add "msg_ctx" to db_open_ctdb
    
    Another step towards making ctdbd_conn.c independent of messages.c. No call to
    ctdb_conn_msg_ctx() anymore
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3fe3226daa8488e0fa787c40359c3401b6f05fc0
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 16:20:32 2016 +0200

    dbwrap_ctdb: Pass in ctdbd_connection
    
    This removes one circular dependency of dbwrap_ctdb to messages.c: No call to
    messaging_ctdbd_connection() anymore from dbwrap_ctdb.c.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0a367f5fd4b0fa1971052bc6c88ab511b03716e2
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 16:01:07 2016 +0200

    dbwrap_ctdb: Add "conn" to db_ctdb_ctx
    
    This minimizes the use of messaging_ctdbd_connection() to
    db_open_ctx(). Next step will move this into db_open().
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit e3fcf90f1553ca0d27d42225d1924664c4d8901e
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 15:45:49 2016 +0200

    dbwrap_ctdb: Align loop index with terminator
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 069d79bbd9ad3f37e9b1a89372301179f726300d
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 24 17:37:33 2016 +0200

    lib: Move async message handling out of ctdbd_conn
    
    messages_ctdbd.c is the code that is genuinely interested in
    async messages from ctdb, so let it take care of them.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 33c8861fc5ed828fe8e1d5b752f09a0c0ea4cc55
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 24 17:36:00 2016 +0200

    ctdbd_conn: Expose ctdb socket readability handler
    
    This will obsolete ctdbd_register_msg_ctx soon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 120f86755abd4919ae7a27de6071878d72fe279b
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 19 21:40:40 2016 +0200

    ctdbd_conn: "sockname" is not needed anymore
    
    Previously it was used in ctdb_traverse(), but with ff72a8a this is no longer
    the case
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0b8896d51e1db5543048d2ccd02d45c7b17ab12c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 19 16:02:49 2016 +0200

    ctdbd_conn: Simplify two DEBUGs
    
    msg->hdr.length is a uint32 and we have PRIu32
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a1309d53215c83688bea14c9c4b39e547c186ba4
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 17:15:29 2016 +0200

    ctdbd_conn: remove ctdb_processes_exist
    
    The singular call was the only user. Remove the complex plural one. We can
    always dig it up from git history if we need it.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 source3/include/ctdbd_conn.h       |   9 +-
 source3/lib/ctdb_dummy.c           |   9 +-
 source3/lib/ctdbd_conn.c           | 194 +++----------------------------------
 source3/lib/dbwrap/dbwrap_ctdb.c   |  68 ++++++-------
 source3/lib/dbwrap/dbwrap_ctdb.h   |   3 +
 source3/lib/dbwrap/dbwrap_open.c   |  15 ++-
 source3/lib/messages_ctdbd.c       |  38 +++++---
 source3/torture/test_dbwrap_ctdb.c |  15 ++-
 8 files changed, 108 insertions(+), 243 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index c91f700..11e71ba 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -36,12 +36,8 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 
 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
 
-int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
-			   struct messaging_context *msg_ctx,
-			   struct tevent_context *ev);
-struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);
-
 int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
+void ctdbd_socket_readable(struct ctdbd_connection *conn);
 
 int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
 			     uint32_t dst_vnn, uint64_t dst_srvid,
@@ -49,9 +45,6 @@ int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
 
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
 			  pid_t pid);
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, int num_pids,
-			  bool *results);
 
 char *ctdbd_dbpath(struct ctdbd_connection *conn,
 		   TALLOC_CTX *mem_ctx, uint32_t db_id);
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 5162242..ec0bcc4 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -58,19 +58,14 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
 	return ENOSYS;
 }
 
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, int num_pids,
-			  bool *results)
-{
-	return false;
-}
-
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
 {
 	return false;
 }
 
 struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
+				struct messaging_context *msg_ctx,
+				struct ctdbd_connection *conn,
 				const char *name,
 				int hash_size, int tdb_flags,
 				int open_flags, mode_t mode,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 9ea029a..6cb6814 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -31,8 +31,6 @@
 #include "lib/util/genrand.h"
 #include "lib/util/fault.h"
 
-#include "messages.h"
-
 /* paths to these include files come from --with-ctdb= in configure */
 
 #include "ctdb_private.h"
@@ -47,8 +45,6 @@ struct ctdbd_srvid_cb {
 };
 
 struct ctdbd_connection {
-	const char *sockname;	/* Needed in ctdbd_traverse */
-	struct messaging_context *msg_ctx;
 	uint32_t reqid;
 	uint32_t our_vnn;
 	uint64_t rand_srvid;
@@ -142,20 +138,19 @@ int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
 static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
 			       struct ctdb_req_message_old *msg)
 {
-	size_t msg_len;
+	uint32_t msg_len;
 	size_t i, num_callbacks;
 
 	msg_len = msg->hdr.length;
 	if (msg_len < offsetof(struct ctdb_req_message_old, data)) {
-		DEBUG(10, ("%s: len %u too small\n", __func__,
-			   (unsigned)msg_len));
+		DBG_DEBUG("len %"PRIu32" too small\n", msg_len);
 		return 0;
 	}
 	msg_len -= offsetof(struct ctdb_req_message_old, data);
 
 	if (msg_len < msg->datalen) {
-		DEBUG(10, ("%s: msg_len=%u < msg->datalen=%u\n", __func__,
-			   (unsigned)msg_len, (unsigned)msg->datalen));
+		DBG_DEBUG("msg_len=%"PRIu32" < msg->datalen=%"PRIu32"\n",
+			  msg_len, msg->datalen);
 		return 0;
 	}
 
@@ -378,14 +373,6 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 	if (hdr->operation == CTDB_REQ_MESSAGE) {
 		struct ctdb_req_message_old *msg = (struct ctdb_req_message_old *)hdr;
 
-		if (conn->msg_ctx == NULL) {
-			DEBUG(1, ("Got a message without having a msg ctx, "
-				  "dropping msg %llu\n",
-				  (long long unsigned)msg->srvid));
-			TALLOC_FREE(hdr);
-			goto next_pkt;
-		}
-
 		ret = ctdbd_msg_call_back(conn, msg);
 		if (ret != 0) {
 			TALLOC_FREE(hdr);
@@ -434,20 +421,13 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		return ENOMEM;
 	}
 
-	conn->sockname = talloc_strdup(conn, sockname);
-	if (conn->sockname == NULL) {
-		DBG_ERR("talloc failed\n");
-		ret = ENOMEM;
-		goto fail;
-	}
-
 	conn->timeout = timeout;
 
 	if (conn->timeout == 0) {
 		conn->timeout = -1;
 	}
 
-	ret = ctdbd_connect(conn->sockname, &conn->fd);
+	ret = ctdbd_connect(sockname, &conn->fd);
 	if (ret != 0) {
 		DEBUG(1, ("ctdbd_connect failed: %s\n", strerror(ret)));
 		goto fail;
@@ -486,11 +466,6 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 	return ret;
 }
 
-struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
-{
-	return conn->msg_ctx;
-}
-
 int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
 {
 	return conn->fd;
@@ -517,17 +492,8 @@ static int ctdb_handle_message(struct ctdbd_connection *conn,
 	return 0;
 }
 
-/*
- * The ctdbd socket is readable asynchronuously
- */
-
-static void ctdbd_socket_handler(struct tevent_context *event_ctx,
-				 struct tevent_fd *event,
-				 uint16_t flags,
-				 void *private_data)
+void ctdbd_socket_readable(struct ctdbd_connection *conn)
 {
-	struct ctdbd_connection *conn = talloc_get_type_abort(
-		private_data, struct ctdbd_connection);
 	struct ctdb_req_header *hdr = NULL;
 	int ret;
 
@@ -547,29 +513,6 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
 	}
 }
 
-/*
- * Prepare a ctdbd connection to receive messages
- */
-
-int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
-			   struct messaging_context *msg_ctx,
-			   struct tevent_context *ev)
-{
-	SMB_ASSERT(conn->msg_ctx == NULL);
-	SMB_ASSERT(conn->fde == NULL);
-
-	conn->fde = tevent_add_fd(ev, conn, conn->fd, TEVENT_FD_READ,
-				  ctdbd_socket_handler, conn);
-	if (conn->fde == NULL) {
-		DEBUG(0, ("event_add_fd failed\n"));
-		return ENOMEM;
-	}
-
-	conn->msg_ctx = msg_ctx;
-
-	return 0;
-}
-
 int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
 			     uint32_t dst_vnn, uint64_t dst_srvid,
 			     const struct iovec *iov, int iovlen)
@@ -692,126 +635,17 @@ static int ctdbd_control(struct ctdbd_connection *conn,
  */
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
 {
-	struct server_id id;
-	bool result;
-
-	id.pid = pid;
-	id.vnn = vnn;
+	int32_t cstatus = 0;
+	int ret;
 
-	if (!ctdb_processes_exist(conn, &id, 1, &result)) {
-		DEBUG(10, ("ctdb_processes_exist failed\n"));
+	ret = ctdbd_control(conn, vnn, CTDB_CONTROL_PROCESS_EXISTS, 0, 0,
+			    (TDB_DATA) { .dptr = (uint8_t *)&pid,
+					 .dsize = sizeof(pid) },
+			    NULL, NULL, &cstatus);
+	if (ret != 0) {
 		return false;
 	}
-	return result;
-}
-
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, int num_pids,
-			  bool *results)
-{
-	TALLOC_CTX *frame = talloc_stackframe();
-	int i, num_received;
-	uint32_t *reqids;
-	bool result = false;
-
-	reqids = talloc_array(talloc_tos(), uint32_t, num_pids);
-	if (reqids == NULL) {
-		goto fail;
-	}
-
-	for (i=0; i<num_pids; i++) {
-		struct ctdb_req_control_old req;
-		pid_t pid;
-		struct iovec iov[2];
-		ssize_t nwritten;
-
-		results[i] = false;
-		reqids[i] = ctdbd_next_reqid(conn);
-
-		ZERO_STRUCT(req);
-
-		/*
-		 * pids[i].pid is uint64_t, scale down to pid_t which
-		 * is the wire protocol towards ctdb.
-		 */
-		pid = pids[i].pid;
-
-		DEBUG(10, ("Requesting PID %d/%d, reqid=%d\n",
-			   (int)pids[i].vnn, (int)pid,
-			   (int)reqids[i]));
-
-		req.hdr.length = offsetof(struct ctdb_req_control_old, data);
-		req.hdr.length += sizeof(pid);
-		req.hdr.ctdb_magic   = CTDB_MAGIC;
-		req.hdr.ctdb_version = CTDB_PROTOCOL;
-		req.hdr.operation    = CTDB_REQ_CONTROL;
-		req.hdr.reqid        = reqids[i];
-		req.hdr.destnode     = pids[i].vnn;
-		req.opcode           = CTDB_CONTROL_PROCESS_EXISTS;
-		req.srvid            = 0;
-		req.datalen          = sizeof(pid);
-		req.flags            = 0;
-
-		DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
-		ctdb_packet_dump(&req.hdr);
-
-		iov[0].iov_base = &req;
-		iov[0].iov_len = offsetof(struct ctdb_req_control_old, data);
-		iov[1].iov_base = &pid;
-		iov[1].iov_len = sizeof(pid);
-
-		nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov));
-		if (nwritten == -1) {
-			DEBUG(10, ("write_data_iov failed: %s\n",
-				   strerror(errno)));
-			goto fail;
-		}
-	}
-
-	num_received = 0;
-
-	while (num_received < num_pids) {
-		struct ctdb_req_header *hdr;
-		struct ctdb_reply_control_old *reply;
-		uint32_t reqid;
-		int ret;
-
-		ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr);
-		if (ret != 0) {
-			DEBUG(10, ("ctdb_read_req failed: %s\n",
-				   strerror(ret)));
-			goto fail;
-		}
-
-		if (hdr->operation != CTDB_REPLY_CONTROL) {
-			DEBUG(10, ("Received invalid reply\n"));
-			goto fail;
-		}
-		reply = (struct ctdb_reply_control_old *)hdr;
-
-		reqid = reply->hdr.reqid;
-
-		DEBUG(10, ("Received reqid %d\n", (int)reqid));
-
-		for (i=0; i<num_pids; i++) {
-			if (reqid == reqids[i]) {
-				break;
-			}
-		}
-		if (i == num_pids) {
-			DEBUG(10, ("Received unknown record number %u\n",
-				   (unsigned)reqid));
-			goto fail;
-		}
-		results[i] = ((reply->status) == 0);
-		TALLOC_FREE(reply);
-		num_received += 1;
-	}
-
-	result = true;
-fail:
-	TALLOC_FREE(frame);
-	return result;
+	return (cstatus == 0);
 }
 
 /*
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 532240d..df5a34f 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -49,6 +49,7 @@ struct db_ctdb_transaction_handle {
 
 struct db_ctdb_ctx {
 	struct db_context *db;
+	struct ctdbd_connection *conn;
 	struct tdb_wrap *wtdb;
 	uint32_t db_id;
 	struct db_ctdb_transaction_handle *transaction;
@@ -357,7 +358,7 @@ static bool parse_newest_in_marshall_buffer(
 	struct ctdb_rec_data_old *rec = NULL;
 	struct ctdb_ltdb_header *h = NULL;
 	TDB_DATA data;
-	int i;
+	uint32_t i;
 
 	if (buf == NULL) {
 		return false;
@@ -589,7 +590,7 @@ static NTSTATUS db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h,
 		SAFE_FREE(rec.dptr);
 	}
 
-	header.dmaster = get_my_vnn();
+	header.dmaster = ctdbd_vnn(h->ctx->conn);
 	header.rsn++;
 
 	h->m_write = db_ctdb_marshall_add(h, h->m_write, h->ctx->db_id, 0, key, &header, data);
@@ -760,8 +761,7 @@ static int db_ctdb_transaction_commit(struct db_context *db)
 
 again:
 	/* tell ctdbd to commit to the other nodes */
-	ret = ctdbd_control_local(messaging_ctdbd_connection(),
-				  CTDB_CONTROL_TRANS3_COMMIT,
+	ret = ctdbd_control_local(ctx->conn, CTDB_CONTROL_TRANS3_COMMIT,
 				  h->ctx->db_id, 0,
 				  db_ctdb_marshall_finish(h->m_write),
 				  NULL, NULL, &status);
@@ -858,6 +858,7 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
 	int32_t cstatus;
 	struct db_ctdb_rec *crec = talloc_get_type_abort(
 		rec->private_data, struct db_ctdb_rec);
+	struct db_ctdb_ctx *ctx = crec->ctdb_ctx;
 
 	indata.dsize = offsetof(struct ctdb_control_schedule_for_deletion, key) + rec->key.dsize;
 	indata.dptr = talloc_zero_array(crec, uint8_t, indata.dsize);
@@ -867,12 +868,12 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
 	}
 
 	dd = (struct ctdb_control_schedule_for_deletion *)(void *)indata.dptr;
-	dd->db_id = crec->ctdb_ctx->db_id;
+	dd->db_id = ctx->db_id;
 	dd->hdr = crec->header;
 	dd->keylen = rec->key.dsize;
 	memcpy(dd->key, rec->key.dptr, rec->key.dsize);
 
-	ret = ctdbd_control_local(messaging_ctdbd_connection(),
+	ret = ctdbd_control_local(ctx->conn,
 				  CTDB_CONTROL_SCHEDULE_FOR_DELETION,
 				  crec->ctdb_ctx->db_id,
 				  CTDB_CTRL_FLAG_NOREPLY, /* flags */
@@ -977,9 +978,9 @@ static int db_ctdb_record_destr(struct db_record* data)
  * either for reading or for writing.
  */
 static bool db_ctdb_can_use_local_hdr(const struct ctdb_ltdb_header *hdr,
-				      bool read_only)
+				      uint32_t my_vnn, bool read_only)
 {
-	if (hdr->dmaster != get_my_vnn()) {
+	if (hdr->dmaster != my_vnn) {
 		/* If we're not dmaster, it must be r/o copy. */
 		return read_only && (hdr->flags & CTDB_REC_RO_HAVE_READONLY);
 	}
@@ -990,7 +991,8 @@ static bool db_ctdb_can_use_local_hdr(const struct ctdb_ltdb_header *hdr,
 	return read_only || !(hdr->flags & CTDB_REC_RO_HAVE_DELEGATIONS);
 }
 
-static bool db_ctdb_can_use_local_copy(TDB_DATA ctdb_data, bool read_only)
+static bool db_ctdb_can_use_local_copy(TDB_DATA ctdb_data, uint32_t my_vnn,
+				       bool read_only)
 {
 	if (ctdb_data.dptr == NULL) {
 		return false;
@@ -1001,7 +1003,7 @@ static bool db_ctdb_can_use_local_copy(TDB_DATA ctdb_data, bool read_only)
 	}
 
 	return db_ctdb_can_use_local_hdr(
-		(struct ctdb_ltdb_header *)ctdb_data.dptr, read_only);
+		(struct ctdb_ltdb_header *)ctdb_data.dptr, my_vnn, read_only);
 }
 
 static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
@@ -1086,7 +1088,8 @@ again:
 	 * take the shortcut and just return it.
 	 */
 
-	if (!db_ctdb_can_use_local_copy(ctdb_data, false)) {
+	if (!db_ctdb_can_use_local_copy(ctdb_data, ctdbd_vnn(ctx->conn),
+					false)) {
 		SAFE_FREE(ctdb_data.dptr);
 		tdb_chainunlock(ctx->wtdb->tdb, key);
 		talloc_set_destructor(result, NULL);
@@ -1099,16 +1102,17 @@ again:
 
 		migrate_attempts += 1;
 
-		DEBUG(10, ("ctdb_data.dptr = %p, dmaster = %u (%u) %u\n",
+		DEBUG(10, ("ctdb_data.dptr = %p, dmaster = %"PRIu32" "
+			   "(%"PRIu32") %"PRIu32"\n",
 			   ctdb_data.dptr, ctdb_data.dptr ?
-			   ((struct ctdb_ltdb_header *)ctdb_data.dptr)->dmaster : -1,
-			   get_my_vnn(),
+			   ((struct ctdb_ltdb_header *)ctdb_data.dptr)->dmaster :
+			   UINT32_MAX,
+			   ctdbd_vnn(ctx->conn),
 			   ctdb_data.dptr ?
 			   ((struct ctdb_ltdb_header *)ctdb_data.dptr)->flags : 0));
 
 		GetTimeOfDay(&ctdb_start_time);
-		ret = ctdbd_migrate(messaging_ctdbd_connection(), ctx->db_id,
-				    key);
+		ret = ctdbd_migrate(ctx->conn, ctx->db_id, key);
 		ctdb_time += timeval_elapsed(&ctdb_start_time);
 
 		if (ret != 0) {
@@ -1214,6 +1218,7 @@ static struct db_record *db_ctdb_try_fetch_locked(struct db_context *db,
 struct db_ctdb_parse_record_state {
 	void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data);
 	void *private_data;
+	uint32_t my_vnn;
 	bool ask_for_readonly_copy;
 	bool done;
 };
@@ -1234,7 +1239,7 @@ static void db_ctdb_parse_record_parser_nonpersistent(
 	struct db_ctdb_parse_record_state *state =
 		(struct db_ctdb_parse_record_state *)private_data;
 
-	if (db_ctdb_can_use_local_hdr(header, true)) {
+	if (db_ctdb_can_use_local_hdr(header, state->my_vnn, true)) {
 		state->parser(key, data, state->private_data);
 		state->done = true;
 	} else {
@@ -1261,6 +1266,7 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
 
 	state.parser = parser;
 	state.private_data = private_data;
+	state.my_vnn = ctdbd_vnn(ctx->conn);
 
 	if (ctx->transaction != NULL) {
 		struct db_ctdb_transaction_handle *h = ctx->transaction;
@@ -1295,7 +1301,7 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
 		return NT_STATUS_OK;
 	}
 
-	ret = ctdbd_parse(messaging_ctdbd_connection(), ctx->db_id, key,
+	ret = ctdbd_parse(ctx->conn, ctx->db_id, key,
 			  state.ask_for_readonly_copy, parser, private_data);
 	if (ret != 0) {
 		if (ret == ENOENT) {
@@ -1431,7 +1437,7 @@ static int db_ctdb_traverse(struct db_context *db,
 			struct db_context *newkeys = db_open_rbt(talloc_tos());
 			struct ctdb_marshall_buffer *mbuf = ctx->transaction->m_write;
 			struct ctdb_rec_data_old *rec=NULL;
-			int i;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list