[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri May 30 20:26:04 MDT 2014


The branch, master has been updated
       via  51077c6 s3:smb2_server: call smbd_smb2_flush_send_queue() directly
       via  629f4e8 s3:smb2_server: fix invalid TALLOC_FREE(iov) in smbd_smb2_inbuf_parse_compound()
       via  c81f1aa messaging3: Enforce just one messaging context
       via  c487937 messaging3: Make messaging_context private
       via  8ddbf18 messaging3: Add and use messaging_tevent_context()
       via  56a7ddd messaging3: Introduce messaging_local_backend()
       via  331296d messaging3: The backend send_fn doesn't need a messaging_context
       via  839a45a imessaging: Fix a comment
      from  90f9db9 Fix several talloc stack frames not freed

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 51077c6be665fb95c0ba06f5878a08503bf311df
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 12:30:21 2014 +0200

    s3:smb2_server: call smbd_smb2_flush_send_queue() directly
    
    This avoids recursion into smbd_smb2_io_handler(),
    which avoids confusion when analysing out put of
    performance analysing tools, e.g. callgrind.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat May 31 04:25:36 CEST 2014 on sn-devel-104

commit 629f4e87696ef891a342c0b2ec095e0a97158dce
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 12:21:57 2014 +0200

    s3:smb2_server: fix invalid TALLOC_FREE(iov) in smbd_smb2_inbuf_parse_compound()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c81f1aab93f613db5a7f8131e3761b0fb1c8ea83
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 18 20:51:23 2014 +0100

    messaging3: Enforce just one messaging context
    
    The current messaging implementation is based on a tdb indexed by server_id. If
    we have more than one messaging context in a process, messages might not arrive
    at the right context and be dropped, depending on which signal handler is
    triggered first.
    
    This is the same patch as bd55fdb lifted to messaging.c
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c487937b0146c19d4969208519f2c11b64666842
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 29 16:44:55 2014 +0200

    messaging3: Make messaging_context private
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8ddbf18115f2fc251a37d01907b572cc14161d01
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 29 16:44:32 2014 +0200

    messaging3: Add and use messaging_tevent_context()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 56a7ddd7779448f18233f6e1769bc34f11fa2e14
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 29 15:01:03 2014 +0200

    messaging3: Introduce messaging_local_backend()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 331296df94a7f9b8921e1c57b3a5e23284ca0314
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 29 14:51:37 2014 +0200

    messaging3: The backend send_fn doesn't need a messaging_context
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 839a45a471e9571c7755e3b68f9fb3e2cebd5920
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 29 13:10:45 2014 +0200

    imessaging: Fix a comment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 source3/include/messages.h        |   27 +++---------------
 source3/lib/ctdbd_conn.c          |    7 +++--
 source3/lib/messages.c            |   55 +++++++++++++++++++++++++++++++++++--
 source3/lib/messages_ctdbd.c      |    4 +-
 source3/lib/messages_dgm.c        |   18 +++++++-----
 source3/smbd/smb2_server.c        |   25 ++++++++---------
 source4/lib/messaging/messaging.c |    2 +-
 7 files changed, 87 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/messages.h b/source3/include/messages.h
index 18362f9..5784e41 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -65,29 +65,8 @@
 struct messaging_context;
 struct messaging_rec;
 
-/*
- * struct messaging_context belongs to messages.c, but because we still have
- * messaging_dispatch, we need it here. Once we get rid of signals for
- * notifying processes, this will go.
- */
-
-struct messaging_context {
-	struct server_id id;
-	struct tevent_context *event_ctx;
-	struct messaging_callback *callbacks;
-
-	struct tevent_req **new_waiters;
-	unsigned num_new_waiters;
-
-	struct tevent_req **waiters;
-	unsigned num_waiters;
-
-	struct messaging_backend *local;
-	struct messaging_backend *remote;
-};
-
 struct messaging_backend {
-	NTSTATUS (*send_fn)(struct messaging_context *msg_ctx,
+	NTSTATUS (*send_fn)(struct server_id src,
 			    struct server_id pid, int msg_type,
 			    const struct iovec *iov, int iovlen,
 			    struct messaging_backend *backend);
@@ -116,6 +95,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 					 struct tevent_context *ev);
 
 struct server_id messaging_server_id(const struct messaging_context *msg_ctx);
+struct tevent_context *messaging_tevent_context(
+	struct messaging_context *msg_ctx);
+struct messaging_backend *messaging_local_backend(
+	struct messaging_context *msg_ctx);
 
 /*
  * re-init after a fork
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 35845ed..201c700 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -496,8 +496,8 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
 		 * We're waiting for a call reply, but an async message has
 		 * crossed. Defer dispatching to the toplevel event loop.
 		 */
-		evt = tevent_add_timer(conn->msg_ctx->event_ctx,
-				      conn->msg_ctx->event_ctx,
+		evt = tevent_add_timer(messaging_tevent_context(conn->msg_ctx),
+				      messaging_tevent_context(conn->msg_ctx),
 				      timeval_zero(),
 				      deferred_message_dispatch,
 				      msg_state);
@@ -747,7 +747,8 @@ NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
 	SMB_ASSERT(conn->msg_ctx == NULL);
 	SMB_ASSERT(conn->fde == NULL);
 
-	if (!(conn->fde = tevent_add_fd(msg_ctx->event_ctx, conn,
+	if (!(conn->fde = tevent_add_fd(messaging_tevent_context(msg_ctx),
+				       conn,
 				       ctdb_packet_get_fd(conn->pkt),
 				       TEVENT_FD_READ,
 				       ctdbd_socket_handler,
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 6e2e7ca..1263bf1 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -61,6 +61,25 @@ struct messaging_callback {
 	void *private_data;
 };
 
+struct messaging_context {
+	struct server_id id;
+	struct tevent_context *event_ctx;
+	struct messaging_callback *callbacks;
+
+	struct tevent_req **new_waiters;
+	unsigned num_new_waiters;
+
+	struct tevent_req **waiters;
+	unsigned num_waiters;
+
+	struct messaging_backend *local;
+	struct messaging_backend *remote;
+
+	bool *have_context;
+};
+
+static int messaging_context_destructor(struct messaging_context *msg_ctx);
+
 /****************************************************************************
  A useful function for testing the message system.
 ****************************************************************************/
@@ -190,6 +209,13 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 {
 	struct messaging_context *ctx;
 	NTSTATUS status;
+	static bool have_context = false;
+
+	if (have_context) {
+		DEBUG(0, ("No two messaging contexts per process\n"));
+		return NULL;
+	}
+
 
 	if (!(ctx = talloc_zero(mem_ctx, struct messaging_context))) {
 		return NULL;
@@ -197,6 +223,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 
 	ctx->id = procid_self();
 	ctx->event_ctx = ev;
+	ctx->have_context = &have_context;
 
 	status = messaging_dgm_init(ctx, ctx, &ctx->local);
 
@@ -227,9 +254,19 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
 	register_dmalloc_msgs(ctx);
 	debug_register_msgs(ctx);
 
+	have_context = true;
+	talloc_set_destructor(ctx, messaging_context_destructor);
+
 	return ctx;
 }
 
+static int messaging_context_destructor(struct messaging_context *msg_ctx)
+{
+	SMB_ASSERT(*msg_ctx->have_context);
+	*msg_ctx->have_context = false;
+	return 0;
+}
+
 struct server_id messaging_server_id(const struct messaging_context *msg_ctx)
 {
 	return msg_ctx->id;
@@ -380,7 +417,7 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
 	}
 
 	if (!procid_is_local(&server)) {
-		return msg_ctx->remote->send_fn(msg_ctx, server,
+		return msg_ctx->remote->send_fn(msg_ctx->id, server,
 						msg_type, iov, iovlen,
 						msg_ctx->remote);
 	}
@@ -407,8 +444,8 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
 		return NT_STATUS_OK;
 	}
 
-	return msg_ctx->local->send_fn(msg_ctx, server, msg_type, iov, iovlen,
-				       msg_ctx->local);
+	return msg_ctx->local->send_fn(msg_ctx->id, server, msg_type,
+				       iov, iovlen, msg_ctx->local);
 }
 
 static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
@@ -862,4 +899,16 @@ static void mess_parent_dgm_cleanup_done(struct tevent_req *req)
 	tevent_req_set_callback(req, mess_parent_dgm_cleanup_done, msg);
 }
 
+struct messaging_backend *messaging_local_backend(
+	struct messaging_context *msg_ctx)
+{
+	return msg_ctx->local;
+}
+
+struct tevent_context *messaging_tevent_context(
+	struct messaging_context *msg_ctx)
+{
+	return msg_ctx->event_ctx;
+}
+
 /** @} **/
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 34b3e2a..3b7fa05 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -88,7 +88,7 @@ struct ctdbd_connection *messaging_ctdbd_connection(void)
 	return global_ctdbd_connection;
 }
 
-static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
+static NTSTATUS messaging_ctdb_send(struct server_id src,
 				    struct server_id pid, int msg_type,
 				    const struct iovec *iov, int iovlen,
 				    struct messaging_backend *backend)
@@ -109,7 +109,7 @@ static NTSTATUS messaging_ctdb_send(struct messaging_context *msg_ctx,
 	msg.msg_version	= MESSAGE_VERSION;
 	msg.msg_type	= msg_type;
 	msg.dest	= pid;
-	msg.src		= msg_ctx->id;
+	msg.src		= src;
 	msg.buf		= data_blob_const(buf, talloc_get_size(buf));
 
 	status = ctdbd_messaging_send(ctx->conn, pid.vnn, pid.pid, &msg);
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 6912035..9b58d9e 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -44,7 +44,7 @@ struct messaging_dgm_hdr {
 	struct server_id src;
 };
 
-static NTSTATUS messaging_dgm_send(struct messaging_context *msg_ctx,
+static NTSTATUS messaging_dgm_send(struct server_id src,
 				   struct server_id pid, int msg_type,
 				   const struct iovec *iov, int iovlen,
 				   struct messaging_backend *backend);
@@ -232,7 +232,8 @@ NTSTATUS messaging_dgm_init(struct messaging_context *msg_ctx,
 	}
 
 	ctx->tevent_handle = poll_funcs_tevent_register(
-		ctx, ctx->msg_callbacks, msg_ctx->event_ctx);
+		ctx, ctx->msg_callbacks,
+		messaging_tevent_context(msg_ctx));
 	if (ctx->tevent_handle == NULL) {
 		TALLOC_FREE(result);
 		return NT_STATUS_NO_MEMORY;
@@ -286,7 +287,7 @@ static int messaging_dgm_context_destructor(struct messaging_dgm_context *c)
 	return 0;
 }
 
-static NTSTATUS messaging_dgm_send(struct messaging_context *msg_ctx,
+static NTSTATUS messaging_dgm_send(struct server_id src,
 				   struct server_id pid, int msg_type,
 				   const struct iovec *iov, int iovlen,
 				   struct messaging_backend *backend)
@@ -312,7 +313,7 @@ static NTSTATUS messaging_dgm_send(struct messaging_context *msg_ctx,
 	hdr.msg_version = MESSAGE_VERSION;
 	hdr.msg_type = msg_type & MSG_TYPE_MASK;
 	hdr.dst = pid;
-	hdr.src = msg_ctx->id;
+	hdr.src = src;
 
 	DEBUG(10, ("%s: Sending message 0x%x to %s\n", __func__,
 		   (unsigned)hdr.msg_type,
@@ -369,8 +370,9 @@ static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
 
 NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
 {
+	struct messaging_backend *be = messaging_local_backend(msg_ctx);
 	struct messaging_dgm_context *ctx = talloc_get_type_abort(
-		msg_ctx->local->private_data, struct messaging_dgm_context);
+		be->private_data, struct messaging_dgm_context);
 	char *lockfile_name, *socket_name;
 	int fd, ret;
 	struct flock lck = {};
@@ -421,8 +423,9 @@ NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
 
 NTSTATUS messaging_dgm_wipe(struct messaging_context *msg_ctx)
 {
+	struct messaging_backend *be = messaging_local_backend(msg_ctx);
 	struct messaging_dgm_context *ctx = talloc_get_type_abort(
-		msg_ctx->local->private_data, struct messaging_dgm_context);
+		be->private_data, struct messaging_dgm_context);
 	char *msgdir_name;
 	DIR *msgdir;
 	struct dirent *dp;
@@ -477,7 +480,8 @@ void *messaging_dgm_register_tevent_context(TALLOC_CTX *mem_ctx,
 					    struct messaging_context *msg_ctx,
 					    struct tevent_context *ev)
 {
+	struct messaging_backend *be = messaging_local_backend(msg_ctx);
 	struct messaging_dgm_context *ctx = talloc_get_type_abort(
-		msg_ctx->local->private_data, struct messaging_dgm_context);
+		be->private_data, struct messaging_dgm_context);
 	return poll_funcs_tevent_register(mem_ctx, ctx->msg_callbacks, ev);
 }
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 4a7abcb..69fe9e4 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -34,8 +34,7 @@ static void smbd_smb2_connection_handler(struct tevent_context *ev,
 					 struct tevent_fd *fde,
 					 uint16_t flags,
 					 void *private_data);
-static NTSTATUS smbd_smb2_io_handler(struct smbd_server_connection *sconn,
-				     uint16_t fde_flags);
+static NTSTATUS smbd_smb2_flush_send_queue(struct smbd_server_connection *sconn);
 
 static const struct smbd_smb2_dispatch_table {
 	uint16_t opcode;
@@ -327,6 +326,11 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
 		uint8_t *body = NULL;
 		uint32_t dyn_size;
 		uint8_t *dyn = NULL;
+		struct iovec *iov_alloc = NULL;
+
+		if (iov != req->in._vector) {
+			iov_alloc = iov;
+		}
 
 		if (verified_buflen > taken) {
 			len = verified_buflen - taken;
@@ -388,7 +392,7 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
 				DEBUG(1, ("invalid session[%llu] in "
 					  "SMB2_TRANSFORM header\n",
 					   (unsigned long long)uid));
-				TALLOC_FREE(iov);
+				TALLOC_FREE(iov_alloc);
 				return NT_STATUS_USER_SESSION_DELETED;
 			}
 
@@ -401,7 +405,7 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
 							  conn->protocol,
 							  tf_iov, 2);
 			if (!NT_STATUS_IS_OK(status)) {
-				TALLOC_FREE(iov);
+				TALLOC_FREE(iov_alloc);
 				return status;
 			}
 
@@ -459,11 +463,6 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
 
 		if (num_iov >= ARRAY_SIZE(req->in._vector)) {
 			struct iovec *iov_tmp = NULL;
-			struct iovec *iov_alloc = NULL;
-
-			if (iov != req->in._vector) {
-				iov_alloc = iov;
-			}
 
 			iov_tmp = talloc_realloc(mem_ctx, iov_alloc,
 						 struct iovec,
@@ -1265,7 +1264,7 @@ static NTSTATUS smb2_send_async_interim_response(const struct smbd_smb2_request
 	DLIST_ADD_END(nreq->sconn->smb2.send_queue, &nreq->queue_entry, NULL);
 	nreq->sconn->smb2.send_queue_len++;
 
-	status = smbd_smb2_io_handler(sconn, TEVENT_FD_WRITE);
+	status = smbd_smb2_flush_send_queue(sconn);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -1598,7 +1597,7 @@ static void smbd_smb2_request_pending_timer(struct tevent_context *ev,
 	DLIST_ADD_END(sconn->smb2.send_queue, &state->queue_entry, NULL);
 	sconn->smb2.send_queue_len++;
 
-	status = smbd_smb2_io_handler(sconn, TEVENT_FD_WRITE);
+	status = smbd_smb2_flush_send_queue(sconn);
 	if (!NT_STATUS_IS_OK(status)) {
 		smbd_server_connection_terminate(sconn,
 						 nt_errstr(status));
@@ -2499,7 +2498,7 @@ static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req)
 	DLIST_ADD_END(req->sconn->smb2.send_queue, &req->queue_entry, NULL);
 	req->sconn->smb2.send_queue_len++;
 
-	status = smbd_smb2_io_handler(sconn, TEVENT_FD_WRITE);
+	status = smbd_smb2_flush_send_queue(sconn);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -2829,7 +2828,7 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
 	DLIST_ADD_END(state->sconn->smb2.send_queue, &state->queue_entry, NULL);
 	state->sconn->smb2.send_queue_len++;
 
-	status = smbd_smb2_io_handler(sconn, TEVENT_FD_WRITE);
+	status = smbd_smb2_flush_send_queue(sconn);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index f73b2ba..66732ce 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -564,7 +564,7 @@ int imessaging_cleanup(struct imessaging_context *msg)
 /*
   create the listening socket and setup the dispatcher
 
-  use temporary=true when you want a destructor to remove the
+  use auto_remove=true when you want a destructor to remove the
   associated messaging socket and database entry on talloc free. Don't
   use this in processes that may fork and a child may talloc free this
   memory


-- 
Samba Shared Repository


More information about the samba-cvs mailing list