From: bluhm Date: Mon, 14 Jul 2014 00:11:12 +0000 (+0000) Subject: When a connection was spliced in one direction and in copy mode in X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=30791b79957de3aed719a3512204736d30c927ac;p=openbsd When a connection was spliced in one direction and in copy mode in the other direction, the timeouts did not work. They were longer than specified. Link the splicing and non-splicing timeouts. Found by make run-regress-args-timeout-http.pl OK reyk@ --- diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index f4d093fdb82..b5d5f8ff165 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.174 2014/07/13 00:32:08 benno Exp $ */ +/* $OpenBSD: relay.c,v 1.175 2014/07/14 00:11:12 bluhm Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -811,6 +811,7 @@ relay_read(struct bufferevent *bev, void *arg) struct evbuffer *src = EVBUFFER_INPUT(bev); getmonotime(&con->se_tv_last); + cre->timedout = 0; if (!EVBUFFER_LENGTH(src)) return; @@ -942,6 +943,7 @@ relay_error(struct bufferevent *bev, short error, void *arg) relay_close(con, "buffer event timeout"); break; case 1: + cre->timedout = 1; bufferevent_enable(bev, EV_READ); break; } @@ -962,6 +964,9 @@ relay_error(struct bufferevent *bev, short error, void *arg) bufferevent_enable(bev, EV_READ); break; } + } else if (cre->dst->timedout) { + relay_close(con, "splice timeout"); + return; } if (relay_spliceadjust(cre) == -1) goto fail; diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index 6a6beaa33c3..bd0449bde27 100644 --- a/usr.sbin/relayd/relay_http.c +++ b/usr.sbin/relayd/relay_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_http.c,v 1.30 2014/07/13 15:39:01 reyk Exp $ */ +/* $OpenBSD: relay_http.c,v 1.31 2014/07/14 00:11:12 bluhm Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -173,6 +173,7 @@ relay_read_http(struct bufferevent *bev, void *arg) struct kv *hdr = NULL; getmonotime(&con->se_tv_last); + cre->timedout = 0; size = EVBUFFER_LENGTH(src); DPRINTF("%s: session %d: size %lu, to read %lld", @@ -457,6 +458,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg) size_t size; getmonotime(&con->se_tv_last); + cre->timedout = 0; size = EVBUFFER_LENGTH(src); DPRINTF("%s: session %d: size %lu, to read %lld", __func__, @@ -510,6 +512,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg) size_t size; getmonotime(&con->se_tv_last); + cre->timedout = 0; size = EVBUFFER_LENGTH(src); DPRINTF("%s: session %d: size %lu, to read %lld", __func__, diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 6c86e29cc29..622f871cf91 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.188 2014/07/13 00:32:08 benno Exp $ */ +/* $OpenBSD: relayd.h,v 1.189 2014/07/14 00:11:12 bluhm Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -183,10 +183,11 @@ struct ctl_relay_event { enum sslreneg_state sslreneg_state; off_t splicelen; - int line; - size_t headerlen; off_t toread; + size_t headerlen; + int line; int done; + int timedout; enum direction dir; u_int8_t *buf;