s4:rpc_server/remote: introduce struct dcesrv_remote_call
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Nov 2018 13:28:56 +0000 (14:28 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 12 Jan 2019 02:13:39 +0000 (03:13 +0100)
This holds the state for async requests.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/rpc_server/remote/dcesrv_remote.c

index 7a1ec3f78f9b1ea46510c0ec8b88ac9b0a72287d..3fa847222c4d1c3e8481b9730618ce15e5ac447d 100644 (file)
@@ -262,8 +262,14 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT
 
 static void remote_op_dispatch_done(struct tevent_req *subreq);
 
+struct dcesrv_remote_call {
+       struct dcesrv_call_state *dce_call;
+       struct dcesrv_remote_private *priv;
+};
+
 static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
 {
+       struct dcesrv_remote_call *rcall = NULL;
        struct dcesrv_remote_private *priv = NULL;
        uint16_t opnum = dce_call->pkt.u.request.opnum;
        const struct ndr_interface_table *table = dce_call->context->iface->private_data;
@@ -281,6 +287,13 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
                return status;
        }
 
+       rcall = talloc_zero(dce_call, struct dcesrv_remote_call);
+       if (rcall == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       rcall->dce_call = dce_call;
+       rcall->priv = priv;
+
        if (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_IN) {
                ndr_print_function_debug(call->ndr_print, name, NDR_IN | NDR_SET_VALUES, r);            
        }
@@ -288,7 +301,7 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
        priv->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;
 
        /* we didn't use the return code of this function as we only check the last_fault_code */
-       subreq = dcerpc_binding_handle_call_send(dce_call, dce_call->event_ctx,
+       subreq = dcerpc_binding_handle_call_send(rcall, dce_call->event_ctx,
                                                 priv->c_pipe->binding_handle,
                                                 NULL, table,
                                                 opnum, mem_ctx, r);
@@ -296,7 +309,7 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
                DEBUG(0,("dcesrv_remote: call[%s] dcerpc_binding_handle_call_send() failed!\n", name));
                return NT_STATUS_NO_MEMORY;
        }
-       tevent_req_set_callback(subreq, remote_op_dispatch_done, dce_call);
+       tevent_req_set_callback(subreq, remote_op_dispatch_done, rcall);
 
        dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC;
        return NT_STATUS_OK;
@@ -304,10 +317,11 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT
 
 static void remote_op_dispatch_done(struct tevent_req *subreq)
 {
-       struct dcesrv_call_state *dce_call = tevent_req_callback_data(subreq,
-                                            struct dcesrv_call_state);
-       struct dcesrv_remote_private *priv = talloc_get_type_abort(dce_call->context->private_data,
-                                                                  struct dcesrv_remote_private);
+       struct dcesrv_remote_call *rcall =
+               tevent_req_callback_data(subreq,
+               struct dcesrv_remote_call);
+       struct dcesrv_call_state *dce_call = rcall->dce_call;
+       struct dcesrv_remote_private *priv = rcall->priv;
        uint16_t opnum = dce_call->pkt.u.request.opnum;
        const struct ndr_interface_table *table = dce_call->context->iface->private_data;
        const struct ndr_interface_call *call;