Changeset 4100
- Timestamp:
- 06/09/09 12:41:38 (15 months ago)
- Location:
- trunk/varnish-cache
- Files:
-
- 9 modified
-
bin/varnishd/cache_expire.c (modified) (8 diffs)
-
bin/varnishd/default.vcl (modified) (1 diff)
-
include/vcl.h (modified) (2 diffs)
-
include/vcl_returns.h (modified) (1 diff)
-
lib/libvcl/vcc_fixed_token.c (modified) (4 diffs)
-
lib/libvcl/vcc_gen_fixed_token.tcl (modified) (1 diff)
-
lib/libvcl/vcc_gen_obj.tcl (modified) (2 diffs)
-
lib/libvcl/vcc_obj.c (modified) (4 diffs)
-
man/vcl.7so (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/varnish-cache/bin/varnishd/cache_expire.c
r4099 r4100 32 32 * and two ways to kill objects: TTL-timeouts and LRU cleanups. 33 33 * 34 * To avoid holding the mutex while we ponder the fate of objects, we 35 * have the following prototol: 36 * 37 * Any object on the LRU is also on the binheap (normal case) 38 * 39 * An object is taken off only the binheap but left on the LRU during timer 40 * processing because we have no easy way to put it back the right place 41 * in the LRU list. 42 * 43 * An object is taken off both LRU and binheap for LRU processing, (which 44 * implies that it must be on both, from where it follows that the timer 45 * is not chewing on it) because we expect the majority of objects to be 46 * discarded by LRU and save a lock cycle that way, and because we can 47 * properly replace it's position in the binheap. 34 * Any object on the LRU is also on the binheap and vice versa. 35 * 36 * We hold one object reference for both data structures. 37 * 48 38 */ 49 39 … … 113 103 114 104 CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); 105 AN(o->objhead); 115 106 AN(ObjIsBusy(o)); 116 107 assert(o->cacheable); … … 152 143 if (oc == NULL) 153 144 return (retval); 145 AN(o->objhead); 154 146 CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); 155 147 if (Lck_Trylock(&exp_mtx)) … … 242 234 CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); 243 235 CHECK_OBJ_NOTNULL(o->objhead, OBJHEAD_MAGIC); 236 assert(oc->flags & OC_F_ONLRU); 244 237 assert(oc->timer_idx != BINHEAP_NOIDX); 245 238 binheap_delete(exp_heap, oc->timer_idx); 246 239 assert(oc->timer_idx == BINHEAP_NOIDX); 240 VTAILQ_REMOVE(&lru, o->objcore, lru_list); 241 oc->flags &= ~OC_F_ONLRU; 247 242 248 243 { /* Sanity checking */ … … 254 249 } 255 250 256 assert(oc->flags & OC_F_ONLRU);257 Lck_Unlock(&exp_mtx);258 259 WSL(sp->wrk, SLT_ExpPick, 0, "%u TTL", o->xid);260 261 sp->obj = o;262 VCL_timeout_method(sp);263 sp->obj = NULL;264 265 assert(sp->handling == VCL_RET_DISCARD);266 WSL(sp->wrk, SLT_ExpKill, 0,267 "%u %d", o->xid, (int)(o->ttl - t));268 Lck_Lock(&exp_mtx);269 assert(oc->timer_idx == BINHEAP_NOIDX);270 assert(oc->flags & OC_F_ONLRU);271 VTAILQ_REMOVE(&lru, o->objcore, lru_list);272 oc->flags &= ~OC_F_ONLRU;273 251 VSL_stats->n_expired++; 274 252 Lck_Unlock(&exp_mtx); 253 WSL(sp->wrk, SLT_ExpKill, 0, "%u %d", 254 o->xid, (int)(o->ttl - t)); 275 255 HSH_Deref(sp->wrk, &o); 276 256 } … … 278 258 279 259 /*-------------------------------------------------------------------- 280 * Attempt to make space by nuking, with VCLs permission, the oldest281 * object on the LRU listwhich isn't in use.260 * Attempt to make space by nuking, the oldest object on the LRU list 261 * which isn't in use. 282 262 * Returns: 1: did, 0: didn't, -1: can't 283 263 */ … … 292 272 * Find the first currently unused object on the LRU. 293 273 * 294 * Ideally we would have the refcnt in the objcore so we theobject does274 * Ideally we would have the refcnt in the objcore so we object does 295 275 * not need to get paged in for this check, but it does not pay off 296 276 * the complexity: The chances of an object being in front of the LRU, … … 298 278 * object with no active references will be prodded further anyway. 299 279 * 300 * NB: Checking refcount here is no guarantee that it does not gain301 * another ref while we ponder its destiny without the lock held.302 280 */ 303 281 Lck_Lock(&exp_mtx); -
trunk/varnish-cache/bin/varnishd/default.vcl
r4099 r4100 111 111 } 112 112 113 sub vcl_timeout {114 /* XXX: Do not redefine vcl_timeout{}, it is not yet supported */115 return (discard);116 }117 118 113 sub vcl_error { 119 114 set obj.http.Content-Type = "text/html; charset=utf-8"; -
trunk/varnish-cache/include/vcl.h
r4099 r4100 23 23 #define VCL_MET_FETCH (1 << 6) 24 24 #define VCL_MET_DELIVER (1 << 7) 25 #define VCL_MET_TIMEOUT (1 << 8) 26 #define VCL_MET_ERROR (1 << 9) 25 #define VCL_MET_ERROR (1 << 8) 27 26 28 #define VCL_MET_MAX 1027 #define VCL_MET_MAX 9 29 28 30 29 /* VCL Returns */ … … 70 69 vcl_func_f *fetch_func; 71 70 vcl_func_f *deliver_func; 72 vcl_func_f *timeout_func;73 71 vcl_func_f *error_func; 74 72 }; -
trunk/varnish-cache/include/vcl_returns.h
r4099 r4100 61 61 | (1 << VCL_RET_DELIVER) 62 62 )) 63 VCL_MET_MAC(timeout,TIMEOUT,64 ((1 << VCL_RET_FETCH)65 | (1 << VCL_RET_DISCARD)66 ))67 63 VCL_MET_MAC(error,ERROR, 68 64 ((1 << VCL_RET_RESTART) -
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
r4099 r4100 1 1 /* 2 * $Id: vcc_gen_fixed_token.tcl 3948 2009-03-18 11:25:43Z kristian$2 * $Id: vcc_gen_fixed_token.tcl 4099 2009-06-08 21:40:48Z phk $ 3 3 * 4 4 * NB: This file is machine generated, DO NOT EDIT! … … 160 160 /* ../../include/vcl.h */ 161 161 162 vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3948 2009-03-18 11");163 vsb_cat(sb, ": 25:43Z kristian $\n *\n * NB: This file is machine g");164 vsb_cat(sb, " enerated, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fi");165 vsb_cat(sb, " xed_token.tcl instead\n */\n\nstruct sess;\n");162 vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4099 2009-06-08 21"); 163 vsb_cat(sb, ":40:48Z phk $\n *\n * NB: This file is machine genera"); 164 vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); 165 vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n"); 166 166 vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n"); 167 167 vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n"); … … 175 175 vsb_cat(sb, "#define VCL_MET_FETCH\t\t(1 << 6)\n"); 176 176 vsb_cat(sb, "#define VCL_MET_DELIVER\t\t(1 << 7)\n"); 177 vsb_cat(sb, "#define VCL_MET_TIMEOUT\t\t(1 << 8)\n"); 178 vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 9)\n"); 179 vsb_cat(sb, "\n#define VCL_MET_MAX\t\t10\n\n"); 180 vsb_cat(sb, "/* VCL Returns */\n#define VCL_RET_ERROR\t\t0\n"); 181 vsb_cat(sb, "#define VCL_RET_LOOKUP\t\t1\n#define VCL_RET_HASH\t\t2"); 182 vsb_cat(sb, "\n#define VCL_RET_PIPE\t\t3\n#define VCL_RET_PASS\t\t4"); 183 vsb_cat(sb, "\n#define VCL_RET_FETCH\t\t5\n#define VCL_RET_DELIVER\t"); 184 vsb_cat(sb, "\t6\n#define VCL_RET_DISCARD\t\t7\n"); 185 vsb_cat(sb, "#define VCL_RET_KEEP\t\t8\n#define VCL_RET_RESTART\t\t"); 186 vsb_cat(sb, "9\n\n#define VCL_RET_MAX\t\t10\n"); 187 vsb_cat(sb, "\nstruct VCL_conf {\n\tunsigned\tmagic;\n"); 177 vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 8)\n"); 178 vsb_cat(sb, "\n#define VCL_MET_MAX\t\t9\n\n/* VCL Returns */\n"); 179 vsb_cat(sb, "#define VCL_RET_ERROR\t\t0\n#define VCL_RET_LOOKUP\t\t"); 180 vsb_cat(sb, "1\n#define VCL_RET_HASH\t\t2\n#define VCL_RET_PIPE\t\t"); 181 vsb_cat(sb, "3\n#define VCL_RET_PASS\t\t4\n#define VCL_RET_FETCH\t\t"); 182 vsb_cat(sb, "5\n#define VCL_RET_DELIVER\t\t6\n"); 183 vsb_cat(sb, "#define VCL_RET_DISCARD\t\t7\n#define VCL_RET_KEEP\t\t"); 184 vsb_cat(sb, "8\n#define VCL_RET_RESTART\t\t9\n"); 185 vsb_cat(sb, "\n#define VCL_RET_MAX\t\t10\n\n"); 186 vsb_cat(sb, "struct VCL_conf {\n\tunsigned\tmagic;\n"); 188 187 vsb_cat(sb, "#define VCL_CONF_MAGIC\t0x7406c509\t/* from /dev/rando"); 189 188 vsb_cat(sb, "m */\n\n\tstruct director\t**director;\n"); … … 198 197 vsb_cat(sb, "\tvcl_func_f\t*miss_func;\n\tvcl_func_f\t*hit_func;\n"); 199 198 vsb_cat(sb, "\tvcl_func_f\t*fetch_func;\n\tvcl_func_f\t*deliver_fun"); 200 vsb_cat(sb, "c;\n\tvcl_func_f\t* timeout_func;\n");201 vsb_cat(sb, " \tvcl_func_f\t*error_func;\n};\n");199 vsb_cat(sb, "c;\n\tvcl_func_f\t*error_func;\n"); 200 vsb_cat(sb, "};\n"); 202 201 203 202 /* ../../include/vrt.h */ -
trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
r4099 r4100 43 43 {fetch {error restart pass deliver}} 44 44 {deliver {restart deliver}} 45 {timeout {fetch discard}}46 45 {error {restart deliver}} 47 46 } -
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
r4099 r4100 234 234 { obj.ttl 235 235 RW TIME 236 { hit timeouterror}236 { hit error} 237 237 "const struct sess *" 238 238 } 239 239 { obj.grace 240 240 RW TIME 241 { hit timeouterror}241 { hit error} 242 242 "const struct sess *" 243 243 } 244 244 { obj.lastuse 245 245 RO TIME 246 { hit deliver timeouterror}246 { hit deliver error} 247 247 "const struct sess *" 248 248 } … … 281 281 { now 282 282 RO TIME 283 {recv pipe pass hash miss hit fetch deliver timeout}283 {recv pipe pass hash miss hit fetch deliver } 284 284 "const struct sess *" 285 285 } 286 286 { req.backend.healthy RO BOOL 287 {recv pipe pass hash miss hit fetch deliver timeout}287 {recv pipe pass hash miss hit fetch deliver } 288 288 "const struct sess *" 289 289 } -
trunk/varnish-cache/lib/libvcl/vcc_obj.c
r4099 r4100 1 1 /* 2 * $Id: vcc_gen_obj.tcl 40 66 2009-05-10 21:21:36Z sky$2 * $Id: vcc_gen_obj.tcl 4099 2009-06-08 21:40:48Z phk $ 3 3 * 4 4 * NB: This file is machine generated, DO NOT EDIT! … … 216 216 "VRT_r_obj_ttl(sp)", "VRT_l_obj_ttl(sp, ", 217 217 V_RW, 0, 218 VCL_MET_HIT | VCL_MET_ TIMEOUT | VCL_MET_ERROR218 VCL_MET_HIT | VCL_MET_ERROR 219 219 }, 220 220 { "obj.grace", TIME, 9, 221 221 "VRT_r_obj_grace(sp)", "VRT_l_obj_grace(sp, ", 222 222 V_RW, 0, 223 VCL_MET_HIT | VCL_MET_ TIMEOUT | VCL_MET_ERROR223 VCL_MET_HIT | VCL_MET_ERROR 224 224 }, 225 225 { "obj.lastuse", TIME, 11, 226 226 "VRT_r_obj_lastuse(sp)", NULL, 227 227 V_RO, 0, 228 VCL_MET_HIT | VCL_MET_DELIVER | VCL_MET_ TIMEOUT | VCL_MET_ERROR228 VCL_MET_HIT | VCL_MET_DELIVER | VCL_MET_ERROR 229 229 }, 230 230 { "obj.hash", STRING, 8, … … 258 258 VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH 259 259 | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER 260 | VCL_MET_TIMEOUT261 260 }, 262 261 { "req.backend.healthy", BOOL, 19, … … 265 264 VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH 266 265 | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER 267 | VCL_MET_TIMEOUT268 266 }, 269 267 { NULL } -
trunk/varnish-cache/man/vcl.7so
r4025 r4100 445 445 Deliver the object to the client. 446 446 .El 447 .\" vcl_timeout448 .It Cm vcl_timeout449 Called by the reaper thread shortly before a cached document reaches450 its expiry time.451 .Pp452 The453 .Cm vcl_timeout454 subroutine may terminate with one of the following keywords:455 .Bl -tag -width indent456 .It Cm fetch457 Request a fresh copy of the object from the backend.458 .It Cm discard459 Discard the object.460 .El461 .\" vcl_discard462 .It Cm vcl_discard463 Called by the reaper thread when a cached document is about to be464 discarded, either because it has expired or because space is running465 low.466 .Pp467 The468 .Cm vcl_discard469 subroutine may terminate with one of the following keywords:470 .Bl -tag -width indent471 .It Cm discard472 Discard the object.473 .It Cm keep474 Keep the object in cache.475 .El476 447 .El 477 448 .Pp
