diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-10-13 09:08:22 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-10-13 09:08:22 +0000 |
commit | e83666188898c18fc518d5976b31f3319b1dd3f5 (patch) | |
tree | 42b7e945c473befee8e2353fd2d26bb5e2be785f /usr.sbin/bgpd | |
parent | 5090fc5d447c6b68a12d0d09a0a90ee0f8610d28 (diff) |
Simplify poll loop, there is no need for nfds tracking. While there kill
some comments that are totaly wrong. OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 95d1082ed31..0a68dc3db66 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.173 2005/09/21 13:35:03 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.174 2005/10/13 09:08:21 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -123,7 +123,7 @@ rde_main(struct bgpd_config *config, struct peer *peer_l, struct peer *p; struct listen_addr *la; struct pollfd pfd[3]; - int nfds, i; + int i; switch (pid = fork()) { case -1: @@ -216,31 +216,27 @@ rde_main(struct bgpd_config *config, struct peer *peer_l, i++; } - if ((nfds = poll(pfd, i, INFTIM)) == -1) + if (poll(pfd, i, INFTIM) == -1) if (errno != EINTR) fatal("poll error"); - if (nfds > 0 && (pfd[PFD_PIPE_MAIN].revents & POLLOUT) && + if ((pfd[PFD_PIPE_MAIN].revents & POLLOUT) && ibuf_main->w.queued) if (msgbuf_write(&ibuf_main->w) < 0) fatal("pipe write error"); - if (nfds > 0 && pfd[PFD_PIPE_MAIN].revents & POLLIN) { - nfds--; + if (pfd[PFD_PIPE_MAIN].revents & POLLIN) rde_dispatch_imsg_parent(ibuf_main); - } - if (nfds > 0 && (pfd[PFD_PIPE_SESSION].revents & POLLOUT) && + if ((pfd[PFD_PIPE_SESSION].revents & POLLOUT) && ibuf_se->w.queued) if (msgbuf_write(&ibuf_se->w) < 0) fatal("pipe write error"); - if (nfds > 0 && pfd[PFD_PIPE_SESSION].revents & POLLIN) { - nfds--; + if (pfd[PFD_PIPE_SESSION].revents & POLLIN) rde_dispatch_imsg_session(ibuf_se); - } - if (nfds > 0 && pfd[PFD_MRT_FILE].revents & POLLOUT) { + if (pfd[PFD_MRT_FILE].revents & POLLOUT) { if (mrt_write(mrt) == -1) { free(mrt); mrt = NULL; @@ -1869,10 +1865,6 @@ rde_update6_queue_runner(void) b = up_dump_mp_unreach(queue_buf, &len, peer); if (b == NULL) - /* - * No packet to send. The 4 bytes are the - * needed withdraw and path attribute length. - */ continue; /* finally send message to SE */ if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, @@ -1892,10 +1884,6 @@ rde_update6_queue_runner(void) b = up_dump_mp_reach(queue_buf, &len, peer); if (b == NULL) - /* - * No packet to send. The 4 bytes are the - * needed withdraw and path attribute length. - */ continue; /* finally send message to SE */ if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, |