diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-01-11 01:00:08 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-01-11 01:00:08 +0000 |
commit | 364a57728697f495c1522a548528857a6155a72e (patch) | |
tree | 9ea13c29309ff45345ba5d1275e7a88c75d82543 /usr.sbin | |
parent | c4568904c63d9e8423df35c8b13fc6af31116493 (diff) |
The buffer changes produced some fallout in the mrt code.
Wait until all data has been written out before closing the file and fix
some obvious misstakes. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/mrt.c | 28 |
2 files changed, 15 insertions, 17 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 23f439cea98..8f9e1e3da17 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.61 2004/01/09 19:08:50 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.62 2004/01/11 01:00:07 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -262,7 +262,7 @@ main(int argc, char *argv[]) for (j = PFD_MRT_START; j < i && nfds > 0 ; j++) { if (pfd[j].revents & POLLOUT) { - if ((n = mrt_write(mrt[i])) < 0) { + if ((n = mrt_write(mrt[j])) < 0) { log_err("mrt write error"); } } diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index 4e68ae09e12..588a0938ab3 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.20 2004/01/10 16:20:29 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.21 2004/01/11 01:00:07 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -463,12 +463,7 @@ mrt_queue(struct mrt_head *mrtc, struct imsg *imsg) return (0); if (imsg->hdr.type == IMSG_MRT_END) { - if (mrt_close(m) == 0) { - m->state = MRT_STATE_CLOSE; - } else { - msgbuf_clear(&m->msgbuf); - m->state = MRT_STATE_STOPPED; - } + m->state = MRT_STATE_CLOSE; return (0); } @@ -495,7 +490,6 @@ mrt_write(struct mrt *mrt) int r; if (mrt->state == MRT_STATE_REOPEN || - mrt->state == MRT_STATE_CLOSE || mrt->state == MRT_STATE_REMOVE) r = msgbuf_writebound(&mrt->msgbuf); else @@ -506,6 +500,14 @@ mrt_write(struct mrt *mrt) /* only msgbuf_writebound returns 1 */ break; case 0: + if (mrt->state == MRT_STATE_CLOSE && mrt->msgbuf.queued == 0) { + if (mrt_close(mrt) != 1) { + logit(LOG_ERR, "mrt_write: mrt_close failed"); + mrt_abort(mrt); + return (0); + } + mrt->state = MRT_STATE_STOPPED; + } return (0); case -1: logit(LOG_ERR, "mrt_write: msgbuf_write: %s", @@ -523,6 +525,7 @@ mrt_write(struct mrt *mrt) if (mrt_close(mrt) != 1) { logit(LOG_ERR, "mrt_write: mrt_close failed"); + mrt_abort(mrt); return (0); } @@ -536,11 +539,6 @@ mrt_write(struct mrt *mrt) LIST_REMOVE(mrt, list); free(mrt); return (0); - case MRT_STATE_CLOSE: - /* Close request: free all left buffers */ - msgbuf_clear(&mrt->msgbuf); - mrt->state = MRT_STATE_STOPPED; - return (0); case MRT_STATE_REOPEN: if (mrt_open(mrt) == 0) { mrt_abort(mrt); @@ -664,9 +662,9 @@ mrt_select(struct mrt_head *mc, struct pollfd *pfd, struct mrt **mrt, mrt_abort(m); continue; } - if (start > size) { + if (start < size) { pfd[start].fd = m->msgbuf.sock; - pfd[start].events |= POLLOUT; + pfd[start].events = POLLOUT; mrt[start++] = m; } } |