mirror of
https://github.com/samba-team/samba.git
synced 2025-09-11 09:44:19 +03:00
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 858a757a6d
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
87f71eb8ad
commit
06085e7bc0
@@ -34,6 +34,7 @@ struct irpc_message {
|
|||||||
struct messaging_context *msg_ctx;
|
struct messaging_context *msg_ctx;
|
||||||
struct irpc_list *irpc;
|
struct irpc_list *irpc;
|
||||||
void *data;
|
void *data;
|
||||||
|
struct event_context *ev;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* don't allow calls to take too long */
|
/* 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);
|
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);
|
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);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -512,12 +512,13 @@ static void irpc_handler_reply(struct messaging_context *msg_ctx, struct irpc_me
|
|||||||
/*
|
/*
|
||||||
send a irpc reply
|
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;
|
struct ndr_push *push;
|
||||||
NTSTATUS status;
|
|
||||||
DATA_BLOB packet;
|
DATA_BLOB packet;
|
||||||
|
|
||||||
|
m->header.status = status;
|
||||||
|
|
||||||
/* setup the reply */
|
/* setup the reply */
|
||||||
push = ndr_push_init_ctx(m->ndr);
|
push = ndr_push_init_ctx(m->ndr);
|
||||||
if (push == NULL) {
|
if (push == NULL) {
|
||||||
@@ -582,6 +583,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx,
|
|||||||
m->msg_ctx = msg_ctx;
|
m->msg_ctx = msg_ctx;
|
||||||
m->irpc = i;
|
m->irpc = i;
|
||||||
m->data = r;
|
m->data = r;
|
||||||
|
m->ev = msg_ctx->event.ev;
|
||||||
|
|
||||||
m->header.status = i->fn(m, r);
|
m->header.status = i->fn(m, r);
|
||||||
|
|
||||||
@@ -591,7 +593,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
irpc_send_reply(m);
|
irpc_send_reply(m, m->header.status);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
@@ -42,13 +42,30 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r)
|
|||||||
return NT_STATUS_OK;
|
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
|
serve up EchoData over the irpc system
|
||||||
*/
|
*/
|
||||||
static NTSTATUS irpc_EchoData(struct irpc_message *irpc, struct echo_EchoData *r)
|
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);
|
irpc->defer_reply = True;
|
||||||
NT_STATUS_HAVE_NO_MEMORY(r->out.out_data);
|
event_add_timed(irpc->ev, irpc, timeval_zero(), deferred_echodata, irpc);
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,8 +115,8 @@ static BOOL test_echodata(TALLOC_CTX *mem_ctx,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
/* make the call */
|
/* make the call */
|
||||||
r.in.in_data = talloc_strdup(mem_ctx, "0123456789");
|
r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
|
||||||
r.in.len = strlen(r.in.in_data);
|
r.in.len = strlen((char *)r.in.in_data);
|
||||||
|
|
||||||
status = IRPC_CALL(msg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r, mem_ctx);
|
status = IRPC_CALL(msg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r, mem_ctx);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
Reference in New Issue
Block a user