Author: tridge Date: 2005-09-25 13:17:03 +0000 (Sun, 25 Sep 2005) New Revision: 10490
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10490 Log: - allow deferred irpc replies to set the status - add an example of deferred reply for echodata in LOCAL-IRPC Modified: branches/SAMBA_4_0/source/lib/messaging/irpc.h branches/SAMBA_4_0/source/lib/messaging/messaging.c branches/SAMBA_4_0/source/torture/local/irpc.c Changeset: Modified: branches/SAMBA_4_0/source/lib/messaging/irpc.h =================================================================== --- branches/SAMBA_4_0/source/lib/messaging/irpc.h 2005-09-25 13:01:26 UTC (rev 10489) +++ branches/SAMBA_4_0/source/lib/messaging/irpc.h 2005-09-25 13:17:03 UTC (rev 10490) @@ -34,6 +34,7 @@ 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_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); Modified: branches/SAMBA_4_0/source/lib/messaging/messaging.c =================================================================== --- branches/SAMBA_4_0/source/lib/messaging/messaging.c 2005-09-25 13:01:26 UTC (rev 10489) +++ branches/SAMBA_4_0/source/lib/messaging/messaging.c 2005-09-25 13:17:03 UTC (rev 10490) @@ -512,12 +512,13 @@ /* 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 @@ 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 @@ return; } - irpc_send_reply(m); + irpc_send_reply(m, m->header.status); return; failed: Modified: branches/SAMBA_4_0/source/torture/local/irpc.c =================================================================== --- branches/SAMBA_4_0/source/torture/local/irpc.c 2005-09-25 13:01:26 UTC (rev 10489) +++ branches/SAMBA_4_0/source/torture/local/irpc.c 2005-09-25 13:17:03 UTC (rev 10490) @@ -43,12 +43,29 @@ } /* + 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 @@ 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)) {
