diff options
author | Volker Lendecke <vl@samba.org> | 2009-11-16 12:03:24 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-11-02 15:59:05 +0100 |
commit | 18e3b223c77b8257966879f5238994642881d147 (patch) | |
tree | 8cd35e12f164d1d15c81c31b6982fc69a89b30ff /source3 | |
parent | 27056d37e0a7a7f46a4765b7ea45193050caa277 (diff) | |
download | samba-18e3b223c77b8257966879f5238994642881d147.tar.gz samba-18e3b223c77b8257966879f5238994642881d147.tar.bz2 samba-18e3b223c77b8257966879f5238994642881d147.zip |
s3: Do not connect to ctdb if it is blocked for some reason
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/ctdbd_conn.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 4a521ca390..dee477f3c5 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -105,6 +105,59 @@ static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32 *vnn) return status; } +/* + * Are we active (i.e. not banned or stopped?) + */ +static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn) +{ + int32_t cstatus=-1; + NTSTATUS status; + TDB_DATA outdata; + struct ctdb_node_map *m; + uint32_t failure_flags; + bool ret = false; + int i; + + status = ctdbd_control(conn, CTDB_CURRENT_NODE, + CTDB_CONTROL_GET_NODEMAP, 0, 0, + tdb_null, talloc_tos(), &outdata, &cstatus); + if (!NT_STATUS_IS_OK(status)) { + cluster_fatal("ctdbd_control failed\n"); + } + if ((cstatus != 0) || (outdata.dptr == NULL)) { + DEBUG(2, ("Received invalid ctdb data\n")); + return false; + } + + m = (struct ctdb_node_map *)outdata.dptr; + + for (i=0; i<m->num; i++) { + if (vnn == m->nodes[i].pnn) { + break; + } + } + + if (i == m->num) { + DEBUG(2, ("Did not find ourselves (node %d) in nodemap\n", + (int)vnn)); + goto fail; + } + + failure_flags = NODE_FLAGS_BANNED | NODE_FLAGS_DISCONNECTED + | NODE_FLAGS_PERMANENTLY_DISABLED | NODE_FLAGS_STOPPED; + + if ((m->nodes[i].flags & failure_flags) != 0) { + DEBUG(2, ("Node has status %x, not active\n", + (int)m->nodes[i].flags)); + goto fail; + } + + ret = true; +fail: + TALLOC_FREE(outdata.dptr); + return ret;; +} + uint32 ctdbd_vnn(const struct ctdbd_connection *conn) { return conn->our_vnn; @@ -460,6 +513,11 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx, goto fail; } + if (!ctdbd_working(conn, conn->our_vnn)) { + DEBUG(2, ("Node is not working, can not connect\n")); + goto fail; + } + generate_random_buffer((unsigned char *)&conn->rand_srvid, sizeof(conn->rand_srvid)); |