The branch, master has been updated via a11cc88 s3:libsmb: move cli_state->outgoing to cli_state->conn.outgoing via 9f2b3b0 s3:libsmb: move cli_state->pending to cli_state->conn.pending via b94a7ca s3:libsmb: fix compiler warnings in cli_state_create() from 2d21fe0 s4-messaging: fixed the removal of messaging sockets in child tasks
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a11cc880ef0a7e105c46b835fb3c793da7cabb53 Author: Stefan Metzmacher <me...@samba.org> Date: Fri Jul 22 08:41:20 2011 +0200 s3:libsmb: move cli_state->outgoing to cli_state->conn.outgoing metze Autobuild-User: Stefan Metzmacher <me...@samba.org> Autobuild-Date: Fri Jul 22 09:53:59 CEST 2011 on sn-devel-104 commit 9f2b3b0be6837c280a033b2fddf8fd433421d206 Author: Stefan Metzmacher <me...@samba.org> Date: Fri Jul 22 08:38:59 2011 +0200 s3:libsmb: move cli_state->pending to cli_state->conn.pending metze commit b94a7caa3ada6764c29ab75bf72fbb153c650bc0 Author: Stefan Metzmacher <me...@samba.org> Date: Fri Jul 22 08:38:02 2011 +0200 s3:libsmb: fix compiler warnings in cli_state_create() metze ----------------------------------------------------------------------- Summary of changes: source3/include/client.h | 6 +++- source3/libsmb/async_smb.c | 54 +++++++++++++++++++++------------------- source3/libsmb/clientgen.c | 20 +++++++------- source3/libsmb/smb2cli_base.c | 45 +++++++++++++++++---------------- 4 files changed, 65 insertions(+), 60 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/client.h b/source3/include/client.h index cfc0b41..26b8fcb 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -124,8 +124,10 @@ struct cli_state { /* Where (if anywhere) this is mounted under DFS. */ char *dfs_mountpoint; - struct tevent_queue *outgoing; - struct tevent_req **pending; + struct { + struct tevent_queue *outgoing; + struct tevent_req **pending; + } conn; struct { uint16_t mid; diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index b621919..462a6dc 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -93,7 +93,7 @@ struct cli_smb_state { static uint16_t cli_alloc_mid(struct cli_state *cli) { - int num_pending = talloc_array_length(cli->pending); + int num_pending = talloc_array_length(cli->conn.pending); uint16_t result; while (true) { @@ -105,7 +105,7 @@ static uint16_t cli_alloc_mid(struct cli_state *cli) } for (i=0; i<num_pending; i++) { - if (result == cli_smb_req_mid(cli->pending[i])) { + if (result == cli_smb_req_mid(cli->conn.pending[i])) { break; } } @@ -121,7 +121,7 @@ void cli_smb_req_unset_pending(struct tevent_req *req) struct cli_smb_state *state = tevent_req_data( req, struct cli_smb_state); struct cli_state *cli = state->cli; - int num_pending = talloc_array_length(cli->pending); + int num_pending = talloc_array_length(cli->conn.pending); int i; if (state->mid != 0) { @@ -138,12 +138,12 @@ void cli_smb_req_unset_pending(struct tevent_req *req) * cli->pending. So if nothing is pending anymore, we need to * delete the socket read fde. */ - TALLOC_FREE(cli->pending); + TALLOC_FREE(cli->conn.pending); return; } for (i=0; i<num_pending; i++) { - if (req == cli->pending[i]) { + if (req == cli->conn.pending[i]) { break; } } @@ -151,22 +151,23 @@ void cli_smb_req_unset_pending(struct tevent_req *req) /* * Something's seriously broken. Just returning here is the * right thing nevertheless, the point of this routine is to - * remove ourselves from cli->pending. + * remove ourselves from cli->conn.pending. */ return; } /* - * Remove ourselves from the cli->pending array + * Remove ourselves from the cli->conn.pending array */ - cli->pending[i] = cli->pending[num_pending-1]; + cli->conn.pending[i] = cli->conn.pending[num_pending-1]; /* * No NULL check here, we're shrinking by sizeof(void *), and * talloc_realloc just adjusts the size for this. */ - cli->pending = talloc_realloc(NULL, cli->pending, struct tevent_req *, - num_pending - 1); + cli->conn.pending = talloc_realloc(NULL, cli->conn.pending, + struct tevent_req *, + num_pending - 1); return; } @@ -195,15 +196,15 @@ bool cli_smb_req_set_pending(struct tevent_req *req) struct tevent_req *subreq; cli = state->cli; - num_pending = talloc_array_length(cli->pending); + num_pending = talloc_array_length(cli->conn.pending); - pending = talloc_realloc(cli, cli->pending, struct tevent_req *, + pending = talloc_realloc(cli, cli->conn.pending, struct tevent_req *, num_pending+1); if (pending == NULL) { return false; } pending[num_pending] = req; - cli->pending = pending; + cli->conn.pending = pending; talloc_set_destructor(req, cli_smb_req_destructor); if (num_pending > 0) { @@ -214,7 +215,7 @@ bool cli_smb_req_set_pending(struct tevent_req *req) * We're the first ones, add the read_smb request that waits for the * answer from the server */ - subreq = read_smb_send(cli->pending, state->ev, cli->fd); + subreq = read_smb_send(cli->conn.pending, state->ev, cli->fd); if (subreq == NULL) { cli_smb_req_unset_pending(req); return false; @@ -429,7 +430,7 @@ static NTSTATUS cli_smb_req_iov_send(struct tevent_req *req, iov[0].iov_len = talloc_get_size(buf); iov_count = 1; } - subreq = writev_send(state, state->ev, state->cli->outgoing, + subreq = writev_send(state, state->ev, state->cli->conn.outgoing, state->cli->fd, false, iov, iov_count); if (subreq == NULL) { return NT_STATUS_NO_MEMORY; @@ -579,10 +580,10 @@ static void cli_smb_received(struct tevent_req *subreq) } mid = SVAL(inbuf, smb_mid); - num_pending = talloc_array_length(cli->pending); + num_pending = talloc_array_length(cli->conn.pending); for (i=0; i<num_pending; i++) { - if (mid == cli_smb_req_mid(cli->pending[i])) { + if (mid == cli_smb_req_mid(cli->conn.pending[i])) { break; } } @@ -611,7 +612,7 @@ static void cli_smb_received(struct tevent_req *subreq) } } - req = cli->pending[i]; + req = cli->conn.pending[i]; state = tevent_req_data(req, struct cli_smb_state); if (!oplock_break /* oplock breaks are not signed */ @@ -648,13 +649,14 @@ static void cli_smb_received(struct tevent_req *subreq) TALLOC_FREE(chain); } done: - if (talloc_array_length(cli->pending) > 0) { + if (talloc_array_length(cli->conn.pending) > 0) { /* * Set up another read request for the other pending cli_smb * requests */ - state = tevent_req_data(cli->pending[0], struct cli_smb_state); - subreq = read_smb_send(cli->pending, state->ev, cli->fd); + state = tevent_req_data(cli->conn.pending[0], + struct cli_smb_state); + subreq = read_smb_send(cli->conn.pending, state->ev, cli->fd); if (subreq == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -665,11 +667,11 @@ static void cli_smb_received(struct tevent_req *subreq) fail: /* * Cancel all pending requests. We don't do a for-loop walking - * cli->pending because that array changes in + * cli->conn.pending because that array changes in * cli_smb_req_destructor(). */ - while (talloc_array_length(cli->pending) > 0) { - req = cli->pending[0]; + while (talloc_array_length(cli->conn.pending) > 0) { + req = cli->conn.pending[0]; talloc_set_destructor(req, NULL); cli_smb_req_unset_pending(req); tevent_req_nterror(req, status); @@ -952,8 +954,8 @@ NTSTATUS cli_smb_chain_send(struct tevent_req **reqs, int num_reqs) bool cli_has_async_calls(struct cli_state *cli) { - return ((tevent_queue_length(cli->outgoing) != 0) - || (talloc_array_length(cli->pending) != 0)); + return ((tevent_queue_length(cli->conn.outgoing) != 0) + || (talloc_array_length(cli->conn.pending) != 0)); } struct cli_smb_oplock_break_waiter_state { diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 1ac5c2e..c394197 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -169,7 +169,7 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, struct cli_state *cli = NULL; bool allow_smb_signing = false; bool mandatory_signing = false; - size_t length; + socklen_t ss_length; int ret; /* Check the effective uid - make sure we are not setuid */ @@ -233,11 +233,11 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, goto error; } - cli->outgoing = tevent_queue_create(cli, "cli_outgoing"); - if (cli->outgoing == NULL) { + cli->conn.outgoing = tevent_queue_create(cli, "cli_outgoing"); + if (cli->conn.outgoing == NULL) { goto error; } - cli->pending = NULL; + cli->conn.pending = NULL; cli->desthost = talloc_strdup(cli, desthost); if (cli->desthost == NULL) { @@ -246,17 +246,17 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, cli->fd = fd; - length = sizeof(cli->src_ss); + ss_length = sizeof(cli->src_ss); ret = getsockname(fd, (struct sockaddr *)(void *)&cli->src_ss, - &length); + &ss_length); if (ret == -1) { goto error; } - length = sizeof(cli->dest_ss); + ss_length = sizeof(cli->dest_ss); ret = getpeername(fd, (struct sockaddr *)(void *)&cli->dest_ss, - &length); + &ss_length); if (ret == -1) { goto error; } @@ -329,8 +329,8 @@ static void _cli_shutdown(struct cli_state *cli) /* * Need to free pending first, they remove themselves */ - while (cli->pending) { - talloc_free(cli->pending[0]); + while (cli->conn.pending) { + talloc_free(cli->conn.pending[0]); } TALLOC_FREE(cli); } diff --git a/source3/libsmb/smb2cli_base.c b/source3/libsmb/smb2cli_base.c index da1d598..a1ecfb4 100644 --- a/source3/libsmb/smb2cli_base.c +++ b/source3/libsmb/smb2cli_base.c @@ -48,7 +48,7 @@ static void smb2cli_req_unset_pending(struct tevent_req *req) tevent_req_data(req, struct smb2cli_req_state); struct cli_state *cli = state->cli; - int num_pending = talloc_array_length(cli->pending); + int num_pending = talloc_array_length(cli->conn.pending); int i; talloc_set_destructor(req, NULL); @@ -56,15 +56,15 @@ static void smb2cli_req_unset_pending(struct tevent_req *req) if (num_pending == 1) { /* * The pending read_smb tevent_req is a child of - * cli->pending. So if nothing is pending anymore, we need to - * delete the socket read fde. + * cli->conn.pending. So if nothing is pending anymore, + * we need to delete the socket read fde. */ - TALLOC_FREE(cli->pending); + TALLOC_FREE(cli->conn.pending); return; } for (i=0; i<num_pending; i++) { - if (req == cli->pending[i]) { + if (req == cli->conn.pending[i]) { break; } } @@ -72,7 +72,7 @@ static void smb2cli_req_unset_pending(struct tevent_req *req) /* * Something's seriously broken. Just returning here is the * right thing nevertheless, the point of this routine is to - * remove ourselves from cli->pending. + * remove ourselves from cli->conn.pending. */ return; } @@ -81,15 +81,16 @@ static void smb2cli_req_unset_pending(struct tevent_req *req) * Remove ourselves from the cli->pending array */ for (; i < (num_pending - 1); i++) { - cli->pending[i] = cli->pending[i+1]; + cli->conn.pending[i] = cli->conn.pending[i+1]; } /* * No NULL check here, we're shrinking by sizeof(void *), and * talloc_realloc just adjusts the size for this. */ - cli->pending = talloc_realloc(NULL, cli->pending, struct tevent_req *, - num_pending - 1); + cli->conn.pending = talloc_realloc(NULL, cli->conn.pending, + struct tevent_req *, + num_pending - 1); return; } @@ -112,15 +113,15 @@ static bool smb2cli_req_set_pending(struct tevent_req *req) struct tevent_req *subreq; cli = state->cli; - num_pending = talloc_array_length(cli->pending); + num_pending = talloc_array_length(cli->conn.pending); - pending = talloc_realloc(cli, cli->pending, struct tevent_req *, + pending = talloc_realloc(cli, cli->conn.pending, struct tevent_req *, num_pending+1); if (pending == NULL) { return false; } pending[num_pending] = req; - cli->pending = pending; + cli->conn.pending = pending; talloc_set_destructor(req, smb2cli_req_destructor); if (num_pending > 0) { @@ -131,7 +132,7 @@ static bool smb2cli_req_set_pending(struct tevent_req *req) * We're the first ones, add the read_smb request that waits for the * answer from the server */ - subreq = read_smb_send(cli->pending, state->ev, cli->fd); + subreq = read_smb_send(cli->conn.pending, state->ev, cli->fd); if (subreq == NULL) { smb2cli_req_unset_pending(req); return false; @@ -149,14 +150,14 @@ static void smb2cli_notify_pending(struct cli_state *cli, NTSTATUS status) /* * Cancel all pending requests. We don't do a for-loop walking - * cli->pending because that array changes in + * cli->conn.pending because that array changes in * cli_smb_req_destructor(). */ - while (talloc_array_length(cli->pending) > 0) { + while (talloc_array_length(cli->conn.pending) > 0) { struct tevent_req *req; struct smb2cli_req_state *state; - req = cli->pending[0]; + req = cli->conn.pending[0]; state = tevent_req_data(req, struct smb2cli_req_state); smb2cli_req_unset_pending(req); @@ -292,7 +293,7 @@ NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs, iov[0].iov_base = state->nbt; iov[0].iov_len = sizeof(state->nbt); - subreq = writev_send(state, state->ev, state->cli->outgoing, + subreq = writev_send(state, state->ev, state->cli->conn.outgoing, state->cli->fd, false, iov, num_iov); if (subreq == NULL) { return NT_STATUS_NO_MEMORY; @@ -452,11 +453,11 @@ inval: static struct tevent_req *cli_smb2_find_pending(struct cli_state *cli, uint64_t mid) { - int num_pending = talloc_array_length(cli->pending); + int num_pending = talloc_array_length(cli->conn.pending); int i; for (i=0; i<num_pending; i++) { - struct tevent_req *req = cli->pending[i]; + struct tevent_req *req = cli->conn.pending[i]; struct smb2cli_req_state *state = tevent_req_data(req, struct smb2cli_req_state); @@ -559,19 +560,19 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq) TALLOC_FREE(frame); - num_pending = talloc_array_length(cli->pending); + num_pending = talloc_array_length(cli->conn.pending); if (num_pending == 0) { /* no more pending requests, so we are done for now */ return; } - req = cli->pending[0]; + req = cli->conn.pending[0]; state = tevent_req_data(req, struct smb2cli_req_state); /* * add the read_smb request that waits for the * next answer from the server */ - subreq = read_smb_send(cli->pending, state->ev, cli->fd); + subreq = read_smb_send(cli->conn.pending, state->ev, cli->fd); if (subreq == NULL) { smb2cli_notify_pending(cli, NT_STATUS_NO_MEMORY); return; -- Samba Shared Repository