[PATCH] messaging3 improvements

Jeremy Allison jra at samba.org
Wed May 7 16:32:16 MDT 2014


On Wed, May 07, 2014 at 02:53:36PM -0700, Jeremy Allison wrote:
> 
> Ok, don't worry I'm not planning to push until
> I've also reviewed this code and understand *exactly*
> what it's doing (which is fun, as it's complex Volker code :-).

OK, I think the following patch needs squashing
into the source3/lib/poll_funcs/poll_funcs_tevent.c
change:

----------------------------------------------
[PATCH 05/12] lib: Enhance poll_funcs_tevent for multiple tevent_contexts
----------------------------------------------

state->contexts[i] can explicitly contain NULL,
and whilst the code handles this for the
destructor case, and the poll_funcs_context_slot_find()
case, it doesn't cope with state->contexts[i]==NULL
in poll_funcs_watch_find_slot(), tevent_watch_new()
or tevent_watch_update().

Volker, please review (and feel free to merge
into 05/12 if you think it's right).

Thanks,

Jeremy.
-------------- next part --------------
diff --git a/source3/lib/poll_funcs/poll_funcs_tevent.c b/source3/lib/poll_funcs/poll_funcs_tevent.c
index ef215fa..ee800ba 100644
--- a/source3/lib/poll_funcs/poll_funcs_tevent.c
+++ b/source3/lib/poll_funcs/poll_funcs_tevent.c
@@ -121,9 +121,11 @@ static bool poll_funcs_watch_find_slot(struct poll_funcs_state *state,
 	state->watches = watches;
 
 	for (i=0; i<state->num_contexts; i++) {
-		struct poll_funcs_tevent_context *c = state->contexts[i];
 		struct tevent_fd **fdes;
-
+		struct poll_funcs_tevent_context *c = state->contexts[i];
+		if (c == NULL) {
+			continue;
+		}
 		fdes = talloc_realloc(c, c->fdes, struct tevent_fd *,
 				      state->num_watches + 1);
 		if (fdes == NULL) {
@@ -177,7 +179,9 @@ static struct poll_watch *tevent_watch_new(
 
 	for (i=0; i<state->num_contexts; i++) {
 		struct poll_funcs_tevent_context *c = state->contexts[i];
-
+		if (c == NULL) {
+			continue;
+		}
 		c->fdes[slot] = tevent_add_fd(c->ev, c->fdes, w->fd, w->events,
 					      poll_funcs_fde_handler, w);
 		if (c->fdes[slot] == NULL) {
@@ -220,6 +224,9 @@ static void tevent_watch_update(struct poll_watch *w, short events)
 
 	for (i=0; i<state->num_contexts; i++) {
 		struct poll_funcs_tevent_context *c = state->contexts[i];
+		if (c == NULL) {
+			continue;
+		}
 		tevent_fd_set_flags(c->fdes[slot], w->events);
 	}
 }


More information about the samba-technical mailing list