summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-22 02:51:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:06 -0500
commitaefaa18554a55da5b5d9fdb9815eb246b539c8a2 (patch)
tree3a17a5c8251b1e72a72ea7fdfd96db09face2fc3 /source4/libcli
parentba5d77bebdcf041a3d2b3dd53fb83fe49ecc4100 (diff)
downloadsamba-aefaa18554a55da5b5d9fdb9815eb246b539c8a2.tar.gz
samba-aefaa18554a55da5b5d9fdb9815eb246b539c8a2.tar.bz2
samba-aefaa18554a55da5b5d9fdb9815eb246b539c8a2.zip
r4924: continue the effort to simplify and generalise the composite
interface. This patch removes the "stage" variable, which is really better suited to the backend state structures (This used to be commit 39da684ea8bc72d7a4a12c00eaad56b4f32890a9)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/composite/composite.h3
-rw-r--r--source4/libcli/composite/connect.c15
-rw-r--r--source4/libcli/composite/loadfile.c9
-rw-r--r--source4/libcli/composite/savefile.c10
-rw-r--r--source4/libcli/raw/clisocket.c7
5 files changed, 22 insertions, 22 deletions
diff --git a/source4/libcli/composite/composite.h b/source4/libcli/composite/composite.h
index fba458795c..35d6d94878 100644
--- a/source4/libcli/composite/composite.h
+++ b/source4/libcli/composite/composite.h
@@ -33,9 +33,6 @@ struct smbcli_composite {
/* the external state - will be queried by the caller */
enum smbcli_request_state state;
- /* the internal stage */
- uint16_t stage;
-
/* a private pointer for use by the composite function
implementation */
void *private;
diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c
index 4f6df154a7..2663c789e4 100644
--- a/source4/libcli/composite/connect.c
+++ b/source4/libcli/composite/connect.c
@@ -34,6 +34,7 @@ enum connect_stage {CONNECT_RESOLVE,
CONNECT_TCON};
struct connect_state {
+ enum connect_stage stage;
struct smbcli_socket *sock;
struct smbcli_transport *transport;
struct smbcli_session *session;
@@ -61,7 +62,7 @@ static NTSTATUS connect_send_negprot(struct smbcli_composite *c,
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_NEGPROT;
+ state->stage = CONNECT_NEGPROT;
return NT_STATUS_OK;
}
@@ -141,7 +142,7 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_TCON;
+ state->stage = CONNECT_TCON;
return NT_STATUS_OK;
}
@@ -180,7 +181,7 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
state->creq->async.fn = composite_handler;
state->creq->async.private = c;
- c->stage = CONNECT_SESSION_SETUP;
+ state->stage = CONNECT_SESSION_SETUP;
return NT_STATUS_OK;
}
@@ -240,7 +241,7 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
state->req->async.fn = request_handler;
state->req->async.private = c;
- c->stage = CONNECT_SESSION_REQUEST;
+ state->stage = CONNECT_SESSION_REQUEST;
return NT_STATUS_OK;
}
@@ -262,7 +263,7 @@ static NTSTATUS connect_resolve(struct smbcli_composite *c,
state->creq = smbcli_sock_connect_send(state->sock, address, state->io->in.port);
NT_STATUS_HAVE_NO_MEMORY(state->creq);
- c->stage = CONNECT_SOCKET;
+ state->stage = CONNECT_SOCKET;
state->creq->async.private = c;
state->creq->async.fn = composite_handler;
@@ -277,7 +278,7 @@ static void state_handler(struct smbcli_composite *c)
{
struct connect_state *state = talloc_get_type(c->private, struct connect_state);
- switch (c->stage) {
+ switch (state->stage) {
case CONNECT_RESOLVE:
c->status = connect_resolve(c, state->io);
break;
@@ -346,9 +347,9 @@ struct smbcli_composite *smb_composite_connect_send(struct smb_composite_connect
if (state->sock == NULL) goto failed;
state->io = io;
+ state->stage = CONNECT_RESOLVE;
c->state = SMBCLI_REQUEST_SEND;
- c->stage = CONNECT_RESOLVE;
c->event_ctx = state->sock->event.ctx;
c->private = state;
diff --git a/source4/libcli/composite/loadfile.c b/source4/libcli/composite/loadfile.c
index 8290876224..b95f43149e 100644
--- a/source4/libcli/composite/loadfile.c
+++ b/source4/libcli/composite/loadfile.c
@@ -33,6 +33,7 @@ enum loadfile_stage {LOADFILE_OPEN, LOADFILE_READ, LOADFILE_CLOSE};
static void loadfile_handler(struct smbcli_request *req);
struct loadfile_state {
+ enum loadfile_stage stage;
struct smb_composite_loadfile *io;
struct smbcli_request *req;
union smb_open *io_open;
@@ -62,7 +63,7 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
/* call the handler again when the close is done */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_CLOSE;
+ state->stage = LOADFILE_CLOSE;
return NT_STATUS_OK;
}
@@ -113,7 +114,7 @@ static NTSTATUS loadfile_open(struct smbcli_composite *c,
/* call the handler again when the first read is done */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_READ;
+ state->stage = LOADFILE_READ;
talloc_free(state->io_open);
@@ -187,7 +188,7 @@ static void loadfile_handler(struct smbcli_request *req)
/* when this handler is called, the stage indicates what
call has just finished */
- switch (c->stage) {
+ switch (state->stage) {
case LOADFILE_OPEN:
c->status = loadfile_open(c, state->io);
break;
@@ -251,7 +252,7 @@ struct smbcli_composite *smb_composite_loadfile_send(struct smbcli_tree *tree,
/* setup the callback handler */
state->req->async.fn = loadfile_handler;
state->req->async.private = c;
- c->stage = LOADFILE_OPEN;
+ state->stage = LOADFILE_OPEN;
return c;
diff --git a/source4/libcli/composite/savefile.c b/source4/libcli/composite/savefile.c
index 06eb13bb01..29d26c7eba 100644
--- a/source4/libcli/composite/savefile.c
+++ b/source4/libcli/composite/savefile.c
@@ -29,10 +29,10 @@
/* the stages of this call */
enum savefile_stage {SAVEFILE_OPEN, SAVEFILE_WRITE, SAVEFILE_CLOSE};
-
static void savefile_handler(struct smbcli_request *req);
struct savefile_state {
+ enum savefile_stage stage;
off_t total_written;
struct smb_composite_savefile *io;
union smb_open *io_open;
@@ -62,7 +62,7 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the close is done */
- c->stage = SAVEFILE_CLOSE;
+ state->stage = SAVEFILE_CLOSE;
state->req->async.fn = savefile_handler;
state->req->async.private = c;
@@ -106,7 +106,7 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
NT_STATUS_HAVE_NO_MEMORY(state->req);
/* call the handler again when the first write is done */
- c->stage = SAVEFILE_WRITE;
+ state->stage = SAVEFILE_WRITE;
state->req->async.fn = savefile_handler;
state->req->async.private = c;
talloc_free(state->io_open);
@@ -189,7 +189,7 @@ static void savefile_handler(struct smbcli_request *req)
/* when this handler is called, the stage indicates what
call has just finished */
- switch (c->stage) {
+ switch (state->stage) {
case SAVEFILE_OPEN:
c->status = savefile_open(c, state->io);
break;
@@ -226,12 +226,12 @@ struct smbcli_composite *smb_composite_savefile_send(struct smbcli_tree *tree,
if (c == NULL) goto failed;
c->state = SMBCLI_REQUEST_SEND;
- c->stage = SAVEFILE_OPEN;
c->event_ctx = tree->session->transport->socket->event.ctx;
state = talloc(c, struct savefile_state);
if (state == NULL) goto failed;
+ state->stage = SAVEFILE_OPEN;
state->total_written = 0;
state->io = io;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index e981049535..cbbd6490bd 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -30,6 +30,7 @@
this private structure is used during async connection handling
*/
struct clisocket_connect {
+ int port_num;
int *iports;
struct smbcli_socket *sock;
const char *dest_host;
@@ -95,8 +96,8 @@ static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_even
}
/* that port failed - try the next port */
- for (i=c->stage+1;conn->iports[i];i++) {
- c->stage = i;
+ for (i=conn->port_num+1;conn->iports[i];i++) {
+ conn->port_num = i;
c->status = smbcli_sock_connect_one(conn->sock,
conn->dest_host,
conn->iports[i]);
@@ -204,7 +205,7 @@ struct smbcli_composite *smbcli_sock_connect_send(struct smbcli_socket *sock,
/* startup the connect process for each port in turn until one
succeeds or tells us that it is pending */
for (i=0;conn->iports[i];i++) {
- c->stage = i;
+ conn->port_num = i;
conn->sock->port = conn->iports[i];
c->status = smbcli_sock_connect_one(sock,
conn->dest_host,