[PATCH] Cache messaging dgm connections

Ralph Böhme slow at samba.org
Thu Sep 15 16:38:25 UTC 2016


On Thu, Sep 15, 2016 at 11:06:00AM +0200, Ralph Böhme wrote:
>  Wed, Sep 14, 2016 at 10:13:13PM -0700, Jeremy Allison wrote:
> > My money is on the event context getting freed with
> > active connections. I'm cheating here as this is
> > something metze already discovered with Volker's
> > tmsgd work :-).
> > 
> > Metze's patch for this is attached (modified to
> > compile in master). I'm trying a private autobuild
> > with it now.
> 
> I guess we also need this:
> 
> --- a/lib/poll_funcs/poll_funcs_tevent.c
> +++ b/lib/poll_funcs/poll_funcs_tevent.c
> @@ -474,6 +474,7 @@ struct poll_funcs *poll_funcs_init_tevent(TALLOC_CTX *mem_ctx)
>  static int poll_funcs_state_destructor(struct poll_funcs_state *state)
>  {
>         size_t num_watches = talloc_array_length(state->watches);
> +       size_t num_timeouts = talloc_array_length(state->timeouts);
>         size_t i;
>         /*
>          * Make sure the watches are cleared before the contexts. The watches
> @@ -482,6 +483,9 @@ static int poll_funcs_state_destructor(struct poll_funcs_state *state)
>         for (i=0; i<num_watches; i++) {
>                 TALLOC_FREE(state->watches[i]);
>         }
> +       for (i=0; i<num_timeouts; i++) {
> +               TALLOC_FREE(state->timeouts[i]);
> +       }
>         return 0;
>  }
> 
> but afaict all this will still crash if the tevent context is freed
> before we have a chance to rundown the messaging and poll_funcs
> contexts.

I got one through with these two patches. Running more...

Cheerio!
-slow
-------------- next part --------------
From 6cf896a87057972afcc24cb6ed42fa588a325b7b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 15 Sep 2016 14:19:27 +0200
Subject: [PATCH 1/2] lib/poll_funcs: free timers in
 poll_funcs_state_destructor()

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/poll_funcs/poll_funcs_tevent.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/poll_funcs/poll_funcs_tevent.c b/lib/poll_funcs/poll_funcs_tevent.c
index 3059ebc..3d79b75 100644
--- a/lib/poll_funcs/poll_funcs_tevent.c
+++ b/lib/poll_funcs/poll_funcs_tevent.c
@@ -474,6 +474,7 @@ struct poll_funcs *poll_funcs_init_tevent(TALLOC_CTX *mem_ctx)
 static int poll_funcs_state_destructor(struct poll_funcs_state *state)
 {
 	size_t num_watches = talloc_array_length(state->watches);
+	size_t num_timeouts = talloc_array_length(state->timeouts);
 	size_t i;
 	/*
 	 * Make sure the watches are cleared before the contexts. The watches
@@ -482,6 +483,9 @@ static int poll_funcs_state_destructor(struct poll_funcs_state *state)
 	for (i=0; i<num_watches; i++) {
 		TALLOC_FREE(state->watches[i]);
 	}
+	for (i=0; i<num_timeouts; i++) {
+		TALLOC_FREE(state->timeouts[i]);
+	}
 	return 0;
 }
 
-- 
2.7.4


From ad120b23821cba4c72354fbf4f73357c320e3c73 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 15 Sep 2016 14:19:51 +0200
Subject: [PATCH 2/2] s4/messaging: let the imessaging ctx destructor free
 msg_dgm_ref

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source4/lib/messaging/messaging.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index fe052fbe..8c98254 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -304,6 +304,7 @@ struct imessaging_context *msg_ctxs;
 static int imessaging_context_destructor(struct imessaging_context *msg)
 {
 	DLIST_REMOVE(msg_ctxs, msg);
+	TALLOC_FREE(msg->msg_dgm_ref);
 	return 0;
 }
 
-- 
2.7.4



More information about the samba-technical mailing list