diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-07-12 20:16:39 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-07-12 20:16:39 +0000 |
commit | 93f226fdd7fd863d667ca20568296621176a26d3 (patch) | |
tree | 30c7a25aa8da5b4c855e46c9df765fb8e80ed899 /usr.sbin/ldpd | |
parent | 968d9aade2b89c5889776f17a59253ccf5d649e3 (diff) |
Close connections when msgbuf_write() returns 0.
ok claudio@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/lde.c | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 10 |
3 files changed, 21 insertions, 9 deletions
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index c089ca2b2df..99fd3b44ed7 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.28 2013/11/26 11:59:38 henning Exp $ */ +/* $OpenBSD: lde.c,v 1.29 2014/07/12 20:16:38 krw Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -211,8 +211,10 @@ lde_dispatch_imsg(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) /* connection closed */ + shut = 1; } clock_gettime(CLOCK_MONOTONIC, &tp); @@ -367,8 +369,10 @@ lde_dispatch_parent(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) /* connection closed */ + shut = 1; } for (;;) { diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index a590ee4d288..621ff71d7a6 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.19 2013/11/26 11:59:38 henning Exp $ */ +/* $OpenBSD: ldpd.c,v 1.20 2014/07/12 20:16:38 krw Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -339,8 +339,10 @@ main_dispatch_ldpe(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) + shut = 1; } for (;;) { @@ -415,8 +417,10 @@ main_dispatch_lde(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) + shut = 1; } for (;;) { diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 47ac0dcce48..565da95d759 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.23 2013/11/26 11:59:38 henning Exp $ */ +/* $OpenBSD: ldpe.c,v 1.24 2014/07/12 20:16:38 krw Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -330,8 +330,10 @@ ldpe_dispatch_main(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("ldpe_dispatch_main: msgbuf_write"); + if (n == 0) + shut = 1; } for (;;) { @@ -470,8 +472,10 @@ ldpe_dispatch_lde(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("ldpe_dispatch_lde: msgbuf_write"); + if (n == 0) + shut = 1; } for (;;) { |