[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Jan 20 06:24:04 MST 2014


The branch, master has been updated
       via  1db4d38 s3-winbind: separate child response sock write
       via  8f3cf00 s3-winbind: only pass needed args to child_read_request
      from  dad72a3 s3: rpc_server/srvsvc: Avoiding the loop around locking tdb traversal.

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


- Log -----------------------------------------------------------------
commit 1db4d383c1921e4c5b6e9ea4b63e035c363bce30
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 16 19:00:05 2014 +0100

    s3-winbind: separate child response sock write
    
    For consistency with request read side.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Jan 20 14:23:10 CET 2014 on sn-devel-104

commit 8f3cf00c20415de9b29483f49739d03a45b6532d
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 16 19:00:04 2014 +0100

    s3-winbind: only pass needed args to child_read_request
    
    The socket and request are the only arguments required, the entire
    winbind child state structure is not needed.
    This allows for the separation of the request and response structures,
    which is useful for asynchronous conversion.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

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

Summary of changes:
 source3/winbindd/winbindd_dual.c |   75 +++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 38 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 1d6a5ba..de254e9 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -49,42 +49,34 @@ static struct winbindd_child *winbindd_children = NULL;
 
 /* Read some data from a client connection */
 
-static NTSTATUS child_read_request(struct winbindd_cli_state *state)
+static NTSTATUS child_read_request(int sock, struct winbindd_request *wreq)
 {
 	NTSTATUS status;
 
-	/* Read data */
-
-	status = read_data(state->sock, (char *)state->request,
-			   sizeof(*state->request));
-
+	status = read_data(sock, (char *)wreq, sizeof(*wreq));
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(3, ("child_read_request: read_data failed: %s\n",
 			  nt_errstr(status)));
 		return status;
 	}
 
-	if (state->request->extra_len == 0) {
-		state->request->extra_data.data = NULL;
+	if (wreq->extra_len == 0) {
+		wreq->extra_data.data = NULL;
 		return NT_STATUS_OK;
 	}
 
-	DEBUG(10, ("Need to read %d extra bytes\n", (int)state->request->extra_len));
+	DEBUG(10, ("Need to read %d extra bytes\n", (int)wreq->extra_len));
 
-	state->request->extra_data.data =
-		SMB_MALLOC_ARRAY(char, state->request->extra_len + 1);
-
-	if (state->request->extra_data.data == NULL) {
+	wreq->extra_data.data = SMB_MALLOC_ARRAY(char, wreq->extra_len + 1);
+	if (wreq->extra_data.data == NULL) {
 		DEBUG(0, ("malloc failed\n"));
 		return NT_STATUS_NO_MEMORY;
 	}
 
 	/* Ensure null termination */
-	state->request->extra_data.data[state->request->extra_len] = '\0';
-
-	status= read_data(state->sock, state->request->extra_data.data,
-			  state->request->extra_len);
+	wreq->extra_data.data[wreq->extra_len] = '\0';
 
+	status = read_data(sock, wreq->extra_data.data, wreq->extra_len);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Could not read extra data: %s\n",
 			  nt_errstr(status)));
@@ -92,6 +84,31 @@ static NTSTATUS child_read_request(struct winbindd_cli_state *state)
 	return status;
 }
 
+static NTSTATUS child_write_response(int sock, struct winbindd_response *wrsp)
+{
+	struct iovec iov[2];
+	int iov_count;
+
+	iov[0].iov_base = (void *)wrsp;
+	iov[0].iov_len = sizeof(struct winbindd_response);
+	iov_count = 1;
+
+	if (wrsp->length > sizeof(struct winbindd_response)) {
+		iov[1].iov_base = (void *)wrsp->extra_data.data;
+		iov[1].iov_len = wrsp->length-iov[0].iov_len;
+		iov_count = 2;
+	}
+
+	DEBUG(10, ("Writing %d bytes to parent\n", (int)wrsp->length));
+
+	if (write_data_iov(sock, iov, iov_count) != wrsp->length) {
+		DEBUG(0, ("Could not write result\n"));
+		return NT_STATUS_INVALID_HANDLE;
+	}
+
+	return NT_STATUS_OK;
+}
+
 /*
  * Do winbind child async request. This is not simply wb_simple_trans. We have
  * to do the queueing ourselves because while a request is queued, the child
@@ -1323,11 +1340,9 @@ static void child_handler(struct tevent_context *ev, struct tevent_fd *fde,
 	struct child_handler_state *state =
 		(struct child_handler_state *)private_data;
 	NTSTATUS status;
-	struct iovec iov[2];
-	int iov_count;
 
 	/* fetch a request from the main daemon */
-	status = child_read_request(&state->cli);
+	status = child_read_request(state->cli.sock, state->cli.request);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		/* we lost contact with our parent */
@@ -1347,24 +1362,8 @@ static void child_handler(struct tevent_context *ev, struct tevent_fd *fde,
 
 	SAFE_FREE(state->cli.request->extra_data.data);
 
-	iov[0].iov_base = (void *)state->cli.response;
-	iov[0].iov_len = sizeof(struct winbindd_response);
-	iov_count = 1;
-
-	if (state->cli.response->length >
-	    sizeof(struct winbindd_response)) {
-		iov[1].iov_base =
-			(void *)state->cli.response->extra_data.data;
-		iov[1].iov_len = state->cli.response->length-iov[0].iov_len;
-		iov_count = 2;
-	}
-
-	DEBUG(10, ("Writing %d bytes to parent\n",
-		   (int)state->cli.response->length));
-
-	if (write_data_iov(state->cli.sock, iov, iov_count) !=
-	    state->cli.response->length) {
-		DEBUG(0, ("Could not write result\n"));
+	status = child_write_response(state->cli.sock, state->cli.response);
+	if (!NT_STATUS_IS_OK(status)) {
 		exit(1);
 	}
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list