Commit 34e327d2 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Disallow SES_Close(SC_NULL)

parent a5a3affe
......@@ -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);
}
/*--------------------------------------------------------------------
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment