[PATCH] ctdb: honor CTDB_SOCKET in the server

Michael Adam obnox at samba.org
Tue Sep 8 08:56:11 UTC 2015


I am not 100% sure this would be the intended behavior,
but it is more consistent to have the same precedence
chain in server and client:

- compiled-in default define CTDB_SOCKET
- overridden by env variable CTDB_SOCKET
- overridden by cmdline option --socket

Review appreciated!

Thanks - Michael

-------------- next part --------------
From 8897a4f300841e61da6455905c7c3216e50bd167 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 8 Sep 2015 10:00:09 +0200
Subject: [PATCH] ctdb: also honor the CTDB_SOCKET env variable in the server.

Up to now, it was only honored in the client.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/common/cmdline.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c
index 7fcb91f..97ce2d5 100644
--- a/ctdb/common/cmdline.c
+++ b/ctdb/common/cmdline.c
@@ -71,6 +71,7 @@ struct poptOption popt_ctdb_cmdline[] = {
 struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 {
 	struct ctdb_context *ctdb;
+	char *socket_name;
 	int ret;
 
 	/* initialise ctdb */
@@ -84,6 +85,16 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 		ctdb_set_flags(ctdb, CTDB_FLAG_TORTURE);
 	}
 
+	socket_name = getenv("CTDB_SOCKET");
+	if (socket_name != NULL) {
+		ret = ctdb_set_socketname(ctdb, socket_name);
+		if (ret == -1) {
+			printf("ctdb_set_socketname failed - %s\n",
+			       ctdb_errstr(ctdb));
+			exit(1);
+		}
+	}
+
 	/* command line specified a socket name */
 	if (ctdb_cmdline.socketname != NULL) {
 		setenv("CTDB_SOCKET", ctdb_cmdline.socketname, 1);
-- 
2.4.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150908/a34bc49c/attachment.sig>


More information about the samba-technical mailing list