svn commit: samba r4936 - in branches/SAMBA_4_0/source/libcli/composite: .

tridge at samba.org tridge at samba.org
Sun Jan 23 08:16:16 GMT 2005


Author: tridge
Date: 2005-01-23 08:16:16 +0000 (Sun, 23 Jan 2005)
New Revision: 4936

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

Log:
moved to a convention where the completion function is only called in
one place. This makes the code more robust, and simpler (it would have
prevented the error that volker found).

Modified:
   branches/SAMBA_4_0/source/libcli/composite/loadfile.c
   branches/SAMBA_4_0/source/libcli/composite/savefile.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/composite/loadfile.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/loadfile.c	2005-01-23 00:51:20 UTC (rev 4935)
+++ branches/SAMBA_4_0/source/libcli/composite/loadfile.c	2005-01-23 08:16:16 UTC (rev 4936)
@@ -170,9 +170,6 @@
 	NT_STATUS_NOT_OK_RETURN(status);
 	
 	c->state = SMBCLI_REQUEST_DONE;
-	if (c->async.fn) {
-		c->async.fn(c);
-	}
 
 	return NT_STATUS_OK;
 }
@@ -185,31 +182,31 @@
 {
 	struct smbcli_composite *c = req->async.private;
 	struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
-	NTSTATUS status;
 
 	/* when this handler is called, the stage indicates what
 	   call has just finished */
 	switch (state->stage) {
 	case LOADFILE_OPEN:
-		status = loadfile_open(c, state->io);
+		c->status = loadfile_open(c, state->io);
 		break;
 
 	case LOADFILE_READ:
-		status = loadfile_read(c, state->io);
+		c->status = loadfile_read(c, state->io);
 		break;
 
 	case LOADFILE_CLOSE:
-		status = loadfile_close(c, state->io);
+		c->status = loadfile_close(c, state->io);
 		break;
 	}
 
-	if (!NT_STATUS_IS_OK(status)) {
-		c->status = status;
+	if (!NT_STATUS_IS_OK(c->status)) {
 		c->state = SMBCLI_REQUEST_ERROR;
-		if (c->async.fn) {
-			c->async.fn(c);
-		}
 	}
+
+	if (c->state >= SMBCLI_REQUEST_DONE &&
+	    c->async.fn) {
+		c->async.fn(c);
+	}
 }
 
 /*

Modified: branches/SAMBA_4_0/source/libcli/composite/savefile.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/composite/savefile.c	2005-01-23 00:51:20 UTC (rev 4935)
+++ branches/SAMBA_4_0/source/libcli/composite/savefile.c	2005-01-23 08:16:16 UTC (rev 4936)
@@ -171,9 +171,6 @@
 	}
 	
 	c->state = SMBCLI_REQUEST_DONE;
-	if (c->async.fn) {
-		c->async.fn(c);
-	}
 
 	return NT_STATUS_OK;
 }
@@ -186,31 +183,31 @@
 {
 	struct smbcli_composite *c = req->async.private;
 	struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
-	NTSTATUS status;
 
 	/* when this handler is called, the stage indicates what
 	   call has just finished */
 	switch (state->stage) {
 	case SAVEFILE_OPEN:
-		status = savefile_open(c, state->io);
+		c->status = savefile_open(c, state->io);
 		break;
 
 	case SAVEFILE_WRITE:
-		status = savefile_write(c, state->io);
+		c->status = savefile_write(c, state->io);
 		break;
 
 	case SAVEFILE_CLOSE:
-		status = savefile_close(c, state->io);
+		c->status = savefile_close(c, state->io);
 		break;
 	}
 
-	if (!NT_STATUS_IS_OK(status)) {
-		c->status = status;
+	if (!NT_STATUS_IS_OK(c->status)) {
 		c->state = SMBCLI_REQUEST_ERROR;
-		if (c->async.fn) {
-			c->async.fn(c);
-		}
 	}
+
+	if (c->state >= SMBCLI_REQUEST_DONE &&
+	    c->async.fn) {
+		c->async.fn(c);
+	}
 }
 
 /*



More information about the samba-cvs mailing list