From 3e39706e91813f95f40244a2babd629f42b32565 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Thu, 9 Feb 2017 11:16:23 +0000 Subject: Do not loose the send/expect validation error on timeout. When a read timeout is reached, the code also has to check if there is already anything in the input buffer and verify it again. This fixes relayd and relayctl to show "send/expect failed" instead of "tcp read timeout". Found by Michael W. Lucas (while working on the Relayd Mastery book). Thanks. OK benno@ --- usr.sbin/relayd/check_tcp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'usr.sbin/relayd') diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index 05b7860827d..bbf3258f70c 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.51 2016/01/11 21:31:42 benno Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.52 2017/02/09 11:16:22 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard @@ -233,8 +233,12 @@ tcp_read_buf(int s, short event, void *arg) struct ctl_tcp_event *cte = arg; if (event == EV_TIMEOUT) { - tcp_close(cte, HOST_DOWN); - hce_notify_done(cte->host, HCE_TCP_READ_TIMEOUT); + if (ibuf_size(cte->buf)) + (void)cte->validate_close(cte); + else + cte->host->he = HCE_TCP_READ_TIMEOUT; + tcp_close(cte, cte->host->up == HOST_UP ? 0 : HOST_DOWN); + hce_notify_done(cte->host, cte->host->he); return; } -- cgit v1.2.3