[experimental-ims] 5ecc60f Merge master -> experimental-ims
Geoff Simmons
geoff at varnish-cache.org
Tue Jan 10 00:03:35 CET 2012
commit 5ecc60f79fb0eb64d8945832ad4c9c3b7579bc69
Merge: 9e5fe24 6bec2c8
Author: Geoff Simmons <geoff at uplex.de>
Date: Mon Jan 9 22:47:17 2012 +0100
Merge master -> experimental-ims
diff --cc bin/varnishd/cache/cache.h
index 521786b,6b0d0a9..898f3ba
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@@ -594,39 -604,49 +604,51 @@@ struct req
char *client_identity;
/* HTTP request */
- const char *doclose;
struct http *http;
struct http *http0;
+ struct http *resp;
struct ws ws[1];
- char *ws_ses; /* WS above session data */
- char *ws_req; /* WS above request data */
+ struct object *obj;
+ struct objcore *objcore;
+ /* Lookup stuff */
+ struct SHA256Context *sha256ctx;
+ /* This is only here so VRT can find it */
+ const char *storage_hint;
- unsigned char digest[DIGEST_LEN];
+ /* ESI delivery stuff */
+ int gzip_resp;
+ ssize_t l_crc;
+ uint32_t crc;
- /* Built Vary string */
- uint8_t *vary_b;
- uint8_t *vary_l;
- uint8_t *vary_e;
- struct http_conn htc[1];
+ };
- /* Timestamps, all on TIM_real() timescale */
- double t_open;
- double t_req;
- double t_resp;
- double t_end;
+ /*--------------------------------------------------------------------
+ * Struct sess is a high memory-load structure because sessions typically
+ * hang around the waiter for relatively long time.
+ *
+ * The size goal for struct sess + struct memitem is <512 bytes
+ *
+ * Getting down to the next relevant size (<256 bytes because of how malloc
+ * works, is not realistic without a lot of code changes.
+ */
- /* Acceptable grace period */
- struct exp exp;
+ struct sess {
+ unsigned magic;
+ #define SESS_MAGIC 0x2c2f9c5a
enum step step;
- unsigned cur_method;
- unsigned handling;
- unsigned char sendbody;
- unsigned char wantbody;
- uint16_t err_code;
- const char *err_reason;
+ int fd;
+ unsigned vsl_id;
+
++ struct object *stale_obj;
++
+ /* Cross references ------------------------------------------*/
+
+ struct sesspool *sesspool;
+ struct worker *wrk;
+ struct req *req;
VTAILQ_ENTRY(sess) list;
diff --cc bin/varnishd/cache/cache_center.c
index dd4e1bd,4967c82..22430ca
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@@ -619,10 -641,9 +641,10 @@@ cnt_fetch(struct sess *sp, struct worke
EXP_Clr(&wrk->busyobj->exp);
wrk->busyobj->exp.entered = W_TIM_real(wrk);
RFC2616_Ttl(sp);
+ wrk->busyobj->exp.keep = cache_param->default_keep;
/* pass from vclrecv{} has negative TTL */
- if (wrk->objcore == NULL)
+ if (req->objcore == NULL)
wrk->busyobj->exp.ttl = -1.;
AZ(wrk->busyobj->do_esi);
@@@ -790,14 -810,10 +811,14 @@@ cnt_fetchbody(struct sess *sp, struct w
l = http_EstimateWS(wrk->busyobj->beresp,
pass ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp);
+ if (sp->stale_obj) {
+ l += http_EstimateWS(sp->stale_obj->http, 0, &stale_nhttp);
+ nhttp += stale_nhttp;
+ }
/* Create Vary instructions */
- if (wrk->objcore != NULL) {
- CHECK_OBJ_NOTNULL(wrk->objcore, OBJCORE_MAGIC);
+ if (req->objcore != NULL) {
+ CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
vary = VRY_Create(sp, wrk->busyobj->beresp);
if (vary != NULL) {
varyl = VSB_len(vary);
@@@ -835,10 -851,9 +856,11 @@@
VBO_DerefBusyObj(wrk, &wrk->busyobj);
return (0);
}
- CHECK_OBJ_NOTNULL(wrk->obj, OBJECT_MAGIC);
+ CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
+
+ wrk->busyobj->exp.keep = sp->exp.keep;
+
- wrk->storage_hint = NULL;
+ req->storage_hint = NULL;
if (wrk->busyobj->do_gzip ||
(wrk->busyobj->is_gzip && !wrk->busyobj->do_gunzip))
@@@ -862,32 -877,14 +884,32 @@@
hp2->logtag = HTTP_Obj;
http_CopyResp(hp2, hp);
+
http_FilterFields(wrk, sp->vsl_id, hp2, hp,
pass ? HTTPH_R_PASS : HTTPH_A_INS);
+
+ /*
+ * If we found a candidate for conditional backend request, attempt it
+ * now. If backend responds with 304, http_Check304() merges stale_obj
+ * into wrk->obj, any other response is handled as usual. In either case,
+ * the stale_obj is no longer needed in the cache, so discard it.
+ */
+ if (sp->stale_obj) {
+ http_Check304(sp);
+ if (wrk->busyobj->beresp->status == 304)
+ assert(wrk->obj->http->status == 200);
+ EXP_Clr(&sp->stale_obj->exp);
+ EXP_Rearm(sp->stale_obj);
+ HSH_Deref(sp->wrk, NULL, &sp->stale_obj);
+ AZ(sp->stale_obj);
+ }
http_CopyHome(wrk, sp->vsl_id, hp2);
- if (http_GetHdr(hp, H_Last_Modified, &b))
- req->obj->last_modified = VTIM_parse(b);
+ if (http_GetHdr(hp, H_Last_Modified, &b)
+ || http_GetHdr(wrk->obj->http, H_Last_Modified, &b))
+ wrk->obj->last_modified = VTIM_parse(b);
else
- wrk->obj->last_modified = floor(wrk->busyobj->exp.entered);
+ req->obj->last_modified = floor(wrk->busyobj->exp.entered);
assert(WRW_IsReleased(wrk));
@@@ -1227,11 -1217,9 +1242,11 @@@ cnt_lookup(struct sess *sp, struct work
if (oc->flags & OC_F_PASS) {
wrk->stats.cache_hitpass++;
- WSP(sp, SLT_HitPass, "%u", wrk->obj->xid);
- (void)HSH_Deref(wrk, NULL, &wrk->obj);
+ WSP(sp, SLT_HitPass, "%u", req->obj->xid);
+ (void)HSH_Deref(wrk, NULL, &req->obj);
+ if (sp->stale_obj != NULL)
+ (void)HSH_Deref(wrk, NULL, &sp->stale_obj);
- wrk->objcore = NULL;
+ req->objcore = NULL;
sp->step = STP_PASS;
return (0);
}
@@@ -1297,18 -1284,12 +1311,18 @@@ cnt_miss(struct sess *sp, struct worke
wrk->first_byte_timeout = 0;
wrk->between_bytes_timeout = 0;
+ /* If a candidate for a conditional backend request was found,
+ * add If-Modified-Since and/or If-None-Match to the bereq.
+ */
+ if (sp->stale_obj)
+ http_CheckRefresh(sp);
+
VCL_miss_method(sp);
- switch(sp->handling) {
+ switch(req->handling) {
case VCL_RET_ERROR:
- AZ(HSH_Deref(wrk, wrk->objcore, NULL));
- wrk->objcore = NULL;
+ AZ(HSH_Deref(wrk, req->objcore, NULL));
+ req->objcore = NULL;
http_Setup(wrk->busyobj->bereq, NULL);
VBO_DerefBusyObj(wrk, &wrk->busyobj);
sp->step = STP_ERROR;
diff --cc bin/varnishd/cache/cache_hash.c
index c56a2d5,d967291..75f568c
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@@ -303,10 -302,9 +304,10 @@@ HSH_Lookup(struct sess *sp, struct objh
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC);
- AN(sp->director);
+ CHECK_OBJ_NOTNULL(sp->req->http, HTTP_MAGIC);
+ AN(sp->req->director);
AN(hash);
+ AZ(sp->stale_obj);
wrk = sp->wrk;
HSH_Prealloc(sp);
diff --cc bin/varnishd/cache/cache_http.c
index b314b55,f441ef2..ef7bbc5
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@@ -912,93 -878,12 +912,94 @@@ http_FilterHeader(const struct sess *sp
if (how == HTTPH_R_FETCH)
http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1");
else
- http_copyh(hp, sp->http, HTTP_HDR_PROTO);
- http_FilterFields(sp->wrk, sp->vsl_id, hp, sp->http, how);
- http_PrintfHeader(sp->wrk, sp->vsl_id, hp, "X-Varnish: %u", sp->xid);
+ http_copyh(hp, sp->req->http, HTTP_HDR_PROTO);
+ http_FilterFields(sp->wrk, sp->vsl_id, hp, sp->req->http, how);
+ http_PrintfHeader(sp->wrk, sp->vsl_id, hp,
+ "X-Varnish: %u", sp->req->xid);
}
+/*-------------------------------------------------------------------
+ * This function checks for sp->freshen_obj. If present, HSH_Lookup()
+ * found an expired object that qualifies for a refresh check,
+ * so add the appropriate headers.
+ */
+
+void
+http_CheckRefresh(struct sess *sp)
+{
+ struct object *freshen_obj;
+ struct http *obj_hp, *bereq_hp;
+ char *p;
+
+ freshen_obj = sp->stale_obj;
+ CHECK_OBJ_NOTNULL(freshen_obj, OBJECT_MAGIC);
+ bereq_hp = sp->wrk->busyobj->bereq;
+ CHECK_OBJ_NOTNULL(bereq_hp, HTTP_MAGIC);
+ obj_hp = freshen_obj->http;
+ CHECK_OBJ_NOTNULL(obj_hp, HTTP_MAGIC);
+
+ if(http_GetHdr(obj_hp, H_ETag, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, bereq_hp, "If-None-Match: %s", p);
+
+ if(http_GetHdr(obj_hp, H_Last_Modified, &p))
+ http_PrintfHeader(sp->wrk, sp->fd, bereq_hp, "If-Modified-Since: %s",p);
+}
+
+/*-------------------------------------------------------------------
+ * Called after fetch and sp->freshen_obj present. Check
+ * response and handle as needed.
+ */
+
+void
+http_Check304(struct sess *sp)
+{
+ struct object *o, *o_stale;
+ char *p;
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ o_stale = sp->stale_obj;
+ CHECK_OBJ_NOTNULL(o_stale, OBJECT_MAGIC);
+ o = sp->wrk->obj;
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+
+ if (sp->wrk->busyobj->beresp->status != 304) {
+ /*
+ * IMS/INM headers may have been removed in VCL, so only count a
+ * non-validating response if they were present in the request.
+ */
+ if (http_GetHdr(sp->wrk->busyobj->bereq, H_If_Modified_Since, &p)
+ || http_GetHdr(sp->wrk->busyobj->bereq, H_If_None_Match, &p))
+ sp->wrk->stats.fetch_not_validated++;
+ return;
+ }
+
+ /*
+ * Copy headers we need from the stale object into the 304 response
+ */
+ http_FilterMissingFields(sp->wrk, sp->fd, o->http, o_stale->http);
+
+ /*
+ * Dup the stale object's storage in to the new object
+ * and reset Content-Length from the size of the storage.
+ */
+ STV_dup(sp, o_stale, o);
+ http_Unset(o->http, H_Content_Length);
+ http_PrintfHeader(sp->wrk, sp->fd, o->http, "Content-Length: %u", o->len);
+
+ http_SetResp(o->http, "HTTP/1.1", 200, "Ok Not Modified");
+ http_SetH(o->http, HTTP_HDR_REQ, "GET");
+ http_copyh(o->http, sp->wrk->busyobj->bereq, HTTP_HDR_URL);
+
+ /*
+ * XXX: Are we copying all the necessary fields from stale_obj?
+ * Should we copy o_stale->hits into o->hits?
+ */
+ o->response = 200;
+ o->gziped = o_stale->gziped;
+
+ AZ(o_stale->objcore->flags & OC_F_BUSY);
+}
+
/*--------------------------------------------------------------------
* This function copies any header fields which reference foreign
* storage into our own WS.
diff --cc bin/varnishd/cache/cache_vrt.c
index 290b6bf,2623bcc..50a7b7f
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@@ -106,16 -107,12 +107,16 @@@ vrt_selecthttp(const struct sess *sp, e
hp = sp->wrk->busyobj->beresp;
break;
case HDR_RESP:
- hp = sp->wrk->resp;
+ hp = sp->req->resp;
break;
case HDR_OBJ:
- CHECK_OBJ_NOTNULL(sp->wrk->obj, OBJECT_MAGIC);
- hp = sp->wrk->obj->http;
+ CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC);
+ hp = sp->req->obj->http;
break;
+ case HDR_STALE_OBJ:
+ CHECK_OBJ_NOTNULL(sp->stale_obj, OBJECT_MAGIC);
+ hp = sp->stale_obj->http;
+ break;
default:
INCOMPL();
}
diff --cc bin/varnishd/cache/cache_vrt_var.c
index b5a5bac,e051dbb..5f60a5c
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@@ -82,32 -78,22 +82,32 @@@ const char *
VRT_r_##obj##_##hdr(const struct sess *sp) \
{ \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
- CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); \
- return (http->hd[fld].b); \
-}
-
-VRT_DO_HDR(req, request, sp->req->http, HTTP_HDR_REQ)
-VRT_DO_HDR(req, url, sp->req->http, HTTP_HDR_URL)
-VRT_DO_HDR(req, proto, sp->req->http, HTTP_HDR_PROTO)
-VRT_DO_HDR(bereq, request, sp->wrk->busyobj->bereq, HTTP_HDR_REQ)
-VRT_DO_HDR(bereq, url, sp->wrk->busyobj->bereq, HTTP_HDR_URL)
-VRT_DO_HDR(bereq, proto, sp->wrk->busyobj->bereq, HTTP_HDR_PROTO)
-VRT_DO_HDR(obj, proto, sp->req->obj->http, HTTP_HDR_PROTO)
-VRT_DO_HDR(obj, response, sp->req->obj->http, HTTP_HDR_RESPONSE)
-VRT_DO_HDR(resp, proto, sp->req->resp, HTTP_HDR_PROTO)
-VRT_DO_HDR(resp, response, sp->req->resp, HTTP_HDR_RESPONSE)
-VRT_DO_HDR(beresp, proto, sp->wrk->busyobj->beresp, HTTP_HDR_PROTO)
-VRT_DO_HDR(beresp, response, sp->wrk->busyobj->beresp, HTTP_HDR_RESPONSE)
+ if (!nullable || cont != NULL) { \
+ CHECK_OBJ_NOTNULL(cont->http, HTTP_MAGIC); \
+ return (cont->http->hd[fld].b); \
+ } \
+ ILLEGAL_R(sp, #obj, #hdr); \
+ return(NULL); \
+} \
+
+#define VRT_DO_HDR(obj, hdr, cont, http, fld, nullable) \
+VRT_DO_HDR_l(obj, hdr, cont, http, fld) \
+VRT_DO_HDR_r(obj, hdr, cont, http, fld, nullable) \
+
- VRT_DO_HDR(req, request, sp, http, HTTP_HDR_REQ, 0)
- VRT_DO_HDR(req, url, sp, http, HTTP_HDR_URL, 0)
- VRT_DO_HDR(req, proto, sp, http, HTTP_HDR_PROTO, 0)
++VRT_DO_HDR(req, request, sp->req, http, HTTP_HDR_REQ, 0)
++VRT_DO_HDR(req, url, sp->req, http, HTTP_HDR_URL, 0)
++VRT_DO_HDR(req, proto, sp->req, http, HTTP_HDR_PROTO, 0)
+VRT_DO_HDR(bereq, request, sp->wrk->busyobj, bereq, HTTP_HDR_REQ, 0)
+VRT_DO_HDR(bereq, url, sp->wrk->busyobj, bereq, HTTP_HDR_URL, 0)
+VRT_DO_HDR(bereq, proto, sp->wrk->busyobj, bereq, HTTP_HDR_PROTO, 0)
- VRT_DO_HDR(obj, proto, sp->wrk->obj, http, HTTP_HDR_PROTO, 0)
- VRT_DO_HDR(obj, response, sp->wrk->obj, http, HTTP_HDR_RESPONSE, 0)
- VRT_DO_HDR(resp, proto, sp->wrk, resp, HTTP_HDR_PROTO, 0)
- VRT_DO_HDR(resp, response, sp->wrk, resp, HTTP_HDR_RESPONSE, 0)
++VRT_DO_HDR(obj, proto, sp->req->obj, http, HTTP_HDR_PROTO, 0)
++VRT_DO_HDR(obj, response, sp->req->obj, http, HTTP_HDR_RESPONSE, 0)
++VRT_DO_HDR(resp, proto, sp->req, resp, HTTP_HDR_PROTO, 0)
++VRT_DO_HDR(resp, response, sp->req, resp, HTTP_HDR_RESPONSE, 0)
+VRT_DO_HDR(beresp, proto, sp->wrk->busyobj, beresp, HTTP_HDR_PROTO, 0)
+VRT_DO_HDR(beresp, response, sp->wrk->busyobj, beresp, HTTP_HDR_RESPONSE, 0)
+VRT_DO_HDR_r(stale_obj, proto, sp->stale_obj, http, HTTP_HDR_PROTO, 1)
+VRT_DO_HDR_r(stale_obj, response, sp->stale_obj, http, HTTP_HDR_RESPONSE, 1)
/*--------------------------------------------------------------------*/
@@@ -126,21 -111,12 +126,21 @@@ VRT_r_##obj##_status(const struct sess
{ \
\
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
- return(http->status); \
+ if (nullable && cont == NULL) { \
+ ILLEGAL_R(sp, #obj, "status"); \
+ return (503); \
+ } \
+ return(cont->http->status); \
}
-VRT_DO_STATUS(obj, sp->req->obj->http)
-VRT_DO_STATUS(beresp, sp->wrk->busyobj->beresp)
-VRT_DO_STATUS(resp, sp->req->resp)
+#define VRT_DO_STATUS(obj, cont, http, nullable) \
+VRT_DO_STATUS_l(obj, cont, http) \
+VRT_DO_STATUS_r(obj, cont, http, nullable) \
+
- VRT_DO_STATUS(obj, sp->wrk->obj, http, 0)
++VRT_DO_STATUS(obj, sp->req->obj, http, 0)
+VRT_DO_STATUS(beresp, sp->wrk->busyobj, beresp, 0)
- VRT_DO_STATUS(resp, sp->wrk, resp, 0)
++VRT_DO_STATUS(resp, sp->req, resp, 0)
+VRT_DO_STATUS_r(stale_obj, sp->stale_obj, http, 1)
/*--------------------------------------------------------------------*/
@@@ -433,30 -401,26 +433,30 @@@ vrt_wsp_exp(const struct sess *sp, unsi
sp->t_req, e->age + (sp->t_req - e->entered));
}
- VRT_DO_EXP(req, sp, ttl, 0, 0, )
- VRT_DO_EXP(req, sp, grace, 0, 0, )
- VRT_DO_EXP(req, sp, keep, 0, 0, )
-VRT_DO_EXP(req, sp->req->exp, ttl, 0, )
-VRT_DO_EXP(req, sp->req->exp, grace, 0, )
-VRT_DO_EXP(req, sp->req->exp, keep, 0, )
++VRT_DO_EXP(req, sp->req, ttl, 0, 0, )
++VRT_DO_EXP(req, sp->req, grace, 0, 0, )
++VRT_DO_EXP(req, sp->req, keep, 0, 0, )
- VRT_DO_EXP(obj, sp->wrk->obj, grace, 0, 0,
- EXP_Rearm(sp->wrk->obj);
- vrt_wsp_exp(sp, sp->wrk->obj->xid, &sp->wrk->obj->exp);)
- VRT_DO_EXP(obj, sp->wrk->obj, ttl, (sp->t_req - sp->wrk->obj->exp.entered), 0,
- EXP_Rearm(sp->wrk->obj);
- vrt_wsp_exp(sp, sp->wrk->obj->xid, &sp->wrk->obj->exp);)
- VRT_DO_EXP(obj, sp->wrk->obj, keep, 0, 0,
- EXP_Rearm(sp->wrk->obj);
- vrt_wsp_exp(sp, sp->wrk->obj->xid, &sp->wrk->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, grace, 0,
++VRT_DO_EXP(obj, sp->req->obj, grace, 0, 0,
+ EXP_Rearm(sp->req->obj);
+ vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, ttl, (sp->t_req - sp->req->obj->exp.entered),
++VRT_DO_EXP(obj, sp->req->obj, ttl, (sp->t_req - sp->req->obj->exp.entered), 0,
+ EXP_Rearm(sp->req->obj);
+ vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, keep, 0,
++VRT_DO_EXP(obj, sp->req->obj, keep, 0, 0,
+ EXP_Rearm(sp->req->obj);
+ vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, grace, 0,
+VRT_DO_EXP(beresp, sp->wrk->busyobj, grace, 0, 0,
- vrt_wsp_exp(sp, sp->xid, &sp->wrk->busyobj->exp);)
+ vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, ttl, 0,
+VRT_DO_EXP(beresp, sp->wrk->busyobj, ttl, 0, 0,
- vrt_wsp_exp(sp, sp->xid, &sp->wrk->busyobj->exp);)
+ vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, keep, 0,
+VRT_DO_EXP(beresp, sp->wrk->busyobj, keep, 0, 0,
- vrt_wsp_exp(sp, sp->xid, &sp->wrk->busyobj->exp);)
+ vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
+
+VRT_DO_EXP_r(stale_obj, sp->stale_obj, grace, 0, 1)
+VRT_DO_EXP_r(stale_obj, sp->stale_obj, ttl, 0, 1)
+VRT_DO_EXP_r(stale_obj, sp->stale_obj, keep, 0, 1)
/*--------------------------------------------------------------------
* req.xid
@@@ -569,56 -531,24 +569,56 @@@ VRT_r_obj_hits(const struct sess *sp
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk->obj, OBJECT_MAGIC); /* XXX */
- return (sp->wrk->obj->hits);
+ CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC); /* XXX */
+ return (sp->req->obj->hits);
}
+int
+VRT_r_stale_obj_hits(const struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ if (sp->stale_obj == NULL) {
+ ILLEGAL_R(sp, "stale_obj", "hits");
+ return (0);
+ }
+ CHECK_OBJ(sp->stale_obj, OBJECT_MAGIC); /* XXX */
+ return (sp->stale_obj->hits);
+}
+
double
VRT_r_obj_lastuse(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk->obj, OBJECT_MAGIC); /* XXX */
- return (VTIM_real() - sp->wrk->obj->last_use);
+ CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC); /* XXX */
+ return (VTIM_real() - sp->req->obj->last_use);
}
+double
+VRT_r_stale_obj_lastuse(const struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ if (sp->stale_obj == NULL) {
+ ILLEGAL_R(sp, "stale_obj", "lastuse");
+ return (0);
+ }
+ CHECK_OBJ(sp->stale_obj, OBJECT_MAGIC); /* XXX */
+ return (VTIM_real() - sp->stale_obj->last_use);
+}
+
unsigned
VRT_r_req_backend_healthy(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
- return (VDI_Healthy(sp->director, sp));
+ CHECK_OBJ_NOTNULL(sp->req->director, DIRECTOR_MAGIC);
+ return (VDI_Healthy(sp->req->director, sp));
}
+unsigned
+VRT_r_stale_obj(const struct sess *sp)
+{
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ return (sp->stale_obj != NULL);
+}
diff --cc bin/varnishd/mgt/mgt_param.c
index 71f08eb,c488f23..b1d562d
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@@ -687,15 -767,22 +767,22 @@@ static const struct parspec input_parsp
"around this long, making it available for conditional "
"backend fetches. "
"That means that the object will be removed from the "
- "cache at the end of ttl+grace+keep.",
+ "cache at the end of ttl+max(grace,keep).",
DELAYED_EFFECT,
- "0", "seconds" },
+ "10", "seconds" },
- { "sess_timeout", tweak_timeout, &mgt_param.sess_timeout, 0, 0,
- "Idle timeout for persistent sessions. "
- "If a HTTP request has not been received in this many "
- "seconds, the session is closed.",
+ { "timeout_idle", tweak_timeout_double, &mgt_param.timeout_idle,
+ 0, UINT_MAX,
+ "Idle timeout for client connections.\n"
+ "A connection is considered idle, until we receive"
+ " a non-white-space character on it.",
0,
"5", "seconds" },
+ { "timeout_req", tweak_timeout_double, &mgt_param.timeout_req,
+ 0, UINT_MAX,
+ "Max time to receive clients request header, measured"
+ " from first non-white-space character to double CRNL.",
+ 0,
+ "2", "seconds" },
{ "expiry_sleep", tweak_timeout_double, &mgt_param.expiry_sleep, 0, 60,
"How long the expiry thread sleeps when there is nothing "
"for it to do.\n",
diff --cc include/tbl/vsc_f_main.h
index 5b9abf6,df7984a..910d2d9
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@@ -142,40 -143,8 +143,10 @@@ VSC_F(fetch_failed, uint64_t, 1, 'a',
VSC_F(fetch_1xx, uint64_t, 1, 'a', "Fetch no body (1xx)", "")
VSC_F(fetch_204, uint64_t, 1, 'a', "Fetch no body (204)", "")
VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "")
+VSC_F(fetch_not_validated, uint64_t, 1, 'c', "Non-validating responses",
+ "Count of backend responses to conditional requests with status != 304")
/*---------------------------------------------------------------------
- * Session Memory
- * see: cache_session.c
- */
-
- VSC_F(sessmem_size, uint64_t, 1, 'g',
- "Session mem size",
- "Bytes of memory allocated for last allocated session."
- )
-
- VSC_F(sessmem_alloc, uint64_t, 1, 'c',
- "Session mem allocated",
- "Count of all allocations of session memory."
- )
-
- VSC_F(sessmem_free, uint64_t, 1, 'c',
- "Session mem freed",
- "Count of all frees of session memory."
- )
-
- VSC_F(sessmem_fail, uint64_t, 1, 'c',
- "Session mem alloc failed",
- "Count of session memory allocation failures."
- )
-
- VSC_F(sessmem_limit, uint64_t, 1, 'c',
- "Session mem alloc limited",
- "Count of session memory allocations blocked by limit (max_sess)."
- )
-
- /*---------------------------------------------------------------------
* Pools, threads, and sessions
* see: cache_pool.c
*
diff --cc include/vrt.h
index bbcc412,bbf16ac..d121d2a
--- a/include/vrt.h
+++ b/include/vrt.h
@@@ -156,10 -156,10 +156,10 @@@ void VRT_purge(const struct sess *sp, d
void VRT_count(const struct sess *, unsigned);
int VRT_rewrite(const char *, const char *);
- void VRT_error(struct sess *, unsigned, const char *);
+ void VRT_error(const struct sess *, unsigned, const char *);
int VRT_switch_config(const char *);
-enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
+enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_STALE_OBJ, HDR_BEREQ, HDR_BERESP };
char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *,
const char *, ...);
More information about the varnish-commit
mailing list