[master] 34e327d Disallow SES_Close(SC_NULL)
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 30 09:32:05 CET 2017
commit 34e327d22b5e9b2ee694a18344b54332d8a731db
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 30 08:31:41 2017 +0000
Disallow SES_Close(SC_NULL)
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 10bb4bb..82933ab 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -502,12 +502,12 @@ SES_Close(struct sess *sp, enum sess_close reason)
{
int i;
+ assert(reason > 0);
assert(sp->fd >= 0);
i = close(sp->fd);
assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */
sp->fd = -(int)reason;
- if (reason != SC_NULL)
- ses_close_acct(reason);
+ ses_close_acct(reason);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index b6fd99a..094294c 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -171,7 +171,9 @@ http1_req_panic(struct vsb *vsb, const struct req *req)
static void __match_proto__(vtr_req_fail_f)
http1_req_fail(struct req *req, enum sess_close reason)
{
- if (req->sp->fd >= 0)
+ assert(reason > 0);
+ assert(req->sp->fd != 0);
+ if (req->sp->fd > 0)
SES_Close(req->sp, reason);
}
@@ -401,6 +403,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
if (!FEATURE(FEATURE_HTTP2)) {
VSLb(req->vsl, SLT_Debug,
"H2 attempt");
+ assert(req->doclose > 0);
SES_Close(req->sp, req->doclose);
http1_setstate(sp, H1CLEANUP);
continue;
@@ -418,6 +421,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
req->acct.req_hdrbytes +=
req->htc->rxbuf_e - req->htc->rxbuf_b;
if (i) {
+ assert(req->doclose > 0);
SES_Close(req->sp, req->doclose);
http1_setstate(sp, H1CLEANUP);
continue;
More information about the varnish-commit
mailing list