[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Nov 10 10:58:02 MST 2011


The branch, master has been updated
       via  145f53e s3: server_id.pid has turned 64 (bits, that is)
       via  5e0258f s3: Avoid a race with the async echo handler
      from  17f1a97 libcli/cldap: fix a crash bug in cldap_socket_recv_dgram() (bug #8593)

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


- Log -----------------------------------------------------------------
commit 145f53e82413d7307643079f4a34aaeed0da80ab
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 10 17:17:20 2011 +0100

    s3: server_id.pid has turned 64 (bits, that is)
    
    Fix ctdb_processes_exist protocol. The socket expects pid_t which is 32 bits on
    32 bit machines.
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Thu Nov 10 18:57:01 CET 2011 on sn-devel-104

commit 5e0258fc932c280428173bb397ef5a18352e63db
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 10 09:39:23 2011 +0100

    s3: Avoid a race with the async echo handler
    
    We can not read from the echo handler socket when we have the main socket
    locked. This leads to the echo responder to lock up sitting in the fcntl lock
    while the parent wants to read the remainder of a large packet.

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

Summary of changes:
 source3/lib/ctdbd_conn.c |   15 ++++++++---
 source3/smbd/process.c   |   61 +++++++++++++++++++++-------------------------
 2 files changed, 39 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 5c3b7c1..e0bdbd0 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -938,18 +938,25 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn,
 
 	for (i=0; i<num_pids; i++) {
 		struct ctdb_req_control req;
+		pid_t pid;
 
 		results[i] = false;
 		reqids[i] = ctdbd_next_reqid(conn);
 
 		ZERO_STRUCT(req);
 
+		/*
+		 * pids[i].pid is uint64_t, scale down to pid_t which
+		 * is the wire protocol towards ctdb.
+		 */
+		pid = pids[i].pid;
+
 		DEBUG(10, ("Requesting PID %d/%d, reqid=%d\n",
-			   (int)pids[i].vnn, (int)pids[i].pid,
+			   (int)pids[i].vnn, (int)pid,
 			   (int)reqids[i]));
 
 		req.hdr.length = offsetof(struct ctdb_req_control, data);
-		req.hdr.length += sizeof(pid_t);
+		req.hdr.length += sizeof(pid);
 		req.hdr.ctdb_magic   = CTDB_MAGIC;
 		req.hdr.ctdb_version = CTDB_VERSION;
 		req.hdr.operation    = CTDB_REQ_CONTROL;
@@ -957,7 +964,7 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn,
 		req.hdr.destnode     = pids[i].vnn;
 		req.opcode           = CTDB_CONTROL_PROCESS_EXISTS;
 		req.srvid            = 0;
-		req.datalen          = sizeof(pids[i].pid);
+		req.datalen          = sizeof(pid);
 		req.flags            = 0;
 
 		DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
@@ -967,7 +974,7 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn,
 			conn->pkt, 2,
 			data_blob_const(
 				&req, offsetof(struct ctdb_req_control, data)),
-			data_blob_const(&pids[i].pid, sizeof(pids[i].pid)));
+			data_blob_const(&pid, sizeof(pid)));
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(10, ("ctdb_packet_send failed: %s\n",
 				   nt_errstr(status)));
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 0ad5542..82dd510 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -2217,46 +2217,41 @@ static void smbd_server_connection_read_handler(
 	NTSTATUS status;
 	uint32_t seqnum;
 
-	bool from_client = (sconn->sock == fd);
+	bool from_client;
+
+	if (lp_async_smb_echo_handler()
+	    && fd_is_readable(sconn->smb1.echo_handler.trusted_fd)) {
+		/*
+		 * This is the super-ugly hack to prefer the packets
+		 * forwarded by the echo handler over the ones by the
+		 * client directly
+		 */
+		fd = sconn->smb1.echo_handler.trusted_fd;
+	}
+
+	from_client = (sconn->sock == fd);
 
 	if (from_client) {
 		smbd_lock_socket(sconn);
 
-		if (lp_async_smb_echo_handler()) {
-
-			if (fd_is_readable(sconn->smb1.echo_handler.trusted_fd)) {
-				/*
-				 * This is the super-ugly hack to
-				 * prefer the packets forwarded by the
-				 * echo handler over the ones by the
-				 * client directly
-				 */
-				fd = sconn->smb1.echo_handler.trusted_fd;
-			} else if (!fd_is_readable(fd)) {
-				DEBUG(10,("the echo listener was faster\n"));
-				smbd_unlock_socket(sconn);
-				return;
-			}
+		if (!fd_is_readable(fd)) {
+			DEBUG(10,("the echo listener was faster\n"));
+			smbd_unlock_socket(sconn);
+			return;
 		}
+	}
+
+	/* TODO: make this completely nonblocking */
+	status = receive_smb_talloc(mem_ctx, sconn, fd,
+				    (char **)(void *)&inbuf,
+				    0, /* timeout */
+				    &unread_bytes,
+				    &encrypted,
+				    &inbuf_len, &seqnum,
+				    false /* trusted channel */);
 
-		/* TODO: make this completely nonblocking */
-		status = receive_smb_talloc(mem_ctx, sconn, fd,
-					    (char **)(void *)&inbuf,
-					    0, /* timeout */
-					    &unread_bytes,
-					    &encrypted,
-					    &inbuf_len, &seqnum,
-					    false /* trusted channel */);
+	if (from_client) {
 		smbd_unlock_socket(sconn);
-	} else {
-		/* TODO: make this completely nonblocking */
-		status = receive_smb_talloc(mem_ctx, sconn, fd,
-					    (char **)(void *)&inbuf,
-					    0, /* timeout */
-					    &unread_bytes,
-					    &encrypted,
-					    &inbuf_len, &seqnum,
-					    true /* trusted channel */);
 	}
 
 	if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list