[master] 05027d746 Remove call to SES_Reserve_proto_priv in h2_init_sess

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


commit 05027d746a11fa3010e2d5f59f96dc97ca3b640b
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 4cf946546..fec88569b 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -101,41 +101,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