[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Sat Feb 2 22:41:01 MST 2013


The branch, master has been updated
       via  570a4b3 tevent_poll: add poll_event_loop_wait()
       via  e79ad7c tevent_poll: fix the usage of tevent_re_initialise()
       via  dd9f0c9 tevent_poll: call tevent_common_fd_destructor() from poll_fresh_fde_destructor()
       via  1cfc76f tevent_poll: Avoid a crash in poll_event_set_fd_flags
       via  611fcca tevent_poll: Avoid a crash in poll_fresh_fde_destructor
       via  0cf62a9 tevent_poll: NULL out fde->event_ctx for "fresh" poll fdes
       via  3ce58cb tevent_poll: Use the poll_event_context_destructor always
       via  e330985 tevent_poll: Re-order routines
       via  d944e2c tevent_poll: Fix a crash in the poll backend
      from  4990080 krb5pac: make sure to correctly store the highest relative pointer offset.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 570a4b3e22dbddb3f1dc095cc1fe1b6a1f3af069
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 1 15:50:08 2013 +0100

    tevent_poll: add poll_event_loop_wait()
    
    We can't use tevent_common_loop_wait() because new fd events
    will be added to the poll_ev->fresh list instead of
    ev->fd_events.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sun Feb  3 06:40:09 CET 2013 on sn-devel-104

commit e79ad7cff196fd6d9250420d83551fd3ac665b19
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 1 15:27:10 2013 +0100

    tevent_poll: fix the usage of tevent_re_initialise()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dd9f0c9b6d4141bc3f40cec1567bfb28b572207c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 1 15:56:34 2013 +0100

    tevent_poll: call tevent_common_fd_destructor() from poll_fresh_fde_destructor()
    
    We need to trigger the fde->close_fn().
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1cfc76f72ae454b13dbaeca22df06cb6f78f078f
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 16:34:41 2013 +0100

    tevent_poll: Avoid a crash in poll_event_set_fd_flags
    
    The event context might have been freed before the fde
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 611fcca641a22a2a23b26752105af99cf338d6a1
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 16:34:41 2013 +0100

    tevent_poll: Avoid a crash in poll_fresh_fde_destructor
    
    The event context might have been freed before the fde
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0cf62a92f26ef9c7d3c5a5d256adc72d66335319
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 16:31:45 2013 +0100

    tevent_poll: NULL out fde->event_ctx for "fresh" poll fdes
    
    This is done in tevent_common_context_destructor for the non-fresh
    fdes already
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3ce58cbcf3d9653ee6b0002f52a29ab922beab4e
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 16:28:08 2013 +0100

    tevent_poll: Use the poll_event_context_destructor always
    
    This is in preparation for the next patch to NULL out the event_ctx
    pointers in the poll_ev->fresh list
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e3309852f717e716181df584716aa17945326565
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 16:25:23 2013 +0100

    tevent_poll: Re-order routines
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d944e2cae15cf1fc2e7601fecd213dec17e5132a
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 31 14:33:15 2013 +0100

    tevent_poll: Fix a crash in the poll backend
    
    If tevent_add_fd is immediately followed by tevent_fd_set_flags, the poll
    backend crashes. This was introduced when the poll backend was prepared
    for the multi-threaded python extension.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/tevent_poll.c |  133 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 105 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index 44e108f..5479f2f 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -55,6 +55,36 @@ struct poll_event_context {
 	int exit_code;
 };
 
+static int poll_event_context_destructor(struct poll_event_context *poll_ev)
+{
+	struct tevent_fd *fd, *fn;
+
+	for (fd = poll_ev->fresh; fd; fd = fn) {
+		fn = fd->next;
+		fd->event_ctx = NULL;
+		DLIST_REMOVE(poll_ev->fresh, fd);
+	}
+
+	if (poll_ev->signal_fd == -1) {
+		/*
+		 * Non-threaded, no signal pipe
+		 */
+		return 0;
+	}
+
+	close(poll_ev->signal_fd);
+	poll_ev->signal_fd = -1;
+
+	if (poll_ev->num_fds == 0) {
+		return 0;
+	}
+	if (poll_ev->fds[0].fd != -1) {
+		close(poll_ev->fds[0].fd);
+		poll_ev->fds[0].fd = -1;
+	}
+	return 0;
+}
+
 /*
   create a poll_event_context structure.
 */
@@ -62,6 +92,14 @@ static int poll_event_context_init(struct tevent_context *ev)
 {
 	struct poll_event_context *poll_ev;
 
+	/*
+	 * we might be called during tevent_re_initialise()
+	 * which means we need to free our old additional_data
+	 * in order to detach old fd events from the
+	 * poll_ev->fresh list
+	 */
+	TALLOC_FREE(ev->additional_data);
+
 	poll_ev = talloc_zero(ev, struct poll_event_context);
 	if (poll_ev == NULL) {
 		return -1;
@@ -69,22 +107,7 @@ static int poll_event_context_init(struct tevent_context *ev)
 	poll_ev->ev = ev;
 	poll_ev->signal_fd = -1;
 	ev->additional_data = poll_ev;
-	return 0;
-}
-
-static int poll_event_mt_destructor(struct poll_event_context *poll_ev)
-{
-	if (poll_ev->signal_fd != -1) {
-		close(poll_ev->signal_fd);
-		poll_ev->signal_fd = -1;
-	}
-	if (poll_ev->num_fds == 0) {
-		return 0;
-	}
-	if (poll_ev->fds[0].fd != -1) {
-		close(poll_ev->fds[0].fd);
-		poll_ev->fds[0].fd = -1;
-	}
+	talloc_set_destructor(poll_ev, poll_event_context_destructor);
 	return 0;
 }
 
@@ -140,7 +163,7 @@ static int poll_event_context_init_mt(struct tevent_context *ev)
 
 	poll_ev->num_fds = 1;
 
-	talloc_set_destructor(poll_ev, poll_event_mt_destructor);
+	talloc_set_destructor(poll_ev, poll_event_context_destructor);
 
 	return 0;
 }
@@ -203,10 +226,18 @@ done:
 
 static int poll_fresh_fde_destructor(struct tevent_fd *fde)
 {
-	struct poll_event_context *poll_ev = talloc_get_type_abort(
-		fde->event_ctx->additional_data, struct poll_event_context);
+	struct tevent_context *ev = fde->event_ctx;
+	struct poll_event_context *poll_ev;
+
+	if (ev == NULL) {
+		goto done;
+	}
+	poll_ev = talloc_get_type_abort(
+		ev->additional_data, struct poll_event_context);
+
 	DLIST_REMOVE(poll_ev->fresh, fde);
-	return 0;
+done:
+	return tevent_common_fd_destructor(fde);
 }
 
 static void poll_event_schedule_immediate(struct tevent_immediate *im,
@@ -256,7 +287,7 @@ static struct tevent_fd *poll_event_add_fd(struct tevent_context *ev,
 	fde->private_data	= private_data;
 	fde->handler_name	= handler_name;
 	fde->location		= location;
-	fde->additional_flags	= 0;
+	fde->additional_flags	= UINT64_MAX;
 	fde->additional_data	= NULL;
 
 	DLIST_ADD(poll_ev->fresh, fde);
@@ -275,10 +306,29 @@ static struct tevent_fd *poll_event_add_fd(struct tevent_context *ev,
 */
 static void poll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 {
-	struct poll_event_context *poll_ev = talloc_get_type_abort(
-		fde->event_ctx->additional_data, struct poll_event_context);
+	struct tevent_context *ev = fde->event_ctx;
+	struct poll_event_context *poll_ev;
 	uint64_t idx = fde->additional_flags;
-	uint16_t pollflags = 0;
+	uint16_t pollflags;
+
+	if (ev == NULL) {
+		return;
+	}
+	poll_ev = talloc_get_type_abort(
+		ev->additional_data, struct poll_event_context);
+
+	fde->flags = flags;
+
+	if (idx == UINT64_MAX) {
+		/*
+		 * poll_event_setup_fresh not yet called after this fde was
+		 * added. We don't have to do anything to transfer the changed
+		 * flags to the array passed to poll(2)
+		 */
+		return;
+	}
+
+	pollflags = 0;
 
 	if (flags & TEVENT_FD_READ) {
 		pollflags |= (POLLIN|POLLHUP);
@@ -286,10 +336,8 @@ static void poll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 	if (flags & TEVENT_FD_WRITE) {
 		pollflags |= (POLLOUT);
 	}
-
 	poll_ev->fds[idx].events = pollflags;
 
-	fde->flags = flags;
 	poll_event_wake_pollthread(poll_ev);
 }
 
@@ -499,6 +547,35 @@ static int poll_event_loop_once(struct tevent_context *ev,
 	return poll_event_loop_poll(ev, &tval);
 }
 
+static int poll_event_loop_wait(struct tevent_context *ev,
+				const char *location)
+{
+	struct poll_event_context *poll_ev = talloc_get_type_abort(
+		ev->additional_data, struct poll_event_context);
+
+	/*
+	 * loop as long as we have events pending
+	 */
+	while (ev->fd_events ||
+	       ev->timer_events ||
+	       ev->immediate_events ||
+	       ev->signal_events ||
+	       poll_ev->fresh) {
+		int ret;
+		ret = _tevent_loop_once(ev, location);
+		if (ret != 0) {
+			tevent_debug(ev, TEVENT_DEBUG_FATAL,
+				     "_tevent_loop_once() failed: %d - %s\n",
+				     ret, strerror(errno));
+			return ret;
+		}
+	}
+
+	tevent_debug(ev, TEVENT_DEBUG_WARNING,
+		     "poll_event_loop_wait() out of events\n");
+	return 0;
+}
+
 static const struct tevent_ops poll_event_ops = {
 	.context_init		= poll_event_context_init,
 	.add_fd			= poll_event_add_fd,
@@ -509,7 +586,7 @@ static const struct tevent_ops poll_event_ops = {
 	.schedule_immediate	= tevent_common_schedule_immediate,
 	.add_signal		= tevent_common_add_signal,
 	.loop_once		= poll_event_loop_once,
-	.loop_wait		= tevent_common_loop_wait,
+	.loop_wait		= poll_event_loop_wait,
 };
 
 _PRIVATE_ bool tevent_poll_init(void)
@@ -527,7 +604,7 @@ static const struct tevent_ops poll_event_mt_ops = {
 	.schedule_immediate	= poll_event_schedule_immediate,
 	.add_signal		= tevent_common_add_signal,
 	.loop_once		= poll_event_loop_once,
-	.loop_wait		= tevent_common_loop_wait,
+	.loop_wait		= poll_event_loop_wait,
 };
 
 _PRIVATE_ bool tevent_poll_mt_init(void)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list