Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit dadd3f1

Browse files
committed
vrt_var: req.ttl and req.grace are NAN when unset
1 parent 5ca631e commit dadd3f1

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

bin/varnishd/cache/cache_expire.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ EXP_Ttl(const struct req *req, const struct objcore *oc)
7373
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
7474

7575
r = oc->ttl;
76-
if (req != NULL && req->d_ttl >= 0. && req->d_ttl < r)
76+
if (req != NULL && !isnan(req->d_ttl) && req->d_ttl < r)
7777
r = req->d_ttl;
7878
return (oc->t_origin + r);
7979
}
@@ -91,7 +91,7 @@ EXP_Ttl_grace(const struct req *req, const struct objcore *oc)
9191
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
9292

9393
g = oc->grace;
94-
if (req != NULL && req->d_grace >= 0. && req->d_grace < g)
94+
if (req != NULL && !isnan(req->d_grace) && req->d_grace < g)
9595
g = req->d_grace;
9696
return (EXP_Ttl(req, oc) + g);
9797
}

bin/varnishd/cache/cache_req_fsm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ cnt_recv_prep(struct req *req, const char *ci)
891891
VRT_Assign_Backend(&req->director_hint,
892892
VCL_DefaultDirector(req->vcl));
893893

894-
req->d_ttl = -1;
895-
req->d_grace = -1;
894+
req->d_ttl = NAN;
895+
req->d_grace = NAN;
896896
req->disable_esi = 0;
897897
req->hash_always_miss = 0;
898898
req->hash_ignore_busy = 0;

bin/varnishd/cache/cache_vrt_var.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,17 @@ VRT_u_req_##nm(VRT_CTX) \
569569
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
570570
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \
571571
ctx->req->elem = val; \
572+
ctx->req->elem = val; \
572573
}
573574

574575
REQ_VAR_R(backend_hint, director_hint, VCL_BACKEND)
575576

576577
REQ_VAR_L(ttl, d_ttl, VCL_DURATION, if (!(arg>0.0)) arg = 0;)
577578
REQ_VAR_R(ttl, d_ttl, VCL_DURATION)
578-
REQ_VAR_U(ttl, d_ttl, -1)
579+
REQ_VAR_U(ttl, d_ttl, NAN)
579580
REQ_VAR_L(grace, d_grace, VCL_DURATION, if (!(arg>0.0)) arg = 0;)
580581
REQ_VAR_R(grace, d_grace, VCL_DURATION)
581-
REQ_VAR_U(grace, d_grace, -1)
582+
REQ_VAR_U(grace, d_grace, NAN)
582583

583584
VCL_VOID
584585
VRT_l_req_backend_hint(VRT_CTX, VCL_BACKEND be)

0 commit comments

Comments
 (0)