[master] 2ce736790 Centralize delete session by htc status for reuse

Nils Goroll nils.goroll at uplex.de
Mon Dec 28 18:03:06 UTC 2020


commit 2ce736790d413a90ec18da04d2a190b20d26176f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Dec 28 18:09:00 2020 +0100

    Centralize delete session by htc status for reuse
    
    adds handling of HTC_S_JUNK

diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index e9ca3f215..a50e1c295 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -586,6 +586,34 @@ SES_Delete(struct sess *sp, enum sess_close reason, vtim_real now)
 	SES_Rel(sp);
 }
 
+void
+SES_DeleteHS(struct sess *sp, enum htc_status_e hs, vtim_real now)
+{
+	enum sess_close reason;
+
+	switch (hs) {
+	case HTC_S_JUNK:
+		reason = SC_RX_JUNK;
+		break;
+	case HTC_S_CLOSE:
+		reason = SC_REM_CLOSE;
+		break;
+	case HTC_S_TIMEOUT:
+		reason = SC_RX_TIMEOUT;
+		break;
+	case HTC_S_OVERFLOW:
+		reason = SC_RX_OVERFLOW;
+		break;
+	case HTC_S_EOF:
+		reason = SC_REM_CLOSE;
+		break;
+	default:
+		WRONG("htc_status (bad)");
+	}
+	SES_Delete(sp, reason, now);
+}
+
+
 /*--------------------------------------------------------------------
  */
 
diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h
index 9d8f9dfc5..36502911a 100644
--- a/bin/varnishd/cache/cache_transport.h
+++ b/bin/varnishd/cache/cache_transport.h
@@ -82,6 +82,7 @@ int VPX_Send_Proxy(int fd, int version, const struct sess *);
 /* cache_session.c */
 struct sess *SES_New(struct pool *);
 void SES_Delete(struct sess *, enum sess_close reason, vtim_real now);
+void SES_DeleteHS(struct sess *, enum htc_status_e hs, vtim_real now);
 void SES_Close(struct sess *, enum sess_close reason);
 void SES_SetTransport(struct worker *, struct sess *, struct req *,
     const struct transport *);
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index de3662f1e..1d1e7c2e6 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -325,22 +325,8 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 				    req->htc->rxbuf_e - req->htc->rxbuf_b;
 				Req_AcctLogCharge(wrk->stats, req);
 				Req_Release(req);
-				switch (hs) {
-				case HTC_S_CLOSE:
-					SES_Delete(sp, SC_REM_CLOSE, NAN);
-					return;
-				case HTC_S_TIMEOUT:
-					SES_Delete(sp, SC_RX_TIMEOUT, NAN);
-					return;
-				case HTC_S_OVERFLOW:
-					SES_Delete(sp, SC_RX_OVERFLOW, NAN);
-					return;
-				case HTC_S_EOF:
-					SES_Delete(sp, SC_REM_CLOSE, NAN);
-					return;
-				default:
-					WRONG("htc_status (bad)");
-				}
+				SES_DeleteHS(sp, hs, NAN);
+				return;
 			}
 			if (hs == HTC_S_IDLE) {
 				wrk->stats->sess_herd++;


More information about the varnish-commit mailing list