[master] a29507a10 http: Record which peer wants to close the session

Nils Goroll nils.goroll at uplex.de
Fri Oct 9 09:36:07 UTC 2020


commit a29507a1045dd7fa6571eeef2bbcaed96cf62ad6
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Oct 8 16:34:00 2020 +0200

    http: Record which peer wants to close the session
    
    Spotted by Martin.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index fc4d5c71d..4497d20dd 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -650,7 +650,7 @@ int HTTP_IterHdrPack(struct worker *, struct objcore *, const char **);
 #define HTTP_FOREACH_PACK(wrk, oc, ptr) \
 	 for ((ptr) = NULL; HTTP_IterHdrPack(wrk, oc, &(ptr));)
 const char *HTTP_GetHdrPack(struct worker *, struct objcore *, const char *hdr);
-enum sess_close http_DoConnection(struct http *hp);
+enum sess_close http_DoConnection(struct http *hp, enum sess_close sc_close);
 int http_IsFiltered(const struct http *hp, unsigned u, unsigned how);
 
 #define HTTPH_R_PASS		(1 << 0)	/* Request (c->b) in pass mode */
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 6986860ce..09fce7def 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -730,12 +730,15 @@ http_GetContentLength(const struct http *hp)
  */
 
 enum sess_close
-http_DoConnection(struct http *hp)
+http_DoConnection(struct http *hp, enum sess_close sc_close)
 {
 	const char *h, *b, *e;
 	enum sess_close retval;
 	unsigned u, v;
 
+	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+	assert(sc_close == SC_REQ_CLOSE || sc_close == SC_RESP_CLOSE);
+
 	if (hp->protover == 10)
 		retval = SC_REQ_HTTP10;
 	else
@@ -748,7 +751,7 @@ http_DoConnection(struct http *hp)
 	while (http_split(&h, NULL, ",", &b, &e)) {
 		u = pdiff(b, e);
 		if (u == 5 && !strncasecmp(b, "close", u))
-			retval = SC_REQ_CLOSE;
+			retval = sc_close;
 		if (u == 10 && !strncasecmp(b, "keep-alive", u))
 			retval = SC_NULL;
 
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 6cb1f7a67..47ed06b31 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -83,7 +83,7 @@ cnt_transport(struct worker *wrk, struct req *req)
 
 	AZ(req->err_code);
 
-	req->doclose = http_DoConnection(req->http);
+	req->doclose = http_DoConnection(req->http, SC_REQ_CLOSE);
 	if (req->doclose == SC_RX_BAD) {
 		(void)req->transport->minimal_response(req, 400);
 		return (REQ_FSM_DONE);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 3892b1544..99a4c58d9 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -234,7 +234,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
 		return (-1);
 	}
 
-	htc->doclose = http_DoConnection(hp);
+	htc->doclose = http_DoConnection(hp, SC_RESP_CLOSE);
 
 	/*
 	 * Figure out how the fetch is supposed to happen, before the
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index c93145322..54be4148b 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -298,7 +298,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody)
 
 	VSLb(req->vsl, SLT_RespProtocol, "HTTP/2.0");
 
-	(void)http_DoConnection(req->resp);
+	(void)http_DoConnection(req->resp, SC_RESP_CLOSE);
 
 	ss = WS_Snapshot(req->ws);
 


More information about the varnish-commit mailing list