[PATCH] One minor bugfix and a whitespace cleanup in tevent

Jeremy Allison jra at samba.org
Tue Nov 17 21:32:27 UTC 2015


Couple of minor things I've noticed whilst
working inside tevent.

Please review and push !

Thanks,

Jeremy.
-------------- next part --------------
From f70c229806edf469f1863ac52ef485d1595121e5 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Tue, 17 Nov 2015 10:28:50 -0800
Subject: [PATCH 1/2] lib: tevent: Fix bug in poll backend -
 poll_event_loop_poll()

If the (pfd->revents & POLLNVAL) case is triggered,
we do DLIST_REMOVE(ev->fd_events, fde); and then
use fde->next in the loop above.

Save off fde->next for loop interation before
this so we can't use a deleted ->next value.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 lib/tevent/tevent_poll.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index 573ba93..9b1781f 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -498,6 +498,7 @@ static int poll_event_loop_poll(struct tevent_context *ev,
 	int timeout = -1;
 	int poll_errno;
 	struct tevent_fd *fde = NULL;
+	struct tevent_fd *next = NULL;
 	unsigned i;
 
 	if (ev->signal_events && tevent_common_check_signal(ev)) {
@@ -542,11 +543,13 @@ static int poll_event_loop_poll(struct tevent_context *ev,
 	   which ones and call the handler, being careful to allow
 	   the handler to remove itself when called */
 
-	for (fde = ev->fd_events; fde; fde = fde->next) {
+	for (fde = ev->fd_events; fde; fde = next) {
 		uint64_t idx = fde->additional_flags;
 		struct pollfd *pfd;
 		uint16_t flags = 0;
 
+		next = fde->next;
+
 		if (idx == UINT64_MAX) {
 			continue;
 		}
-- 
2.6.0.rc2.230.g3dd15c0


From bcf26bedadcc72d14c0a4c292ff63e0989af90d0 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Tue, 17 Nov 2015 09:13:41 -0800
Subject: [PATCH 2/2] lib: tevent: Whitespace cleanup.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 lib/tevent/tevent_epoll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 01fcde6..507ea5c 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -216,7 +216,7 @@ static void epoll_update_event(struct epoll_event_context *epoll_ev, struct teve
 
 /*
   reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
+  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
   demonstration of why this is needed
  */
 static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
@@ -661,7 +661,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
 	}
 
 	for (i=0;i<ret;i++) {
-		struct tevent_fd *fde = talloc_get_type(events[i].data.ptr, 
+		struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
 						       struct tevent_fd);
 		uint16_t flags = 0;
 		struct tevent_fd *mpx_fde = NULL;
@@ -888,7 +888,7 @@ static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 }
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
 static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
 {
-- 
2.6.0.rc2.230.g3dd15c0



More information about the samba-technical mailing list