svn commit: samba r4924 - in branches/SAMBA_4_0/source/libcli: composite raw

tridge at samba.org tridge at samba.org
Sat Jan 22 02:51:39 GMT 2005


Author: tridge
Date: 2005-01-22 02:51:39 +0000 (Sat, 22 Jan 2005)
New Revision: 4924

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4924

Log:
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

Modified:
   branches/SAMBA_4_0/source/libcli/composite/composite.h
   branches/SAMBA_4_0/source/libcli/composite/connect.c
   branches/SAMBA_4_0/source/libcli/composite/loadfile.c
   branches/SAMBA_4_0/source/libcli/composite/savefile.c
   branches/SAMBA_4_0/source/libcli/raw/clisocket.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/composite/composite.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/composite.h	2005-01-22 02:39:05 UTC (rev 4923)
+++ branches/SAMBA_4_0/source/libcli/composite/composite.h	2005-01-22 02:51:39 UTC (rev 4924)
@@ -33,9 +33,6 @@
 	/* 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;

Modified: branches/SAMBA_4_0/source/libcli/composite/connect.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/connect.c	2005-01-22 02:39:05 UTC (rev 4923)
+++ branches/SAMBA_4_0/source/libcli/composite/connect.c	2005-01-22 02:51:39 UTC (rev 4924)
@@ -34,6 +34,7 @@
 		    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 @@
 
 	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 @@
 
 	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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 {
 	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 @@
 	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;
 

Modified: branches/SAMBA_4_0/source/libcli/composite/loadfile.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/loadfile.c	2005-01-22 02:39:05 UTC (rev 4923)
+++ branches/SAMBA_4_0/source/libcli/composite/loadfile.c	2005-01-22 02:51:39 UTC (rev 4924)
@@ -33,6 +33,7 @@
 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 @@
 	/* 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 @@
 	/* 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 @@
 
 	/* 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 @@
 	/* 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;
 

Modified: branches/SAMBA_4_0/source/libcli/composite/savefile.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/savefile.c	2005-01-22 02:39:05 UTC (rev 4923)
+++ branches/SAMBA_4_0/source/libcli/composite/savefile.c	2005-01-22 02:51:39 UTC (rev 4924)
@@ -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 @@
 	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 @@
 	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 @@
 
 	/* 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 @@
 	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;
 

Modified: branches/SAMBA_4_0/source/libcli/raw/clisocket.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/raw/clisocket.c	2005-01-22 02:39:05 UTC (rev 4923)
+++ branches/SAMBA_4_0/source/libcli/raw/clisocket.c	2005-01-22 02:51:39 UTC (rev 4924)
@@ -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 @@
 	}
 
 	/* 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 @@
 	/* 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, 



More information about the samba-cvs mailing list