summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-22 08:38:59 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-22 08:44:08 +0200
commit9f2b3b0be6837c280a033b2fddf8fd433421d206 (patch)
treec555b4aab59c8cad110f405df931e14f50d72204
parentb94a7caa3ada6764c29ab75bf72fbb153c650bc0 (diff)
downloadsamba-9f2b3b0be6837c280a033b2fddf8fd433421d206.tar.gz
samba-9f2b3b0be6837c280a033b2fddf8fd433421d206.tar.xz
samba-9f2b3b0be6837c280a033b2fddf8fd433421d206.zip
s3:libsmb: move cli_state->pending to cli_state->conn.pending
metze
-rw-r--r--source3/include/client.h5
-rw-r--r--source3/libsmb/async_smb.c50
-rw-r--r--source3/libsmb/clientgen.c6
-rw-r--r--source3/libsmb/smb2cli_base.c43
4 files changed, 55 insertions, 49 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index cfc0b417091..72bb25a2d7e 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -125,7 +125,10 @@ struct cli_state {
char *dfs_mountpoint;
struct tevent_queue *outgoing;
- struct tevent_req **pending;
+
+ struct {
+ struct tevent_req **pending;
+ } conn;
struct {
uint16_t mid;
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index b621919dbd1..402abb2c333 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;
@@ -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);
@@ -953,7 +955,7 @@ 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));
+ || (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 766817d98f0..b84b1812e82 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -237,7 +237,7 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
if (cli->outgoing == NULL) {
goto error;
}
- cli->pending = NULL;
+ cli->conn.pending = NULL;
cli->desthost = talloc_strdup(cli, desthost);
if (cli->desthost == NULL) {
@@ -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 da1d598fa3e..037127ea07b 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);
@@ -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;