[PATCH] Remove lp_ references from ctdbd_conn

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Oct 2 01:48:18 UTC 2015


Hi!

A baby-step to make messages.c usable in source4 too. Not
there yet, but getting to it eventually.

Review&push appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 9b0c35522c046625cc337b970f0b62d99c53f9ae Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 14:32:09 -0700
Subject: [PATCH 1/8] lib: Lift lp_ctdbd_socket() call up one level

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/ctdbd_conn.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 9aec517..c966c4f 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -265,9 +265,8 @@ const char *lp_ctdbd_socket(void)
  * Get us a ctdb connection
  */
 
-static int ctdbd_connect(int *pfd)
+static int ctdbd_connect(const char *sockname, int *pfd)
 {
-	const char *sockname = lp_ctdbd_socket();
 	struct sockaddr_un addr = { 0, };
 	int fd;
 	socklen_t salen;
@@ -431,6 +430,7 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 				      struct ctdbd_connection **pconn)
 {
+	const char *sockname = lp_ctdbd_socket();
 	struct ctdbd_connection *conn;
 	int ret;
 	NTSTATUS status;
@@ -440,7 +440,7 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	ret = ctdbd_connect(&conn->fd);
+	ret = ctdbd_connect(sockname, &conn->fd);
 	if (ret != 0) {
 		status = map_nt_error_from_unix(ret);
 		DEBUG(1, ("ctdbd_connect failed: %s\n", strerror(ret)));
-- 
1.9.1


From e69bad0732eff369eaf1a8e91470e5686afc7f20 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 14:36:35 -0700
Subject: [PATCH 2/8] lib: Store ctdb_timeout in ctdb_connection

This lifts the call to lp_ctdb_timeout() up

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/ctdbd_conn.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index c966c4f..07d1282 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -50,6 +50,7 @@ struct ctdbd_connection {
 	struct ctdbd_srvid_cb *callbacks;
 	int fd;
 	struct tevent_fd *fde;
+	int timeout;
 };
 
 static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
@@ -303,19 +304,14 @@ static int ctdbd_connect(const char *sockname, int *pfd)
 	return 0;
 }
 
-static int ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
+static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx,
 			    struct ctdb_req_header **result)
 {
-	int timeout = lp_ctdb_timeout();
 	struct ctdb_req_header *req;
 	int ret, revents;
 	uint32_t msglen;
 	ssize_t nread;
 
-	if (timeout == 0) {
-		timeout = -1;
-	}
-
 	if (timeout != -1) {
 		ret = poll_one_fd(fd, POLLIN, timeout, &revents);
 		if (ret == -1) {
@@ -375,7 +371,7 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 
  next_pkt:
 
-	ret = ctdb_read_packet(conn->fd, mem_ctx, &hdr);
+	ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr);
 	if (ret != 0) {
 		DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
 		cluster_fatal("ctdbd died\n");
@@ -440,6 +436,12 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	conn->timeout = lp_ctdb_timeout();
+
+	if (conn->timeout == 0) {
+		conn->timeout = -1;
+	}
+
 	ret = ctdbd_connect(sockname, &conn->fd);
 	if (ret != 0) {
 		status = map_nt_error_from_unix(ret);
@@ -554,7 +556,7 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
 	struct ctdb_req_header *hdr = NULL;
 	int ret;
 
-	ret = ctdb_read_packet(conn->fd, talloc_tos(), &hdr);
+	ret = ctdb_read_packet(conn->fd, conn->timeout, talloc_tos(), &hdr);
 	if (ret != 0) {
 		DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
 		cluster_fatal("ctdbd died\n");
@@ -1125,7 +1127,7 @@ NTSTATUS ctdbd_traverse(uint32_t db_id,
 		struct ctdb_rec_data *d;
 		int ret;
 
-		ret = ctdb_read_packet(conn->fd, conn, &hdr);
+		ret = ctdb_read_packet(conn->fd, conn->timeout, conn, &hdr);
 		if (ret != 0) {
 			DEBUG(0, ("ctdb_read_packet failed: %s\n",
 				  strerror(ret)));
-- 
1.9.1


From 96865e258a6d1be038c6ef74466d7f66d55cfc30 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 14:39:41 -0700
Subject: [PATCH 3/8] lib: Remove temporary ctdb_connection in ctdb_control

I can just assume this is a bad hack for a condition that should have been
fixed in a different way. Today we pretty much expect a messaging_context to be
properly initialized everywhere, and this includes a ctdb connection.

If something later fails due to this commit, we need to do a
messaging_init before the offending call

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/ctdbd_conn.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 07d1282..a690a55 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -646,24 +646,11 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
 	struct ctdb_req_control req;
 	struct ctdb_req_header *hdr;
 	struct ctdb_reply_control *reply = NULL;
-	struct ctdbd_connection *new_conn = NULL;
 	struct iovec iov[2];
 	ssize_t nwritten;
 	NTSTATUS status;
 	int ret;
 
-	if (conn == NULL) {
-		status = ctdbd_init_connection(NULL, &new_conn);
-
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(10, ("Could not init temp connection: %s\n",
-				   nt_errstr(status)));
-			goto fail;
-		}
-
-		conn = new_conn;
-	}
-
 	ZERO_STRUCT(req);
 	req.hdr.length = offsetof(struct ctdb_req_control, data) + data.dsize;
 	req.hdr.ctdb_magic   = CTDB_MAGIC;
@@ -691,7 +678,6 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
 	}
 
 	if (flags & CTDB_CTRL_FLAG_NOREPLY) {
-		TALLOC_FREE(new_conn);
 		if (cstatus) {
 			*cstatus = 0;
 		}
@@ -726,7 +712,6 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
 	status = NT_STATUS_OK;
 
  fail:
-	TALLOC_FREE(new_conn);
 	TALLOC_FREE(reply);
 	return status;
 }
-- 
1.9.1


From 448821a4c12d8d9f68d883d7ffa96535a057c7cb Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 15:49:16 -0700
Subject: [PATCH 4/8] lib: Store sockname in ctdbd_connection

We'll need it in ctdbd_traverse()

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/ctdbd_conn.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index a690a55..8977e02 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -43,6 +43,7 @@ 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;
@@ -426,7 +427,6 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 				      struct ctdbd_connection **pconn)
 {
-	const char *sockname = lp_ctdbd_socket();
 	struct ctdbd_connection *conn;
 	int ret;
 	NTSTATUS status;
@@ -436,13 +436,20 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	conn->sockname = talloc_strdup(conn, lp_ctdbd_socket());
+	if (conn->sockname == NULL) {
+		DBG_ERR("%s: talloc failed\n", __func__);
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
 	conn->timeout = lp_ctdb_timeout();
 
 	if (conn->timeout == 0) {
 		conn->timeout = -1;
 	}
 
-	ret = ctdbd_connect(sockname, &conn->fd);
+	ret = ctdbd_connect(conn->sockname, &conn->fd);
 	if (ret != 0) {
 		status = map_nt_error_from_unix(ret);
 		DEBUG(1, ("ctdbd_connect failed: %s\n", strerror(ret)));
-- 
1.9.1


From 51aa9ed7ecc5fd5647672d9292853bad2bac161d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 16:09:23 -0700
Subject: [PATCH 5/8] lib: Pass parameters to ctdbd_init_connection()

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/ctdbd_conn.h     |  2 +-
 source3/lib/ctdbd_conn.c         | 13 ++++++++-----
 source3/lib/dbwrap/dbwrap_ctdb.c |  6 ++++--
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 9f7ec9f..803d3d4 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -63,7 +63,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
 				    void *private_data),
 		     void *private_data);
 
-NTSTATUS ctdbd_traverse(uint32_t db_id,
+NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
 			void (*fn)(TDB_DATA key, TDB_DATA data,
 				   void *private_data),
 			void *private_data);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 8977e02..1bb9125 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -425,6 +425,7 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
  */
 
 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+				      const char *sockname, int timeout,
 				      struct ctdbd_connection **pconn)
 {
 	struct ctdbd_connection *conn;
@@ -436,14 +437,14 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	conn->sockname = talloc_strdup(conn, lp_ctdbd_socket());
+	conn->sockname = talloc_strdup(conn, sockname);
 	if (conn->sockname == NULL) {
 		DBG_ERR("%s: talloc failed\n", __func__);
 		status = NT_STATUS_NO_MEMORY;
 		goto fail;
 	}
 
-	conn->timeout = lp_ctdb_timeout();
+	conn->timeout = timeout;
 
 	if (conn->timeout == 0) {
 		conn->timeout = -1;
@@ -499,7 +500,8 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
         struct ctdbd_connection *conn;
 	NTSTATUS status;
 
-	status = ctdbd_init_connection(mem_ctx, &conn);
+	status = ctdbd_init_connection(mem_ctx, lp_ctdbd_socket(),
+				       lp_ctdb_timeout(), &conn);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
@@ -1066,7 +1068,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
   everything in-line.
 */
 
-NTSTATUS ctdbd_traverse(uint32_t db_id,
+NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
 			void (*fn)(TDB_DATA key, TDB_DATA data,
 				   void *private_data),
 			void *private_data)
@@ -1079,7 +1081,8 @@ NTSTATUS ctdbd_traverse(uint32_t db_id,
 	int cstatus;
 
 	become_root();
-	status = ctdbd_init_connection(NULL, &conn);
+	status = ctdbd_init_connection(NULL, master->sockname, master->timeout,
+				       &conn);
 	unbecome_root();
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("ctdbd_init_connection failed: %s\n",
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 3b68338..75dad42 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1414,7 +1414,8 @@ static int db_ctdb_traverse(struct db_context *db,
 		return ret;
 	}
 
-	status = ctdbd_traverse(ctx->db_id, traverse_callback, &state);
+	status = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+				traverse_callback, &state);
 	if (!NT_STATUS_IS_OK(status)) {
 		return -1;
 	}
@@ -1503,7 +1504,8 @@ static int db_ctdb_traverse_read(struct db_context *db,
 		return tdb_traverse_read(ctx->wtdb->tdb, traverse_persistent_callback_read, &state);
 	}
 
-	status = ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
+	status = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+				traverse_read_callback, &state);
 	if (!NT_STATUS_IS_OK(status)) {
 		return -1;
 	}
-- 
1.9.1


From 720d8a0bb04bfc9827625df30d40fee8801c676f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 1 Oct 2015 12:28:21 +0200
Subject: [PATCH 6/8] lib: Move lp_ctdbd_socket() to cluster_support.c

There we have a #ifdef CTDB_SOCKET anyway

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/ctdbd_conn.h     |  1 -
 source3/lib/cluster_support.c    | 16 ++++++++++++++++
 source3/lib/cluster_support.h    |  1 +
 source3/lib/ctdb_dummy.c         |  5 -----
 source3/lib/ctdbd_conn.c         | 12 ------------
 source3/lib/dbwrap/dbwrap_ctdb.c |  1 +
 source3/lib/dbwrap/dbwrap_open.c |  1 +
 source3/lib/messages_ctdbd.c     |  1 +
 source3/lib/util_cluster.c       |  1 +
 9 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 803d3d4..b1c2534 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -30,7 +30,6 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
 				    struct ctdbd_connection **pconn);
 
 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
-const char *lp_ctdbd_socket(void);
 
 NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
 				struct messaging_context *msg_ctx);
diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c
index b8925aa..c11b1f7 100644
--- a/source3/lib/cluster_support.c
+++ b/source3/lib/cluster_support.c
@@ -54,3 +54,19 @@ const char *cluster_support_features(void)
 
 	return v;
 }
+
+const char *lp_ctdbd_socket(void)
+{
+	const char *ret;
+
+	ret = lp__ctdbd_socket();
+	if (ret != NULL && strlen(ret) > 0) {
+		return ret;
+	}
+
+#ifdef CTDB_SOCKET
+	return CTDB_SOCKET;
+#else
+	return "";
+#endif
+}
diff --git a/source3/lib/cluster_support.h b/source3/lib/cluster_support.h
index 0a03d2b..5e040bb 100644
--- a/source3/lib/cluster_support.h
+++ b/source3/lib/cluster_support.h
@@ -18,3 +18,4 @@
 
 bool cluster_support_available(void);
 const char *cluster_support_features(void);
+const char *lp_ctdbd_socket(void);
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 2d1f6de..4b7d20e 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -58,11 +58,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-const char *lp_ctdbd_socket(void)
-{
-	return "";
-}
-
 bool ctdb_processes_exist(struct ctdbd_connection *conn,
 			  const struct server_id *pids, int num_pids,
 			  bool *results)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 1bb9125..9ffd446 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -251,18 +251,6 @@ uint32_t ctdbd_vnn(const struct ctdbd_connection *conn)
 	return conn->our_vnn;
 }
 
-const char *lp_ctdbd_socket(void)
-{
-	const char *ret;
-
-	ret = lp__ctdbd_socket();
-	if (ret != NULL && strlen(ret) > 0) {
-		return ret;
-	}
-
-	return CTDB_SOCKET;
-}
-
 /*
  * Get us a ctdb connection
  */
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 75dad42..9852bc7 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -35,6 +35,7 @@
 #include "dbwrap/dbwrap_ctdb.h"
 #include "g_lock.h"
 #include "messages.h"
+#include "lib/cluster_support.h"
 
 struct db_ctdb_transaction_handle {
 	struct db_ctdb_ctx *ctx;
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index 64f484e..59fb3e4 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -25,6 +25,7 @@
 #include "dbwrap/dbwrap_tdb.h"
 #include "dbwrap/dbwrap_ctdb.h"
 #include "lib/param/param.h"
+#include "lib/cluster_support.h"
 #include "util_tdb.h"
 #include "ctdbd_conn.h"
 
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 294debe..ca85ab8 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -23,6 +23,7 @@
 #include "lib/util/iov_buf.h"
 #include "lib/messages_util.h"
 #include "ctdbd_conn.h"
+#include "lib/cluster_support.h"
 
 
 struct messaging_ctdbd_context {
diff --git a/source3/lib/util_cluster.c b/source3/lib/util_cluster.c
index ef79c8b..c1633f6 100644
--- a/source3/lib/util_cluster.c
+++ b/source3/lib/util_cluster.c
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "ctdbd_conn.h"
 #include "util_cluster.h"
+#include "lib/cluster_support.h"
 
 bool cluster_probe_ok(void)
 {
-- 
1.9.1


From 3f9481d28d83be000cdcd8fad003ff682719a958 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 16:49:33 -0700
Subject: [PATCH 7/8] lib: Pass sockname and timeout to
 ctdbd_messaging_connection

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/ctdbd_conn.h | 1 +
 source3/lib/ctdbd_conn.c     | 7 ++++---
 source3/lib/messages_ctdbd.c | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index b1c2534..4dcda6d 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -27,6 +27,7 @@ struct messaging_context;
 struct messaging_rec;
 
 NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
+				    const char *sockname, int timeout,
 				    struct ctdbd_connection **pconn);
 
 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 9ffd446..fb052dd 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -483,13 +483,13 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
  */
 
 NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
+				    const char *sockname, int timeout,
 				    struct ctdbd_connection **pconn)
 {
         struct ctdbd_connection *conn;
 	NTSTATUS status;
 
-	status = ctdbd_init_connection(mem_ctx, lp_ctdbd_socket(),
-				       lp_ctdb_timeout(), &conn);
+	status = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
@@ -1310,7 +1310,8 @@ NTSTATUS ctdbd_probe(void)
 	struct ctdbd_connection *conn = NULL;
 	NTSTATUS status;
 
-	status = ctdbd_messaging_connection(talloc_tos(), &conn);
+	status = ctdbd_messaging_connection(talloc_tos(), lp_ctdbd_socket(),
+					    lp_ctdb_timeout(), &conn);
 
 	/*
 	 * We only care if we can connect.
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index ca85ab8..4d8b574 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -183,7 +183,8 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	status = ctdbd_messaging_connection(ctx, &ctx->conn);
+	status = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
+					    lp_ctdb_timeout(), &ctx->conn);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
-- 
1.9.1


From 8eae2fecb519d892f91e23c5e8d0d107fe7a7ee1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 25 Sep 2015 16:52:58 -0700
Subject: [PATCH 8/8] lib: Pass sockname and timeout to ctdbd_probe()

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/ctdbd_conn.h | 2 +-
 source3/lib/ctdb_dummy.c     | 2 +-
 source3/lib/ctdbd_conn.c     | 6 +++---
 source3/lib/util_cluster.c   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 4dcda6d..6c46cdb 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -92,6 +92,6 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
 				       const uint8_t *msg, size_t msglen,
 				       void *private_data),
 			     void *private_data);
-NTSTATUS ctdbd_probe(void);
+NTSTATUS ctdbd_probe(const char *sockname, int timeout);
 
 #endif /* _CTDBD_CONN_H */
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 4b7d20e..d8658cf 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -24,7 +24,7 @@
 #include "lib/dbwrap/dbwrap_ctdb.h"
 #include "torture/proto.h"
 
-NTSTATUS ctdbd_probe(void)
+NTSTATUS ctdbd_probe(const char *sockname, int timeout)
 {
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index fb052dd..da2c3a9 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1301,7 +1301,7 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
 	return status;
 }
 
-NTSTATUS ctdbd_probe(void)
+NTSTATUS ctdbd_probe(const char *sockname, int timeout)
 {
 	/*
 	 * Do a very early check if ctdbd is around to avoid an abort and core
@@ -1310,8 +1310,8 @@ NTSTATUS ctdbd_probe(void)
 	struct ctdbd_connection *conn = NULL;
 	NTSTATUS status;
 
-	status = ctdbd_messaging_connection(talloc_tos(), lp_ctdbd_socket(),
-					    lp_ctdb_timeout(), &conn);
+	status = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
+					    &conn);
 
 	/*
 	 * We only care if we can connect.
diff --git a/source3/lib/util_cluster.c b/source3/lib/util_cluster.c
index c1633f6..85f006c 100644
--- a/source3/lib/util_cluster.c
+++ b/source3/lib/util_cluster.c
@@ -28,7 +28,7 @@ bool cluster_probe_ok(void)
 	if (lp_clustering()) {
 		NTSTATUS status;
 
-		status = ctdbd_probe();
+		status = ctdbd_probe(lp_ctdbd_socket(), lp_ctdb_timeout());
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(0, ("clustering=yes but ctdbd connect failed: "
 				  "%s\n", nt_errstr(status)));
-- 
1.9.1



More information about the samba-technical mailing list