[SCM] SAMBA-CTDB repository - branch v3-4-ctdb updated - 3.4.2-ctdb-12-15-g744e80a

Michael Adam obnox at samba.org
Mon Nov 30 02:35:54 MST 2009


The branch, v3-4-ctdb has been updated
       via  744e80a0933412c24bdebf88b400e576cbeffcab (commit)
       via  d5c6f9f1f0ada80bb4b6557eb6be83d6e807aaf8 (commit)
      from  5fb50b51268e80ce755116b1c62957f6069c3741 (commit)

http://gitweb.samba.org/?p=obnox/samba-ctdb.git;a=shortlog;h=v3-4-ctdb


- Log -----------------------------------------------------------------
commit 744e80a0933412c24bdebf88b400e576cbeffcab
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 16 12:03:24 2009 +0100

    s3: Do not connect to ctdb if it is blocked for some reason

commit d5c6f9f1f0ada80bb4b6557eb6be83d6e807aaf8
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 26 17:58:01 2009 +0100

    s3: Fix the winbind piece of 58045: Correctly time out client smb requests

-----------------------------------------------------------------------

Summary of changes:
 lib/async_req/async_req.c  |   25 +++++++++++++++++++
 lib/async_req/async_req.h  |    8 ++++++
 source3/lib/ctdbd_conn.c   |   58 ++++++++++++++++++++++++++++++++++++++++++++
 source3/libsmb/async_smb.c |    9 +++++++
 4 files changed, 100 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/async_req/async_req.c b/lib/async_req/async_req.c
index 4dfe809..69c3ed6 100644
--- a/lib/async_req/async_req.c
+++ b/lib/async_req/async_req.c
@@ -78,6 +78,31 @@ static void async_req_finish(struct async_req *req, enum async_req_state state)
 	}
 }
 
+static void async_req_timedout(struct event_context *ev,
+			       struct timed_event *te,
+			       struct timeval now,
+			       void *private_data)
+{
+	struct async_req *req = talloc_get_type_abort(
+		private_data, struct async_req);
+	TALLOC_FREE(req->timer);
+	async_req_finish(req, ASYNC_REQ_TIMED_OUT);
+}
+
+bool async_req_set_endtime(struct async_req *req, struct event_context *ev,
+			   struct timeval endtime)
+{
+	struct timed_event *te;
+
+	te = event_add_timed(ev, req, endtime, async_req_timedout, req);
+	if (te == NULL) {
+		return false;
+	}
+	TALLOC_FREE(req->timer);
+	req->timer = te;
+	return true;
+}
+
 /**
  * @brief An async request has successfully finished
  * @param[in] req	The finished request
diff --git a/lib/async_req/async_req.h b/lib/async_req/async_req.h
index fdec1b7..7a9220b 100644
--- a/lib/async_req/async_req.h
+++ b/lib/async_req/async_req.h
@@ -121,10 +121,18 @@ struct async_req {
 		 */
 		void *priv;
 	} async;
+
+	/*
+	 * Individual timeout event for this async_req
+	 */
+	struct timed_event *timer;
 };
 
 struct async_req *async_req_new(TALLOC_CTX *mem_ctx);
 
+bool async_req_set_endtime(struct async_req *req, struct event_context *ev,
+			   struct timeval endtime);
+
 char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req);
 
 void async_req_done(struct async_req *req);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 291fa3c..9101bd4 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -104,6 +104,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;
@@ -448,6 +501,11 @@ 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));
 
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 07d832e..e5ff002 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -600,6 +600,7 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
 {
 	struct async_req *result;
 	bool uncork = false;
+	struct timeval endtime;
 
 	if (cli->chain_accumulator == NULL) {
 		if (!cli_chain_cork(cli, ev,
@@ -618,6 +619,14 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
 		DEBUG(1, ("cli_request_chain failed\n"));
 	}
 
+	endtime = timeval_current_ofs(0, cli->timeout * 1000);
+
+	if (!async_req_set_endtime(result, ev, endtime)) {
+		DEBUG(1, ("async_req_set_endtime failed\n"));
+		TALLOC_FREE(result);
+		return NULL;
+	}
+
 	if (uncork) {
 		cli_chain_uncork(cli);
 	}


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list