summaryrefslogtreecommitdiff
path: root/ctdb/tcp
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@samba.org>2008-02-19 14:44:48 +1100
committerRonnie Sahlberg <sahlberg@samba.org>2008-02-19 14:44:48 +1100
commit9f99b44fd1b68f7bcb0305d49f6f648813451ef6 (patch)
tree13f1eac1f1ac052c35232324cf8b6bf0d41c352c /ctdb/tcp
parent87b38e01b2f27314a8283b7fd079e5348d2e97fd (diff)
downloadsamba-9f99b44fd1b68f7bcb0305d49f6f648813451ef6.tar.gz
to make it easier/less disruptive to add nodes to a running cluster
add a new control that causes the node to drop the current nodes list and reread it from the nodes file. During this operation, the node will also drop the tcp layer and restart it. When we drop the tcp layer, by talloc_free()ing the ctcp structure add a destructor to ctcp so that we also can clean up and remove the references in the ctdb structure to the transport layer add two new commands for the ctdb tool. one to list all nodes in the nodesfile and the second a command to trigger a node to drop the transport and reinitialize it with the nde nodes file (This used to be ctdb commit 4bc20ac73e9fa94ffd43cccb6eeb438eeff9963c)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r--ctdb/tcp/ctdb_tcp.h1
-rw-r--r--ctdb/tcp/tcp_init.c20
2 files changed, 20 insertions, 1 deletions
diff --git a/ctdb/tcp/ctdb_tcp.h b/ctdb/tcp/ctdb_tcp.h
index 7d47cbcfe14..9a17bd6b596 100644
--- a/ctdb/tcp/ctdb_tcp.h
+++ b/ctdb/tcp/ctdb_tcp.h
@@ -20,6 +20,7 @@
/* ctdb_tcp main state */
struct ctdb_tcp {
+ struct ctdb_context *ctdb;
int listen_fd;
};
diff --git a/ctdb/tcp/tcp_init.c b/ctdb/tcp/tcp_init.c
index 624f6507efc..527373cb08b 100644
--- a/ctdb/tcp/tcp_init.c
+++ b/ctdb/tcp/tcp_init.c
@@ -54,7 +54,10 @@ static int ctdb_tcp_initialise(struct ctdb_context *ctdb)
int i;
/* listen on our own address */
- if (ctdb_tcp_listen(ctdb) != 0) return -1;
+ if (ctdb_tcp_listen(ctdb) != 0) {
+ DEBUG(DEBUG_CRIT, (__location__ " Failed to start listening on the CTDB socket\n"));
+ exit(1);
+ }
for (i=0; i<ctdb->num_nodes; i++) {
if (ctdb_tcp_add_node(ctdb->nodes[i]) != 0) {
@@ -142,6 +145,18 @@ static const struct ctdb_methods ctdb_tcp_methods = {
.restart = ctdb_tcp_restart,
};
+static int tcp_ctcp_destructor(struct ctdb_tcp *ctcp)
+{
+ if (ctcp->listen_fd) {
+ close(ctcp->listen_fd);
+ }
+ ctcp->ctdb->private_data = NULL;
+ ctcp->ctdb->methods = NULL;
+
+ return 0;
+}
+
+
/*
initialise tcp portion of ctdb
*/
@@ -152,8 +167,11 @@ int ctdb_tcp_init(struct ctdb_context *ctdb)
CTDB_NO_MEMORY(ctdb, ctcp);
ctcp->listen_fd = -1;
+ ctcp->ctdb = ctdb;
ctdb->private_data = ctcp;
ctdb->methods = &ctdb_tcp_methods;
+
+ talloc_set_destructor(ctcp, tcp_ctcp_destructor);
return 0;
}