Centralize delete session by htc status for reuse

adds handling of HTC_S_JUNK
parent 98f55dae
......@@ -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);
}
/*--------------------------------------------------------------------
*/
......
......@@ -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 *);
......@@ -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++;
......
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