summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-05-10 17:32:33 +1000
committerAmitay Isaacs <amitay@samba.org>2018-11-06 07:16:14 +0100
commit5f478b7c5ff66da27cfc12e5272f72c8fbb95c62 (patch)
tree46a2c2379a38bbcc6de0f0b6f9f147c339eb6ad0
parentcd021596da68baf4ef6be7c2a18c64077c5c8ade (diff)
downloadsamba-5f478b7c5ff66da27cfc12e5272f72c8fbb95c62.tar.gz
ctdb-daemon: Use path functions for socket and PID file
Drop the use of ctdb_set_sockname() because it complicates the memory allocation and this is the only place it is used. Just assign to the relevant pointer. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/server/ctdbd.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index 721347c4733..9a8e0e8c3f4 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -38,6 +38,7 @@
#include "common/reqid.h"
#include "common/system.h"
#include "common/common.h"
+#include "common/path.h"
#include "common/logging.h"
#include "common/logging_conf.h"
@@ -100,9 +101,16 @@ static struct ctdb_context *ctdb_init(struct tevent_context *ev)
return NULL;
}
- ret = ctdb_set_socketname(ctdb, CTDB_SOCKET);
- if (ret != 0) {
- DBG_ERR("ctdb_set_socketname failed.\n");
+ ctdb->daemon.name = path_socket(ctdb, "ctdbd");
+ if (ctdb->daemon.name == NULL) {
+ DBG_ERR("Memory allocation error\n");
+ talloc_free(ctdb);
+ return NULL;
+ }
+
+ ctdbd_pidfile = path_pidfile(ctdb, "ctdbd");
+ if (ctdbd_pidfile == NULL) {
+ DBG_ERR("Memory allocation error\n");
talloc_free(ctdb);
return NULL;
}
@@ -145,7 +153,6 @@ int main(int argc, const char *argv[])
{
struct ctdb_context *ctdb = NULL;
int interactive = 0;
- const char *ctdb_socket;
struct poptOption popt_options[] = {
POPT_AUTOHELP
@@ -356,23 +363,6 @@ int main(int argc, const char *argv[])
* Testing and debug options
*/
- /* Environment variable overrides default */
- ctdbd_pidfile = getenv("CTDB_PIDFILE");
- if (ctdbd_pidfile == NULL) {
- ctdbd_pidfile = CTDB_RUNDIR "/ctdbd.pid";
- }
-
- /* Environment variable overrides default */
- ctdb_socket = getenv("CTDB_SOCKET");
- if (ctdb_socket == NULL) {
- ctdb_socket = CTDB_SOCKET;
- }
- ret = ctdb_set_socketname(ctdb, ctdb_socket);
- if (ret == -1) {
- D_ERR("ctdb_set_socketname() failed\n");
- goto fail;
- }
-
t = getenv("CTDB_TEST_MODE");
if (t != NULL) {
ctdb->do_setsched = false;