[PATCH] Cache messaging dgm connections

Jeremy Allison jra at samba.org
Sat Sep 17 08:06:47 UTC 2016


On Fri, Sep 16, 2016 at 11:49:32PM -0700, Jeremy Allison wrote:
> On Sat, Sep 17, 2016 at 07:54:28AM +0200, Ralph Böhme wrote:
> > 
> > I'm now running autobuilds with it on sn-devel.
> 
> Yeah, the reinit after fork makes it hard to follow.
> 
> Here's a new version with pid's attached to the ev
> context debugs.
> 
> I think I've also found another issue we might have
> missed before.
> 
> In poll_funcs_context_slot_find() the logic for
> looking for a free slot (ctx == NULL) is tied
> up with the logic looking for an existing match
> (ctx->ev == ev).
> 
> I think that needs to be split so we look for
> an existing match, and only if not found do
> we look for a free slot, and if no free slot
> then we create one.
> 
> The last patch in this series has the fix
> for this.

Ah, that last patch should look like the
attached (missed checking for ctx != NULL
before testing ctx->ev == ev).

Retrying a private autobuild now.
-------------- next part --------------
commit c44cd2ccc2150a2e6b00ffd5bff6b0eb01ca31af
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 16 23:37:20 2016 -0700

    test: look for a match first, before a free slot.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

diff --git a/lib/poll_funcs/poll_funcs_tevent.c b/lib/poll_funcs/poll_funcs_tevent.c
index e84e18f..db2b393 100644
--- a/lib/poll_funcs/poll_funcs_tevent.c
+++ b/lib/poll_funcs/poll_funcs_tevent.c
@@ -522,10 +522,21 @@ static bool poll_funcs_context_slot_find(struct poll_funcs_state *state,
 	size_t num_contexts = talloc_array_length(state->contexts);
 	size_t i;
 
+	/* Look for an existing match first. */
 	for (i=0; i<num_contexts; i++) {
 		struct poll_funcs_tevent_context *ctx = state->contexts[i];
 
-		if ((ctx == NULL) || (ctx->ev == ev)) {
+		if (ctx != NULL && ctx->ev == ev) {
+			*slot = i;
+			return true;
+		}
+	}
+
+	/* Now look for a free slot. */
+	for (i=0; i<num_contexts; i++) {
+		struct poll_funcs_tevent_context *ctx = state->contexts[i];
+
+		if (ctx == NULL) {
 			*slot = i;
 			return true;
 		}


More information about the samba-technical mailing list