svn commit: samba r17318 - in branches/SAMBA_4_0/source/libcli/smb2: .

metze at samba.org metze at samba.org
Sun Jul 30 17:29:02 GMT 2006


Author: metze
Date: 2006-07-30 17:29:02 +0000 (Sun, 30 Jul 2006)
New Revision: 17318

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

Log:
make better usage of the composite api

metze
Modified:
   branches/SAMBA_4_0/source/libcli/smb2/connect.c
   branches/SAMBA_4_0/source/libcli/smb2/session.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/smb2/connect.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/connect.c	2006-07-30 16:48:41 UTC (rev 17317)
+++ branches/SAMBA_4_0/source/libcli/smb2/connect.c	2006-07-30 17:29:02 UTC (rev 17318)
@@ -171,39 +171,25 @@
 	struct nbt_name name;
 	struct composite_context *creq;
 
-	c = talloc_zero(mem_ctx, struct composite_context);
+	c = composite_create(mem_ctx, ev);
 	if (c == NULL) return NULL;
 
 	state = talloc(c, struct smb2_connect_state);
-	if (state == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
-
-	c->state = COMPOSITE_STATE_IN_PROGRESS;
+	if (composite_nomem(state, c)) return c;
 	c->private_data = state;
-	c->event_ctx = ev;
 
 	state->credentials = credentials;
 	state->host = talloc_strdup(c, host);
+	if (composite_nomem(state->host, c)) return c;
 	state->share = talloc_strdup(c, share);
-	if (state->host == NULL || state->share == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
+	if (composite_nomem(state->share, c)) return c;
 
 	ZERO_STRUCT(name);
 	name.name = host;
 
 	creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
-
 	composite_continue(c, creq, continue_resolve, c);
-
 	return c;
-
-failed:
-	composite_error(c, c->status);
-	return c;
 }
 
 /*

Modified: branches/SAMBA_4_0/source/libcli/smb2/session.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/smb2/session.c	2006-07-30 16:48:41 UTC (rev 17317)
+++ branches/SAMBA_4_0/source/libcli/smb2/session.c	2006-07-30 17:29:02 UTC (rev 17318)
@@ -196,18 +196,12 @@
 	struct composite_context *c;
 	struct smb2_session_state *state;
 
-	c = talloc_zero(session, struct composite_context);
+	c = composite_create(session, session->transport->socket->event.ctx);
 	if (c == NULL) return NULL;
 
 	state = talloc(c, struct smb2_session_state);
-	if (state == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
-
-	c->state = COMPOSITE_STATE_IN_PROGRESS;
+	if (composite_nomem(state, c)) return c;
 	c->private_data = state;
-	c->event_ctx = session->transport->socket->event.ctx;
 
 	ZERO_STRUCT(state->io);
 	state->io.in._pad = 0x0000;
@@ -216,48 +210,30 @@
 	state->io.in.unknown4 = 0; /* uint64_t */
 
 	c->status = gensec_set_credentials(session->gensec, credentials);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	c->status = gensec_set_target_hostname(session->gensec, 
 					       session->transport->socket->hostname);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	c->status = gensec_set_target_service(session->gensec, "cifs");
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	c->status = gensec_start_mech_by_oid(session->gensec, GENSEC_OID_SPNEGO);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	c->status = gensec_update(session->gensec, c, 
 				  session->transport->negotiate.secblob,
 				  &state->io.in.secblob);
 	if (!NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
-		goto failed;
+		composite_error(c, c->status);
+		return c;
 	}
 	state->gensec_status = c->status;
 		
 	state->req = smb2_session_setup_send(session, &state->io);
-	if (state->req == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
-
-	state->req->async.fn = session_request_handler;
-	state->req->async.private = c;
-
+	composite_continue_smb2(c, state->req, session_request_handler, c);
 	return c;
-
-failed:
-	composite_error(c, c->status);
-	return c;
 }
 
 /*



More information about the samba-cvs mailing list