[PATCH] Cache messaging dgm connections

Ralph Böhme slow at samba.org
Fri Sep 16 16:00:44 UTC 2016


On Fri, Sep 16, 2016 at 08:36:33AM -0700, Jeremy Allison wrote:
> On Fri, Sep 16, 2016 at 11:29:06AM +0200, Ralph Böhme wrote:
> > On Thu, Sep 15, 2016 at 10:09:18AM -0700, Jeremy Allison wrote:
> > > On Thu, Sep 15, 2016 at 06:38:25PM +0200, Ralph Böhme wrote:
> > > > 
> > > > I got one through with these two patches. Running more...
> > > > 
> > > > Cheerio!
> > > 
> > > Oh, this looks more elegant than the reparent struct poll_funcs_tevent_context
> > > to ev patch I just posted...
> > > 
> > > The:
> > > 
> > >  +     TALLOC_FREE(msg->msg_dgm_ref);
> > > 
> > > looks very clever :-).
> > 
> > it passed three more autobuilds. Shall we push it?
> 
> Yes please - the version we discussed on the phone
> with the free of the timer events followed by context,
> plus the TALLOC_FREE(msg->msg_dgm_ref); change !

Then the attached is the one. Please push if ok.

Cheerio!
-slow
-------------- next part --------------
From e75ef0b42d55d8e1a1acce3028633fe60f3351c7 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/3] lib/poll_funcs: free timers in
 poll_funcs_state_destructor()

Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra 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 ba083323faa35b337d42c2166219de37c49ca639 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Fri, 16 Sep 2016 17:55:56 +0200
Subject: [PATCH 2/3] lib/poll_funcs: free contexts in
 poll_funcs_state_destructor()

This ensures the destructors get called in the proper order.

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

diff --git a/lib/poll_funcs/poll_funcs_tevent.c b/lib/poll_funcs/poll_funcs_tevent.c
index 3d79b75..a061878 100644
--- a/lib/poll_funcs/poll_funcs_tevent.c
+++ b/lib/poll_funcs/poll_funcs_tevent.c
@@ -486,6 +486,9 @@ static int poll_funcs_state_destructor(struct poll_funcs_state *state)
 	for (i=0; i<num_timeouts; i++) {
 		TALLOC_FREE(state->timeouts[i]);
 	}
+	for (i=0; i<num_contexts; i++) {
+		TALLOC_FREE(state->contexts[i]);
+	}
 	return 0;
 }
 
-- 
2.7.4


From 16b079a7d393f91da8b03039231a343e558971f2 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 3/3] s4/messaging: let the imessaging ctx destructor free
 msg_dgm_ref

Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra 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 ea50627..d0beef6 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -304,6 +304,7 @@ static 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