From: Willy Tarreau Date: Tue, 31 Dec 2013 21:33:13 +0000 (+0100) Subject: OPTIM: session: set the READ_DONTWAIT flag when connecting X-Git-Tag: v1.5-dev22~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d81ca040514e509dd218fa704f254c9cbc11c39c;p=thirdparty%2Fhaproxy.git OPTIM: session: set the READ_DONTWAIT flag when connecting As soon as we connect to the server, we want to limit the number of recvfrom() on the response path because most of the time a single call will retrieve enough information. At the moment this is only done in the HTTP response parser, after some reads have already failed, which is too late. We need to do that at the earliest possible instant. It was already done for the request side by frontend_accept() for the first request, and by http_reset_txn() for the next requests. Thanks to this change, there are no more failed recvfrom() calls in keep-alive mode. --- diff --git a/src/session.c b/src/session.c index 18d670ebd6..72daf61580 100644 --- a/src/session.c +++ b/src/session.c @@ -942,10 +942,7 @@ static void sess_establish(struct session *s, struct stream_interface *si) } else { s->txn.rsp.msg_state = HTTP_MSG_RPBEFORE; - /* reset hdr_idx which was already initialized by the request. - * right now, the http parser does it. - * hdr_idx_init(&s->txn.hdr_idx); - */ + rep->flags |= CF_READ_DONTWAIT; /* a single read is enough to get response headers */ } rep->analysers |= s->fe->fe_rsp_ana | s->be->be_rsp_ana;