summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/messaging/irpc.h3
-rw-r--r--source4/lib/messaging/messaging.c8
-rw-r--r--source4/torture/local/irpc.c25
3 files changed, 28 insertions, 8 deletions
diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h
index aa06a2de06..e83e7dce65 100644
--- a/source4/lib/messaging/irpc.h
+++ b/source4/lib/messaging/irpc.h
@@ -34,6 +34,7 @@ struct irpc_message {
struct messaging_context *msg_ctx;
struct irpc_list *irpc;
void *data;
+ struct event_context *ev;
};
/* don't allow calls to take too long */
@@ -108,6 +109,6 @@ NTSTATUS irpc_call(struct messaging_context *msg_ctx,
NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
uint32_t *irpc_servers_byname(struct messaging_context *msg_ctx, const char *name);
void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
-NTSTATUS irpc_send_reply(struct irpc_message *m);
+NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 9fcfd58972..c3d3ba7899 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -512,12 +512,13 @@ static void irpc_handler_reply(struct messaging_context *msg_ctx, struct irpc_me
/*
send a irpc reply
*/
-NTSTATUS irpc_send_reply(struct irpc_message *m)
+NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status)
{
struct ndr_push *push;
- NTSTATUS status;
DATA_BLOB packet;
+ m->header.status = status;
+
/* setup the reply */
push = ndr_push_init_ctx(m->ndr);
if (push == NULL) {
@@ -582,6 +583,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx,
m->msg_ctx = msg_ctx;
m->irpc = i;
m->data = r;
+ m->ev = msg_ctx->event.ev;
m->header.status = i->fn(m, r);
@@ -591,7 +593,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx,
return;
}
- irpc_send_reply(m);
+ irpc_send_reply(m, m->header.status);
return;
failed:
diff --git a/source4/torture/local/irpc.c b/source4/torture/local/irpc.c
index 3d529fcc49..861edc42fa 100644
--- a/source4/torture/local/irpc.c
+++ b/source4/torture/local/irpc.c
@@ -43,12 +43,29 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r)
}
/*
+ a deferred reply to echodata
+*/
+static void deferred_echodata(struct event_context *ev, struct timed_event *te,
+ struct timeval t, void *private)
+{
+ struct irpc_message *irpc = talloc_get_type(private, struct irpc_message);
+ struct echo_EchoData *r = irpc->data;
+ r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len);
+ if (r->out.out_data == NULL) {
+ irpc_send_reply(irpc, NT_STATUS_NO_MEMORY);
+ }
+ printf("sending deferred reply\n");
+ irpc_send_reply(irpc, NT_STATUS_OK);
+}
+
+
+/*
serve up EchoData over the irpc system
*/
static NTSTATUS irpc_EchoData(struct irpc_message *irpc, struct echo_EchoData *r)
{
- r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len);
- NT_STATUS_HAVE_NO_MEMORY(r->out.out_data);
+ irpc->defer_reply = True;
+ event_add_timed(irpc->ev, irpc, timeval_zero(), deferred_echodata, irpc);
return NT_STATUS_OK;
}
@@ -98,8 +115,8 @@ static BOOL test_echodata(TALLOC_CTX *mem_ctx,
NTSTATUS status;
/* make the call */
- r.in.in_data = talloc_strdup(mem_ctx, "0123456789");
- r.in.len = strlen(r.in.in_data);
+ r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
+ r.in.len = strlen((char *)r.in.in_data);
status = IRPC_CALL(msg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r, mem_ctx);
if (!NT_STATUS_IS_OK(status)) {