diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-09-02 15:35:35 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-09-02 15:35:35 +0000 |
commit | 3eabe6af2c0c1005617c1efd8cb3d5ddd2fff820 (patch) | |
tree | c417d884bf5cfef16c5c7e4cdcabda0b248deeb1 /usr.sbin/dvmrpd/dvmrpe.c | |
parent | 72da5dbbc2aad38f262bc5ed628d429d2aa5458f (diff) |
Close connections when msgbuf_write() returns 0.
Pulled from ospfd. Original author: claudio@
ok rzalamena@ benno@ claudio@
Diffstat (limited to 'usr.sbin/dvmrpd/dvmrpe.c')
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpe.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c index 0ee578e65b2..76b8cb16ea3 100644 --- a/usr.sbin/dvmrpd/dvmrpe.c +++ b/usr.sbin/dvmrpd/dvmrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.c,v 1.16 2016/09/02 15:33:27 renato Exp $ */ +/* $OpenBSD: dvmrpe.c,v 1.17 2016/09/02 15:35:34 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -249,8 +249,10 @@ dvmrpe_dispatch_main(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) <= 0 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) /* connection closed */ + shut = 1; } for (;;) { @@ -321,8 +323,10 @@ dvmrpe_dispatch_rde(int fd, short event, void *bula) shut = 1; } if (event & EV_WRITE) { - if (msgbuf_write(&ibuf->w) <= 0 && errno != EAGAIN) + if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); + if (n == 0) /* connection closed */ + shut = 1; } for (;;) { |