From 06085e7bc09e46c74fbe050633203fab619d501c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 25 Sep 2005 13:17:03 +0000 Subject: r10490: - allow deferred irpc replies to set the status - add an example of deferred reply for echodata in LOCAL-IRPC (This used to be commit 858a757a6d0a614b8f13bfb6217034e8a8b69554) --- source4/torture/local/irpc.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'source4/torture/local') 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 @@ -42,13 +42,30 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r) return NT_STATUS_OK; } +/* + 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)) { -- cgit