]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
messaging: Register a tevent context for secondary dgm refs
authorVolker Lendecke <vl@samba.org>
Mon, 18 May 2015 11:15:35 +0000 (13:15 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 28 May 2015 09:13:09 +0000 (11:13 +0200)
When a secondary messaging context is initialized, we need to register
its tevent context with the lower level dgm context. Seen when using
smbstatus with clustering.

The TALLOC_FREE(r->tevent_handle) in the destructor might not be
necessary, but I want to free the tevent reference before
the context goes away.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/lib/messages_dgm_ref.c

index 32b9c985296c3ff0a802089193dd8e12f62c0111..b4511e0060391b924a89f738c405c462c9ea427e 100644 (file)
@@ -26,6 +26,7 @@
 
 struct msg_dgm_ref {
        struct msg_dgm_ref *prev, *next;
+       void *tevent_handle;
        void (*recv_cb)(const uint8_t *msg, size_t msg_len,
                        int *fds, size_t num_fds, void *private_data);
        void *recv_cb_private_data;
@@ -55,6 +56,7 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                *err = ENOMEM;
                return NULL;
        }
+       result->tevent_handle = NULL;
 
        tmp_refs = refs;
 
@@ -79,6 +81,14 @@ void *messaging_dgm_ref(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                        return NULL;
                }
                dgm_pid = getpid();
+       } else {
+               result->tevent_handle = messaging_dgm_register_tevent_context(
+                       result, ev);
+               if (result->tevent_handle == NULL) {
+                       TALLOC_FREE(result);
+                       *err = ENOMEM;
+                       return NULL;
+               }
        }
 
        refs = tmp_refs;
@@ -114,6 +124,8 @@ static int msg_dgm_ref_destructor(struct msg_dgm_ref *r)
        }
        DLIST_REMOVE(refs, r);
 
+       TALLOC_FREE(r->tevent_handle);
+
        if (refs == NULL) {
                messaging_dgm_destroy();
        }