s4-repl: take advantage of async RPC forwarding
authorAndrew Tridgell <tridge@samba.org>
Wed, 16 Sep 2009 03:51:10 +0000 (20:51 -0700)
committerAndrew Tridgell <tridge@samba.org>
Wed, 16 Sep 2009 03:51:10 +0000 (20:51 -0700)
This uses async RPC forwarding for the DsReplicaSync call

source4/dsdb/repl/drepl_service.c
source4/rpc_server/drsuapi/dcesrv_drsuapi.c

index cb415b65e684a3ba19dbefd996361acd61cb04cb..75ce42b91a38b0bf2a058ad8b383f67b73810357 100644 (file)
@@ -113,18 +113,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 {
        struct dreplsrv_service *service = talloc_get_type(msg->private_data,
                                                           struct dreplsrv_service);
-       WERROR werr;
        struct GUID *guid = &r->in.req.req1.naming_context->guid;
 
-       werr = dreplsrv_schedule_partition_pull_by_guid(service, msg, guid);
-       if (W_ERROR_IS_OK(werr)) {
+       r->out.result = dreplsrv_schedule_partition_pull_by_guid(service, msg, guid);
+       if (W_ERROR_IS_OK(r->out.result)) {
                DEBUG(3,("drepl_replica_sync: forcing sync of partition %s\n",
                         GUID_string(msg, guid)));
                dreplsrv_run_pending_ops(service);
        } else {
                DEBUG(3,("drepl_replica_sync: failed setup of sync of partition %s - %s\n",
-                        GUID_string(msg, guid), win_errstr(werr)));
-               return NT_STATUS_INTERNAL_ERROR;
+                        GUID_string(msg, guid), win_errstr(r->out.result)));
        }
        return NT_STATUS_OK;
 }
index c01711d2d9888675af0a3c1feda8f8de15350be9..491b962a851dfe1a86f9dfc8bdb7b142a62b0ea8 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/ldb/include/ldb_errors.h"
 #include "param/param.h"
 #include "librpc/gen_ndr/ndr_drsblobs.h"
-#include "messaging/irpc.h"
 #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
 #include "libcli/security/security.h"
 
@@ -232,35 +231,19 @@ static WERROR dcesrv_drsuapi_DsUnbind(struct dcesrv_call_state *dce_call, TALLOC
 static WERROR dcesrv_drsuapi_DsReplicaSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                           struct drsuapi_DsReplicaSync *r)
 {
-       struct server_id *repld;
-       struct irpc_request *ireq;
-
        if (security_session_user_level(dce_call->conn->auth_state.session_info) <
            SECURITY_DOMAIN_CONTROLLER) {
                DEBUG(0,("DsReplicaSync refused for security token\n"));
                return WERR_DS_DRA_ACCESS_DENIED;
        }
 
-       repld = irpc_servers_byname(dce_call->msg_ctx, mem_ctx, "dreplsrv");
-       if (repld == NULL || repld[0].id == 0) {
-               DEBUG(0,("DsReplicaSync: Unable to find dreplsrv task\n"));
-               return WERR_DS_DRA_INTERNAL_ERROR;
-       }
-
-       ireq = IRPC_CALL_SEND(dce_call->msg_ctx, repld[0],
-                             drsuapi, DRSUAPI_DSREPLICASYNC,
-                             r, mem_ctx);
-       if (ireq == NULL) {
-               DEBUG(0,("DsReplicaSync: Failed to forward request to dreplsrv task\n"));
-               return WERR_DS_DRA_INTERNAL_ERROR;
-       }
-
-       /* we are not interested in a reply */
-       talloc_free(ireq);
-
+       dcesrv_irpc_forward_rpc_call(dce_call, mem_ctx, r, NDR_DRSUAPI_DSREPLICASYNC,
+                                    &ndr_table_drsuapi,
+                                    "dreplsrv", "DsReplicaSync");
        return WERR_OK;
 }
 
+
 /* 
   drsuapi_DsReplicaAdd 
 */