From b2fe9673de39bf638f6b8ec64e99ce58952fb07d Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 15 Feb 2017 13:08:47 +0100 Subject: [PATCH] Fix realloc pfds set error + callback order error --- src/extension/poll_eventloop.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/extension/poll_eventloop.c b/src/extension/poll_eventloop.c index 331e5d4b..f5e609ab 100644 --- a/src/extension/poll_eventloop.c +++ b/src/extension/poll_eventloop.c @@ -317,7 +317,7 @@ poll_eventloop_run_once(getdns_eventloop *loop, int blocking) if (num_pfds >= poll_loop->pfds_capacity) { poll_loop->pfds_capacity = up_pow2(num_pfds + 1); - if (poll_loop->pfds) { + if (!poll_loop->pfds) { poll_loop->pfds = GETDNS_XMALLOC(poll_loop->mf, struct pollfd, poll_loop->pfds_capacity); } else poll_loop->pfds = GETDNS_XREALLOC(poll_loop->mf, poll_loop->pfds, struct pollfd, poll_loop->pfds_capacity); @@ -363,13 +363,13 @@ poll_eventloop_run_once(getdns_eventloop *loop, int blocking) _getdns_eventloop_info* fd_event = find_event(&poll_loop->fd_events, fd); if (fd_event && fd_event->event) { getdns_eventloop_event* event = fd_event->event; - if (event->read_cb && - (poll_loop->pfds[i].revents & POLLIN)) - poll_read_cb(fd, event); - if (event->write_cb && (poll_loop->pfds[i].revents & POLLOUT)) poll_write_cb(fd, event); + + else if (event->read_cb && + (poll_loop->pfds[i].revents & POLLIN)) + poll_read_cb(fd, event); } } HASH_ITER(hh, poll_loop->fd_events, s, tmp) {