Commit 7243e9c5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change the way we close client sessions.

Previously we always used SO_LINGER to make sure that all queued data
got transmitted, no matter under which circumstances we closed the
client connection.

Change this so that SO_LINGER is only activated for orderly connection
closure (ie: "Connection: close" from client or error handling), in
all other cases (usually the client connecting on us, abandon any data
queued for transmission.

This _may_ reduce the tendency of worker threads to get hung up on
network failures a little bit.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4046 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c47a4d09
......@@ -68,7 +68,9 @@ static struct waiter const *vca_act;
static pthread_t vca_thread_acct;
static struct timeval tv_sndtimeo;
static struct timeval tv_rcvtimeo;
static struct linger linger;
static const struct linger linger = {
.l_onoff = 1,
};
static unsigned char need_sndtimeo, need_rcvtimeo, need_linger, need_test;
......
......@@ -242,8 +242,15 @@ cnt_done(struct sess *sp)
sp->t_req = NAN;
if (sp->fd >= 0 && sp->doclose != NULL)
if (sp->fd >= 0 && sp->doclose != NULL) {
/*
* This is an orderly close of the connection; ditch linger
* before we close, to get queued data transmitted.
*/
struct linger lin = { 0, 0 };
AZ(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof lin));
vca_close_session(sp, sp->doclose);
}
if (sp->fd < 0) {
SES_Charge(sp);
VSL_stats->sess_closed++;
......
# $Id$
test "Test orderly connection closure"
server s1 {
rxreq
txresp -bodylen 130000
} -start
varnish v1 -vcl+backend { } -start
client c1 {
txreq -hdr "Connection: close"
delay 3
rxresp
expect resp.bodylen == 130000
} -run
......@@ -769,7 +769,7 @@ http_process(struct vtclog *vl, const char *spec, int sock, int client)
hp->vl = vl;
hp->client = client;
hp->timeout = 3000;
hp->nrxbuf = 64*1024;
hp->nrxbuf = 640*1024;
hp->vsb = vsb_newauto();
hp->rxbuf = malloc(hp->nrxbuf); /* XXX */
AN(hp->rxbuf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment