diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2017-02-09 11:16:23 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2017-02-09 11:16:23 +0000 |
commit | 3e39706e91813f95f40244a2babd629f42b32565 (patch) | |
tree | 0bc4e1e50734c950154c6dc3842cb79803fc7d42 /usr.sbin/relayd | |
parent | c6fc3be9514938495b89e95cdd063ec99feebf27 (diff) |
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@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 <pyr@openbsd.org> @@ -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; } |