diff options
| author | David Disseldorp <ddiss@samba.org> | 2014-01-16 19:00:05 +0100 |
|---|---|---|
| committer | Volker Lendecke <vl@samba.org> | 2014-01-20 14:23:09 +0100 |
| commit | 1db4d383c1921e4c5b6e9ea4b63e035c363bce30 (patch) | |
| tree | 873a1767bbdf73e8c4391d41ed77db2472f7909c /source3 | |
| parent | 8f3cf00c20415de9b29483f49739d03a45b6532d (diff) | |
| download | samba-1db4d383c1921e4c5b6e9ea4b63e035c363bce30.tar.gz samba-1db4d383c1921e4c5b6e9ea4b63e035c363bce30.tar.xz samba-1db4d383c1921e4c5b6e9ea4b63e035c363bce30.zip | |
s3-winbind: separate child response sock write
For consistency with request read side.
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jan 20 14:23:10 CET 2014 on sn-devel-104
Diffstat (limited to 'source3')
| -rw-r--r-- | source3/winbindd/winbindd_dual.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 18ec3dd900..de254e90e9 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -84,6 +84,31 @@ static NTSTATUS child_read_request(int sock, struct winbindd_request *wreq) 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 @@ -1315,8 +1340,6 @@ 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.sock, state->cli.request); @@ -1339,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); } } |
