s4:imessaging: Remove event context from irpc and imessaging structures
authorAndrew Bartlett <abartlet@samba.org>
Mon, 5 May 2014 04:27:59 +0000 (16:27 +1200)
committerStefan Metzmacher <metze@samba.org>
Tue, 13 May 2014 00:33:24 +0000 (02:33 +0200)
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 <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue May 13 02:33:24 CEST 2014 on sn-devel-104

source4/lib/messaging/irpc.h
source4/lib/messaging/messaging.c

index 456d1906e0c3bf747d62320787526bd000923b7d..96f67e1dcb7aa10423b4ddf4f14e9ef2e698f5ca 100644 (file)
@@ -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);
 
index a466cc086850777ecf69a524f593e2d48d6faed1..f73b2ba117edcd238fb8023724c3efb412fa8f0f 100644 (file)
@@ -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;