[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Wed Jan 13 08:04:23 MST 2010


The branch, master has been updated
       via  92b87eb... s4:dsdb/repl: reorder dreplsrv_op_notify* functions
       via  e886b6e... s4:dsdb/repl: change dreplsrv_op_notify_send/recv() to tevent_req
      from  232197e... s4:dsdb/common: fix major bug in lsa_BinaryString to ldb_val conversation.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 92b87eb47405b884c0c736e28cd06e6e83d99a1e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 13 16:00:20 2010 +0100

    s4:dsdb/repl: reorder dreplsrv_op_notify* functions
    
    This make the whole async dreplsrv_op_notify_send/recv()
    readable.
    
    metze

commit e886b6e240cde0b2985dcd291f223f5143be8acf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 11 20:00:07 2010 +0100

    s4:dsdb/repl: change dreplsrv_op_notify_send/recv() to tevent_req
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/repl/drepl_notify.c  |  177 +++++++++++++++++++------------------
 source4/dsdb/repl/drepl_service.h |    2 -
 2 files changed, 90 insertions(+), 89 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/repl/drepl_notify.c b/source4/dsdb/repl/drepl_notify.c
index 2f0fa48..8198e4e 100644
--- a/source4/dsdb/repl/drepl_notify.c
+++ b/source4/dsdb/repl/drepl_notify.c
@@ -34,111 +34,118 @@
 #include "librpc/gen_ndr/ndr_drsuapi.h"
 #include "librpc/gen_ndr/ndr_drsblobs.h"
 #include "libcli/composite/composite.h"
+#include "../lib/util/tevent_ntstatus.h"
 
 
 struct dreplsrv_op_notify_state {
-	struct composite_context *creq;
-
-	struct dreplsrv_out_connection *conn;
-
-	struct dreplsrv_drsuapi_connection *drsuapi;
-
-	struct drsuapi_DsBindInfoCtr bind_info_ctr;
-	struct drsuapi_DsBind bind_r;
 	struct dreplsrv_notify_operation *op;
 };
 
+static void dreplsrv_op_notify_connect_done(struct tevent_req *subreq);
+
 /*
-  receive a DsReplicaSync reply
+  start the ReplicaSync async call
  */
-static void dreplsrv_op_notify_replica_sync_recv(struct rpc_request *req)
+static struct tevent_req *dreplsrv_op_notify_send(TALLOC_CTX *mem_ctx,
+						  struct tevent_context *ev,
+						  struct dreplsrv_notify_operation *op)
 {
-	struct dreplsrv_op_notify_state *st = talloc_get_type(req->async.private_data,
-							      struct dreplsrv_op_notify_state);
-	struct composite_context *c = st->creq;
-	struct drsuapi_DsReplicaSync *r = talloc_get_type(req->ndr.struct_ptr,
-							  struct drsuapi_DsReplicaSync);
+	struct tevent_req *req;
+	struct dreplsrv_op_notify_state *state;
+	struct tevent_req *subreq;
 
-	c->status = dcerpc_ndr_request_recv(req);
-	if (!composite_is_ok(c)) return;
+	req = tevent_req_create(mem_ctx, &state,
+				struct dreplsrv_op_notify_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	state->op = op;
 
-	if (!W_ERROR_IS_OK(r->out.result)) {
-		composite_error(c, werror_to_ntstatus(r->out.result));
+	subreq = dreplsrv_out_drsuapi_send(state,
+					   ev,
+					   op->source_dsa->conn);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq, dreplsrv_op_notify_connect_done, req);
+
+	return req;
+}
+
+static void dreplsrv_op_notify_replica_sync_trigger(struct tevent_req *req);
+
+static void dreplsrv_op_notify_connect_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(subreq,
+							  struct tevent_req);
+	NTSTATUS status;
+
+	status = dreplsrv_out_drsuapi_recv(subreq);
+	TALLOC_FREE(subreq);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
-	composite_done(c);
+	dreplsrv_op_notify_replica_sync_trigger(req);
 }
 
-/*
-  send a DsReplicaSync
-*/
-static void dreplsrv_op_notify_replica_sync_send(struct dreplsrv_op_notify_state *st)
+static void dreplsrv_op_notify_replica_sync_done(struct rpc_request *rreq);
+
+static void dreplsrv_op_notify_replica_sync_trigger(struct tevent_req *req)
 {
-	struct composite_context *c = st->creq;
-	struct dreplsrv_partition *partition = st->op->source_dsa->partition;
-	struct dreplsrv_drsuapi_connection *drsuapi = st->op->source_dsa->conn->drsuapi;
-	struct rpc_request *req;
+	struct dreplsrv_op_notify_state *state =
+		tevent_req_data(req,
+		struct dreplsrv_op_notify_state);
+	struct dreplsrv_partition *partition = state->op->source_dsa->partition;
+	struct dreplsrv_drsuapi_connection *drsuapi = state->op->source_dsa->conn->drsuapi;
+	struct rpc_request *rreq;
 	struct drsuapi_DsReplicaSync *r;
 
-	r = talloc_zero(st, struct drsuapi_DsReplicaSync);
-	if (composite_nomem(r, c)) return;
-
+	r = talloc_zero(state, struct drsuapi_DsReplicaSync);
+	if (tevent_req_nomem(r, req)) {
+		return;
+	}
 	r->in.bind_handle	= &drsuapi->bind_handle;
 	r->in.level = 1;
 	r->in.req.req1.naming_context = &partition->nc;
-	r->in.req.req1.source_dsa_guid = st->op->service->ntds_guid;
+	r->in.req.req1.source_dsa_guid = state->op->service->ntds_guid;
 	r->in.req.req1.options = 
 		DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION |
 		DRSUAPI_DS_REPLICA_SYNC_WRITEABLE |
 		DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES;
-	
 
-	req = dcerpc_drsuapi_DsReplicaSync_send(drsuapi->pipe, r, r);
-	composite_continue_rpc(c, req, dreplsrv_op_notify_replica_sync_recv, st);
+	rreq = dcerpc_drsuapi_DsReplicaSync_send(drsuapi->pipe, r, r);
+	if (tevent_req_nomem(rreq, req)) {
+		return;
+	}
+	composite_continue_rpc(NULL, rreq, dreplsrv_op_notify_replica_sync_done, req);
 }
 
-/*
-  called when we have an established connection
- */
-static void dreplsrv_op_notify_connect_done(struct tevent_req *subreq)
+static void dreplsrv_op_notify_replica_sync_done(struct rpc_request *rreq)
 {
-	struct dreplsrv_op_notify_state *st = tevent_req_callback_data(subreq,
-					      struct dreplsrv_op_notify_state);
-	struct composite_context *c = st->creq;
+	struct tevent_req *req = talloc_get_type(rreq->async.private_data,
+						 struct tevent_req);
+	struct drsuapi_DsReplicaSync *r = talloc_get_type(rreq->ndr.struct_ptr,
+							  struct drsuapi_DsReplicaSync);
+	NTSTATUS status;
 
-	c->status = dreplsrv_out_drsuapi_recv(subreq);
-	TALLOC_FREE(subreq);
-	if (!composite_is_ok(c)) return;
+	status = dcerpc_ndr_request_recv(rreq);
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
 
-	dreplsrv_op_notify_replica_sync_send(st);
+	if (!W_ERROR_IS_OK(r->out.result)) {
+		status = werror_to_ntstatus(r->out.result);
+		tevent_req_nterror(req, status);
+		return;
+	}
+
+	tevent_req_done(req);
 }
 
-/*
-  start the ReplicaSync async call
- */
-static struct composite_context *dreplsrv_op_notify_send(struct dreplsrv_notify_operation *op)
+static NTSTATUS dreplsrv_op_notify_recv(struct tevent_req *req)
 {
-	struct composite_context *c;
-	struct dreplsrv_op_notify_state *st;
-	struct tevent_req *subreq;
-
-	c = composite_create(op, op->service->task->event_ctx);
-	if (c == NULL) return NULL;
-
-	st = talloc_zero(c, struct dreplsrv_op_notify_state);
-	if (composite_nomem(st, c)) return c;
-
-	st->creq	= c;
-	st->op		= op;
-
-	subreq = dreplsrv_out_drsuapi_send(st,
-					   op->service->task->event_ctx,
-					   op->source_dsa->conn);
-	if (composite_nomem(subreq, c)) return c;
-	tevent_req_set_callback(subreq, dreplsrv_op_notify_connect_done, st);
-
-	return c;
+	return tevent_req_simple_recv_ntstatus(req);
 }
 
 static void dreplsrv_notify_del_repsTo(struct dreplsrv_notify_operation *op)
@@ -176,12 +183,16 @@ static void dreplsrv_notify_del_repsTo(struct dreplsrv_notify_operation *op)
 /*
   called when a notify operation has completed
  */
-static void dreplsrv_notify_op_callback(struct dreplsrv_notify_operation *op)
+static void dreplsrv_notify_op_callback(struct tevent_req *subreq)
 {
+	struct dreplsrv_notify_operation *op =
+		tevent_req_callback_data(subreq,
+		struct dreplsrv_notify_operation);
 	NTSTATUS status;
 	struct dreplsrv_service *s = op->service;
 
-	status = composite_wait(op->creq);
+	status = dreplsrv_op_notify_recv(subreq);
+	TALLOC_FREE(subreq);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0,("dreplsrv_notify: Failed to send DsReplicaSync to %s for %s - %s\n",
 			 op->source_dsa->repsFrom1->other_info->dns_name,
@@ -195,27 +206,19 @@ static void dreplsrv_notify_op_callback(struct dreplsrv_notify_operation *op)
 		   partition, as we have successfully told him to sync */
 		dreplsrv_notify_del_repsTo(op);
 	}
-	talloc_free(op->creq);
 
 	talloc_free(op);
 	s->ops.n_current = NULL;
 	dreplsrv_notify_run_ops(s);
 }
 
-
-static void dreplsrv_notify_op_callback_creq(struct composite_context *creq)
-{
-	struct dreplsrv_notify_operation *op = talloc_get_type(creq->async.private_data,
-							       struct dreplsrv_notify_operation);
-	dreplsrv_notify_op_callback(op);
-}
-
 /*
   run any pending replica sync calls
  */
 void dreplsrv_notify_run_ops(struct dreplsrv_service *s)
 {
 	struct dreplsrv_notify_operation *op;
+	struct tevent_req *subreq;
 
 	if (s->ops.n_current || s->ops.current) {
 		/* if there's still one running, we're done */
@@ -231,14 +234,14 @@ void dreplsrv_notify_run_ops(struct dreplsrv_service *s)
 	s->ops.n_current = op;
 	DLIST_REMOVE(s->ops.notifies, op);
 
-	op->creq = dreplsrv_op_notify_send(op);
-	if (!op->creq) {
-		dreplsrv_notify_op_callback(op);
+	subreq = dreplsrv_op_notify_send(op, s->task->event_ctx, op);
+	if (!subreq) {
+		DEBUG(0,("dreplsrv_notify_run_ops: dreplsrv_op_notify_send[%s][%s] - no memory\n",
+			 op->source_dsa->repsFrom1->other_info->dns_name,
+			 ldb_dn_get_linearized(op->source_dsa->partition->dn)));
 		return;
 	}
-
-	op->creq->async.fn		= dreplsrv_notify_op_callback_creq;
-	op->creq->async.private_data	= op;
+	tevent_req_set_callback(subreq, dreplsrv_notify_op_callback, op);
 }
 
 
diff --git a/source4/dsdb/repl/drepl_service.h b/source4/dsdb/repl/drepl_service.h
index 0a0d721..f885892 100644
--- a/source4/dsdb/repl/drepl_service.h
+++ b/source4/dsdb/repl/drepl_service.h
@@ -121,8 +121,6 @@ struct dreplsrv_notify_operation {
 	uint64_t uSN;
 
 	struct dreplsrv_partition_source_dsa *source_dsa;
-
-	struct composite_context *creq;
 };
 
 struct dreplsrv_service {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list