[6.0] 8164a366a Remove call to SES_Reserve_proto_priv in h2_init_sess

Martin Blix Grydeland martin at varnish-software.com
Tue Feb 4 10:02:08 UTC 2020


commit 8164a366a085a85e9df18067529a55b141c1cfc2
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Dec 12 13:51:17 2019 +0100

    Remove call to SES_Reserve_proto_priv in h2_init_sess
    
    h2_init_sess can only be reached through H1 with either previous knowledge
    or opportunistic upgrade. Because of this the proto_priv session attribute
    will always be set before entry. This patch simplifies and removes dead
    code containing a call to SES_Reserve_proto_priv.
    
    Note: Better diff with the --ignore-all-space option

diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 5818707f4..9d3683845 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -100,41 +100,37 @@ h2_init_sess(const struct worker *wrk, struct sess *sp,
 	uintptr_t *up;
 	struct h2_sess *h2;
 
-	if (SES_Get_proto_priv(sp, &up)) {
-		/* Already reserved if we came via H1 */
-		XXXAN(SES_Reserve_proto_priv(sp, &up));
-		*up = 0;
-	}
-	if (*up == 0) {
-		if (srq == NULL)
-			srq = Req_New(wrk, sp);
-		AN(srq);
-		h2 = h2s;
-		AN(h2);
-		INIT_OBJ(h2, H2_SESS_MAGIC);
-		h2->srq = srq;
-		h2->htc = srq->htc;
-		h2->ws = srq->ws;
-		h2->vsl = srq->vsl;
-		VSL_Flush(h2->vsl, 0);
-		h2->vsl->wid = sp->vxid;
-		h2->htc->rfd = &sp->fd;
-		h2->sess = sp;
-		h2->rxthr = pthread_self();
-		AZ(pthread_cond_init(h2->winupd_cond, NULL));
-		VTAILQ_INIT(&h2->streams);
-		VTAILQ_INIT(&h2->txqueue);
-		h2_local_settings(&h2->local_settings);
-		h2->remote_settings = H2_proto_settings;
-		h2->decode = decode;
-
-		AZ(VHT_Init(h2->dectbl,
-			h2->local_settings.header_table_size));
-
-		*up = (uintptr_t)h2;
-	}
-	AN(up);
-	CAST_OBJ_NOTNULL(h2, (void*)(*up), H2_SESS_MAGIC);
+	/* proto_priv session attribute will always have been set up by H1
+	 * before reaching here. */
+	AZ(SES_Get_proto_priv(sp, &up));
+	assert(*up == 0);
+
+	if (srq == NULL)
+		srq = Req_New(wrk, sp);
+	AN(srq);
+	h2 = h2s;
+	AN(h2);
+	INIT_OBJ(h2, H2_SESS_MAGIC);
+	h2->srq = srq;
+	h2->htc = srq->htc;
+	h2->ws = srq->ws;
+	h2->vsl = srq->vsl;
+	VSL_Flush(h2->vsl, 0);
+	h2->vsl->wid = sp->vxid;
+	h2->htc->rfd = &sp->fd;
+	h2->sess = sp;
+	h2->rxthr = pthread_self();
+	AZ(pthread_cond_init(h2->winupd_cond, NULL));
+	VTAILQ_INIT(&h2->streams);
+	VTAILQ_INIT(&h2->txqueue);
+	h2_local_settings(&h2->local_settings);
+	h2->remote_settings = H2_proto_settings;
+	h2->decode = decode;
+
+	AZ(VHT_Init(h2->dectbl, h2->local_settings.header_table_size));
+
+	*up = (uintptr_t)h2;
+
 	return (h2);
 }
 


More information about the varnish-commit mailing list