From: Willy Tarreau Date: Mon, 9 Mar 2009 21:40:57 +0000 (+0100) Subject: [BUG] stream_sock: write timeout must be updated when forwarding ! X-Git-Tag: v1.3.16-rc2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9619468eaaa95de0d6080da5be941941bf6250d;p=thirdparty%2Fhaproxy.git [BUG] stream_sock: write timeout must be updated when forwarding ! When data are forwarded between socket, we must update the output socket's write timeout. This was forgotten, causing sessions to unexpectedly expire during long posts. --- diff --git a/src/stream_sock.c b/src/stream_sock.c index e68775a59c..ed53ca08af 100644 --- a/src/stream_sock.c +++ b/src/stream_sock.c @@ -988,6 +988,23 @@ void stream_sock_chk_snd(struct stream_interface *si) EV_FD_COND_S(si->fd, DIR_WR); } + if (likely(ob->flags & BF_WRITE_ACTIVITY)) { + /* update timeout if we have written something */ + if ((ob->send_max || ob->pipe) && + (ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL)) == BF_WRITE_PARTIAL) + ob->wex = tick_add_ifset(now_ms, ob->wto); + + if (tick_isset(si->ib->rex)) { + /* Note: to prevent the client from expiring read timeouts + * during writes, we refresh it. A better solution would be + * to merge read+write timeouts into a unique one, although + * that needs some study particularly on full-duplex TCP + * connections. + */ + si->ib->rex = tick_add_ifset(now_ms, si->ib->rto); + } + } + /* in case of special condition (error, shutdown, end of write...), we * have to notify the task. */