X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fevent.c;h=8c7de4799e95f570d858d6a063585d018627a85f;hb=a742ea4d040ecfaabbc875c63f2625654ce68923;hp=9cd7d07ae7246a0554db90c84760bd3445da0cec;hpb=d6c8a1a3d3e945142b251b2897517e10ce0dfce4;p=tinc diff --git a/src/event.c b/src/event.c index 9cd7d07a..8c7de479 100644 --- a/src/event.c +++ b/src/event.c @@ -348,6 +348,8 @@ bool event_loop(void) { continue; } + unsigned int curgen = io_tree.generation; + for splay_each(io_t, io, &io_tree) { if(FD_ISSET(io->fd, &writable)) { io->cb(io->data, IO_WRITE); @@ -360,10 +362,12 @@ bool event_loop(void) { /* There are scenarios in which the callback will remove another io_t from the tree (e.g. closing a double connection). Since splay_each does not support that, we - need to exit the loop now. That's okay, since any remaining events will get picked - up by the next select() call. + need to exit the loop if that happens. That's okay, since any remaining events will + get picked up by the next select() call. */ - break; + if(curgen != io_tree.generation) { + break; + } } }