Commit a0effd4d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Simplify the timeout math a bit

parent 9fec4441
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
static enum req_fsm_nxt static enum req_fsm_nxt
http1_wait(struct sess *sp, struct worker *wrk, struct req *req) http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
{ {
int tmo; double tmo;
double now, when; double now, when;
enum sess_close why = SC_NULL; enum sess_close why = SC_NULL;
enum htc_status_e hs; enum htc_status_e hs;
...@@ -69,9 +69,9 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -69,9 +69,9 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
assert(isnan(req->t_prev)); assert(isnan(req->t_prev));
assert(isnan(req->t_req)); assert(isnan(req->t_req));
tmo = (int)floor(1e3 * cache_param->timeout_linger); tmo = cache_param->timeout_linger;
while (1) { while (1) {
hs = SES_Rx(req->htc, tmo * 1e3); hs = SES_Rx(req->htc, tmo);
now = VTIM_real(); now = VTIM_real();
if (hs == HTC_S_OK || hs == HTC_S_TIMEOUT) if (hs == HTC_S_OK || hs == HTC_S_TIMEOUT)
hs = HTTP1_Complete(req->htc); hs = HTTP1_Complete(req->htc);
...@@ -100,8 +100,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -100,8 +100,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
break; break;
} }
when = sp->t_idle + cache_param->timeout_linger; when = sp->t_idle + cache_param->timeout_linger;
tmo = (int)floor(1e3 * (when - now)); tmo = when - now;
if (when < now || tmo == 0) { if (tmo <= 0) {
wrk->stats->sess_herd++; wrk->stats->sess_herd++;
SES_ReleaseReq(req); SES_ReleaseReq(req);
if (VTCP_nonblocking(sp->fd)) if (VTCP_nonblocking(sp->fd))
...@@ -116,8 +116,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -116,8 +116,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
/* Record first byte received time stamp */ /* Record first byte received time stamp */
req->t_first = now; req->t_first = now;
when = req->t_first + cache_param->timeout_req; when = req->t_first + cache_param->timeout_req;
tmo = (int)floor(1e3 * (when - now)); tmo = when - now;
if (when < now || tmo == 0) { if (tmo <= 0) {
why = SC_RX_TIMEOUT; why = SC_RX_TIMEOUT;
break; break;
} }
......
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