From c1507bc1014c199d3a11227d088762364de432cd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 5 May 2014 16:27:59 +1200 Subject: s4:imessaging: Remove event context from irpc and imessaging structures The only part of this code with a stored event context is now the binding_handle created by irpc_binding_handle() when in the client dcerpc_binding_handle_set_sync_ev() is called, otherwise a new nested event context is created for sync calls. Note that the FD event associated with the socket still implies the long term event context passed to imessaging_[client]_init(). Andrew Bartlett Change-Id: I9aeae94b26e3736370f449daa96808e6cdc2d55d Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Tue May 13 02:33:24 CEST 2014 on sn-devel-104 --- source4/lib/messaging/irpc.h | 13 ++++++------- source4/lib/messaging/messaging.c | 29 +++++++++++++---------------- 2 files changed, 19 insertions(+), 23 deletions(-) (limited to 'source4') diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index 456d1906e0c..96f67e1dcb7 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -38,7 +38,6 @@ struct irpc_message { struct imessaging_context *msg_ctx; struct irpc_list *irpc; void *data; - struct tevent_context *ev; }; /* don't allow calls to take too long */ @@ -63,13 +62,13 @@ NTSTATUS irpc_register(struct imessaging_context *msg_ctx, int call, irpc_function_t fn, void *private_data); struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx, - struct imessaging_context *msg_ctx, - struct server_id server_id, - const struct ndr_interface_table *table); + struct imessaging_context *msg_ctx, + struct server_id server_id, + const struct ndr_interface_table *table); struct dcerpc_binding_handle *irpc_binding_handle_by_name(TALLOC_CTX *mem_ctx, - struct imessaging_context *msg_ctx, - const char *dest_task, - const struct ndr_interface_table *table); + struct imessaging_context *msg_ctx, + const char *dest_task, + const struct ndr_interface_table *table); void irpc_binding_handle_add_security_token(struct dcerpc_binding_handle *h, struct security_token *token); diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index a466cc08685..f73b2ba117e 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -71,7 +71,6 @@ struct imessaging_context { struct timeval start_time; struct tevent_timer *retry_te; struct { - struct tevent_context *ev; struct tevent_fd *fde; } event; }; @@ -262,7 +261,7 @@ static void msg_retry_timer(struct tevent_context *ev, struct tevent_timer *te, /* handle a socket write event */ -static void imessaging_send_handler(struct imessaging_context *msg) +static void imessaging_send_handler(struct imessaging_context *msg, struct tevent_context *ev) { while (msg->pending) { struct imessaging_rec *rec = msg->pending; @@ -278,9 +277,9 @@ static void imessaging_send_handler(struct imessaging_context *msg) struct imessaging_rec *); if (msg->retry_te == NULL) { msg->retry_te = - tevent_add_timer(msg->event.ev, msg, - timeval_current_ofs(1, 0), - msg_retry_timer, msg); + tevent_add_timer(ev, msg, + timeval_current_ofs(1, 0), + msg_retry_timer, msg); } } break; @@ -306,7 +305,7 @@ static void imessaging_send_handler(struct imessaging_context *msg) /* handle a new incoming packet */ -static void imessaging_recv_handler(struct imessaging_context *msg) +static void imessaging_recv_handler(struct imessaging_context *msg, struct tevent_context *ev) { struct imessaging_rec *rec; NTSTATUS status; @@ -372,10 +371,10 @@ static void imessaging_handler(struct tevent_context *ev, struct tevent_fd *fde, struct imessaging_context *msg = talloc_get_type(private_data, struct imessaging_context); if (flags & TEVENT_FD_WRITE) { - imessaging_send_handler(msg); + imessaging_send_handler(msg, ev); } if (flags & TEVENT_FD_READ) { - imessaging_recv_handler(msg); + imessaging_recv_handler(msg, ev); } } @@ -655,7 +654,6 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, /* it needs to be non blocking for sends */ set_blocking(socket_get_fd(msg->sock), false); - msg->event.ev = ev; msg->event.fde = tevent_add_fd(ev, msg, socket_get_fd(msg->sock), TEVENT_FD_READ, imessaging_handler, msg); tevent_fd_set_auto_close(msg->event.fde); @@ -834,7 +832,6 @@ static void irpc_handler_request(struct imessaging_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); @@ -1362,9 +1359,9 @@ static const struct dcerpc_binding_handle_ops irpc_bh_ops = { /* initialise a irpc binding handle */ struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx, - struct imessaging_context *msg_ctx, - struct server_id server_id, - const struct ndr_interface_table *table) + struct imessaging_context *msg_ctx, + struct server_id server_id, + const struct ndr_interface_table *table) { struct dcerpc_binding_handle *h; struct irpc_bh_state *hs; @@ -1388,9 +1385,9 @@ struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx, } struct dcerpc_binding_handle *irpc_binding_handle_by_name(TALLOC_CTX *mem_ctx, - struct imessaging_context *msg_ctx, - const char *dest_task, - const struct ndr_interface_table *table) + struct imessaging_context *msg_ctx, + const char *dest_task, + const struct ndr_interface_table *table) { struct dcerpc_binding_handle *h; struct server_id *sids; -- cgit