From 93f226fdd7fd863d667ca20568296621176a26d3 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sat, 12 Jul 2014 20:16:39 +0000 Subject: Close connections when msgbuf_write() returns 0. ok claudio@ --- usr.sbin/ospf6d/rde.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'usr.sbin/ospf6d/rde.c') diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index cdd5dc9dae7..b60d263e756 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.61 2013/11/13 20:49:49 benno Exp $ */ +/* $OpenBSD: rde.c,v 1.62 2014/07/12 20:16:38 krw Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker @@ -266,8 +266,10 @@ rde_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); @@ -638,8 +640,10 @@ rde_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 (;;) { -- cgit v1.2.3