/src/varnish-cache/bin/varnishd/cache/cache_varnishd.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*- |
2 | | * Copyright (c) 2006 Verdens Gang AS |
3 | | * Copyright (c) 2006-2015 Varnish Software AS |
4 | | * All rights reserved. |
5 | | * |
6 | | * Author: Poul-Henning Kamp <phk@phk.freebsd.dk> |
7 | | * |
8 | | * SPDX-License-Identifier: BSD-2-Clause |
9 | | * |
10 | | * Redistribution and use in source and binary forms, with or without |
11 | | * modification, are permitted provided that the following conditions |
12 | | * are met: |
13 | | * 1. Redistributions of source code must retain the above copyright |
14 | | * notice, this list of conditions and the following disclaimer. |
15 | | * 2. Redistributions in binary form must reproduce the above copyright |
16 | | * notice, this list of conditions and the following disclaimer in the |
17 | | * documentation and/or other materials provided with the distribution. |
18 | | * |
19 | | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
20 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
23 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | | * SUCH DAMAGE. |
30 | | * |
31 | | * Stuff that should *never* be exposed to a VMOD |
32 | | */ |
33 | | |
34 | | #include "cache.h" |
35 | | |
36 | | #include "vsb.h" |
37 | | |
38 | | #include <sys/socket.h> |
39 | | |
40 | | #include <string.h> |
41 | | #include <limits.h> |
42 | | #include <unistd.h> |
43 | | |
44 | | #include "common/common_param.h" |
45 | | |
46 | | #ifdef NOT_IN_A_VMOD |
47 | | # include "VSC_main.h" |
48 | | #endif |
49 | | |
50 | | /*--------------------------------------------------------------------*/ |
51 | | |
52 | | struct vfp; |
53 | | struct vdp; |
54 | | struct cli_proto; |
55 | | struct poolparam; |
56 | | |
57 | | /*--------------------------------------------------------------------*/ |
58 | | |
59 | | typedef enum req_fsm_nxt req_state_f(struct worker *, struct req *); |
60 | | struct req_step { |
61 | | const char *name; |
62 | | req_state_f *func; |
63 | | }; |
64 | | |
65 | | extern const struct req_step R_STP_TRANSPORT[1]; |
66 | | extern const struct req_step R_STP_RECV[1]; |
67 | | |
68 | | struct vxid_pool { |
69 | | uint64_t next; |
70 | | uint32_t count; |
71 | | }; |
72 | | |
73 | | /*-------------------------------------------------------------------- |
74 | | * Private part of worker threads |
75 | | */ |
76 | | |
77 | | struct worker_priv { |
78 | | unsigned magic; |
79 | | #define WORKER_PRIV_MAGIC 0x3047db99 |
80 | | struct objhead *nobjhead; |
81 | | struct objcore *nobjcore; |
82 | | void *nhashpriv; |
83 | | struct vxid_pool vxid_pool[1]; |
84 | | struct vcl *vcl; |
85 | | }; |
86 | | |
87 | | /*-------------------------------------------------------------------- |
88 | | * HTTP Protocol connection structure |
89 | | * |
90 | | * This is the protocol independent object for a HTTP connection, used |
91 | | * both for backend and client sides. |
92 | | * |
93 | | */ |
94 | | |
95 | | struct http_conn { |
96 | | unsigned magic; |
97 | | #define HTTP_CONN_MAGIC 0x3e19edd1 |
98 | | |
99 | | int *rfd; |
100 | | stream_close_t doclose; |
101 | | body_status_t body_status; |
102 | | struct ws *ws; |
103 | | char *rxbuf_b; |
104 | | char *rxbuf_e; |
105 | | char *pipeline_b; |
106 | | char *pipeline_e; |
107 | | ssize_t content_length; |
108 | | void *priv; |
109 | | |
110 | | /* Timeouts */ |
111 | | vtim_dur first_byte_timeout; |
112 | | vtim_dur between_bytes_timeout; |
113 | | }; |
114 | | |
115 | | enum htc_status_e { |
116 | | #define HTC_STATUS(e, n, s, l) HTC_S_ ## e = n, |
117 | | #include "tbl/htc.h" |
118 | | }; |
119 | | |
120 | | typedef enum htc_status_e htc_complete_f(struct http_conn *); |
121 | | |
122 | | /* -------------------------------------------------------------------*/ |
123 | | |
124 | | extern volatile struct params * cache_param; |
125 | | |
126 | | /* ------------------------------------------------------------------- |
127 | | * The VCF facility is deliberately undocumented, use at your peril. |
128 | | */ |
129 | | |
130 | | struct vcf_return { |
131 | | const char *name; |
132 | | }; |
133 | | |
134 | | #define VCF_RETURNS() \ |
135 | | VCF_RETURN(CONTINUE) \ |
136 | | VCF_RETURN(DEFAULT) \ |
137 | | VCF_RETURN(MISS) \ |
138 | | VCF_RETURN(HIT) |
139 | | |
140 | | #define VCF_RETURN(x) extern const struct vcf_return VCF_##x[1]; |
141 | | VCF_RETURNS() |
142 | | #undef VCF_RETURN |
143 | | |
144 | | typedef const struct vcf_return *vcf_func_f( |
145 | | struct req *req, |
146 | | struct objcore **oc, |
147 | | struct objcore **oc_exp, |
148 | | int state); |
149 | | |
150 | | struct vcf { |
151 | | unsigned magic; |
152 | | #define VCF_MAGIC 0x183285d1 |
153 | | vcf_func_f *func; |
154 | | void *priv; |
155 | | }; |
156 | | |
157 | | /* Prototypes etc ----------------------------------------------------*/ |
158 | | |
159 | | /* cache_backend.c */ |
160 | | struct backend; |
161 | | |
162 | | /* cache_backend_cfg.c */ |
163 | | void VBE_InitCfg(void); |
164 | | |
165 | | /* cache_ban.c */ |
166 | | |
167 | | /* for stevedoes resurrecting bans */ |
168 | | void BAN_Hold(void); |
169 | | void BAN_Release(void); |
170 | | void BAN_Reload(const uint8_t *ban, unsigned len); |
171 | | struct ban *BAN_FindBan(vtim_real t0); |
172 | | void BAN_RefBan(struct objcore *oc, struct ban *); |
173 | | vtim_real BAN_Time(const struct ban *ban); |
174 | | |
175 | | /* cache_busyobj.c */ |
176 | | struct busyobj *VBO_GetBusyObj(const struct worker *, const struct req *); |
177 | | void VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **busyobj); |
178 | | |
179 | | /* cache_director.c */ |
180 | | int VDI_GetHdr(struct busyobj *); |
181 | | VCL_IP VDI_GetIP(struct busyobj *); |
182 | | void VDI_Finish(struct busyobj *bo); |
183 | | stream_close_t VDI_Http1Pipe(struct req *, struct busyobj *); |
184 | | void VDI_Panic(const struct director *, struct vsb *, const char *nm); |
185 | | void VDI_Event(const struct director *d, enum vcl_event_e ev); |
186 | | void VDI_Init(void); |
187 | | |
188 | | /* cache_deliver_proc.c */ |
189 | | void VDP_Fini(const struct vdp_ctx *vdc); |
190 | | void VDP_Init(struct vdp_ctx *vdc, struct worker *wrk, struct vsl_log *vsl, |
191 | | const struct req *req, const struct busyobj *bo, intmax_t *cl); |
192 | | uint64_t VDP_Close(struct vdp_ctx *, struct objcore *, struct boc *); |
193 | | void VDP_Panic(struct vsb *vsb, const struct vdp_ctx *vdc); |
194 | | int VDP_Push(VRT_CTX, struct vdp_ctx *, struct ws *, const struct vdp *, |
195 | | void *priv); |
196 | | int VDP_ObjIterate(void *priv, unsigned flush, const void *ptr, ssize_t len); |
197 | | int VDP_DeliverObj(struct vdp_ctx *vdc, struct objcore *oc); |
198 | | extern const struct vdp VDP_gunzip; |
199 | | extern const struct vdp VDP_esi; |
200 | | extern const struct vdp VDP_range; |
201 | | |
202 | | uint64_t VDPIO_Close(struct vdp_ctx *, struct objcore *, struct boc *); |
203 | | int VDPIO_Upgrade(VRT_CTX, struct vdp_ctx *vdc); |
204 | | int VDPIO_Push(VRT_CTX, struct vdp_ctx *, struct ws *, const struct vdp *, |
205 | | void *priv); |
206 | | |
207 | | |
208 | | /* cache_exp.c */ |
209 | | vtim_real EXP_Ttl(const struct req *, const struct objcore *); |
210 | | vtim_real EXP_Ttl_grace(const struct req *, const struct objcore *oc); |
211 | | void EXP_RefNewObjcore(struct objcore *); |
212 | | void EXP_Insert(struct worker *wrk, struct objcore *oc); |
213 | | void EXP_Remove(struct objcore *, const struct objcore *); |
214 | | |
215 | | #define EXP_Dttl(req, oc) (oc->ttl - (req->t_req - oc->t_origin)) |
216 | | |
217 | | /* cache_expire.c */ |
218 | | |
219 | | /* |
220 | | * The set of variables which control object expiry are inconveniently |
221 | | * 24 bytes long (double+3*float) and this causes alignment waste if |
222 | | * we put then in a struct. |
223 | | * These three macros operate on the struct we don't use. |
224 | | */ |
225 | | |
226 | | #define EXP_ZERO(xx) \ |
227 | | do { \ |
228 | | (xx)->t_origin = 0.0; \ |
229 | | (xx)->ttl = 0.0; \ |
230 | | (xx)->grace = 0.0; \ |
231 | | (xx)->keep = 0.0; \ |
232 | | } while (0) |
233 | | |
234 | | #define EXP_COPY(to,fm) \ |
235 | | do { \ |
236 | | (to)->t_origin = (fm)->t_origin; \ |
237 | | (to)->ttl = (fm)->ttl; \ |
238 | | (to)->grace = (fm)->grace; \ |
239 | | (to)->keep = (fm)->keep; \ |
240 | | } while (0) |
241 | | |
242 | | #define EXP_WHEN(to) \ |
243 | | ((to)->t_origin + (to)->ttl + (to)->grace + (to)->keep) |
244 | | |
245 | | /* cache_exp.c */ |
246 | | void EXP_Rearm(struct objcore *oc, vtim_real now, |
247 | | vtim_dur ttl, vtim_dur grace, vtim_dur keep); |
248 | | void EXP_Reduce(struct objcore *oc, vtim_real now, |
249 | | vtim_dur ttl, vtim_dur grace, vtim_dur keep); |
250 | | |
251 | | /* From cache_main.c */ |
252 | | void BAN_Init(void); |
253 | | void BAN_Compile(void); |
254 | | void BAN_Shutdown(void); |
255 | | |
256 | | /* From cache_hash.c */ |
257 | | void BAN_NewObjCore(struct objcore *oc); |
258 | | void BAN_DestroyObj(struct objcore *oc); |
259 | | int BAN_CheckObject(struct worker *, struct objcore *, struct req *); |
260 | | |
261 | | /* cache_busyobj.c */ |
262 | | void VBO_Init(void); |
263 | | |
264 | | /* cache_cli.c [CLI] */ |
265 | | void CLI_Init(void); |
266 | | void CLI_Run(void); |
267 | | void CLI_AddFuncs(struct cli_proto *p); |
268 | | |
269 | | /* cache_expire.c */ |
270 | | void EXP_Init(void); |
271 | | void EXP_Shutdown(void); |
272 | | |
273 | | /* cache_fetch.c */ |
274 | | enum vbf_fetch_mode_e { |
275 | | VBF_NORMAL = 0, |
276 | | VBF_PASS = 1, |
277 | | VBF_BACKGROUND = 2, |
278 | | }; |
279 | | void VBF_Fetch(struct worker *wrk, struct req *req, |
280 | | struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e); |
281 | | const char *VBF_Get_Filter_List(struct busyobj *); |
282 | | void Bereq_Rollback(VRT_CTX); |
283 | | |
284 | | /* cache_fetch_proc.c */ |
285 | | void VFP_Init(void); |
286 | | struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); |
287 | | enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); |
288 | | void VFP_Extend(const struct vfp_ctx *, ssize_t sz, enum vfp_status); |
289 | | void VFP_Setup(struct vfp_ctx *vc, struct worker *wrk); |
290 | | int VFP_Open(VRT_CTX, struct vfp_ctx *); |
291 | | uint64_t VFP_Close(struct vfp_ctx *); |
292 | | |
293 | | extern const struct vfp VFP_gunzip; |
294 | | extern const struct vfp VFP_gzip; |
295 | | extern const struct vfp VFP_testgunzip; |
296 | | extern const struct vfp VFP_esi; |
297 | | extern const struct vfp VFP_esi_gzip; |
298 | | |
299 | | /* cache_http.c */ |
300 | | void HTTP_Init(void); |
301 | | |
302 | | /* cache_http1_proto.c */ |
303 | | |
304 | | htc_complete_f HTTP1_Complete; |
305 | | uint16_t HTTP1_DissectRequest(struct http_conn *, struct http *); |
306 | | uint16_t HTTP1_DissectResponse(struct http_conn *, struct http *resp, |
307 | | const struct http *req); |
308 | | struct v1l; |
309 | | unsigned HTTP1_Write(struct v1l *v1l, const struct http *hp, const int*); |
310 | | |
311 | | /* cache_main.c */ |
312 | | vxid_t VXID_Get(const struct worker *, uint64_t marker); |
313 | | extern pthread_key_t panic_key; |
314 | | extern pthread_key_t witness_key; |
315 | | |
316 | | void THR_SetName(const char *name); |
317 | | const char* THR_GetName(void); |
318 | | void THR_SetBusyobj(const struct busyobj *); |
319 | | struct busyobj * THR_GetBusyobj(void); |
320 | | void THR_SetRequest(const struct req *); |
321 | | struct req * THR_GetRequest(void); |
322 | | void THR_SetWorker(const struct worker *); |
323 | | struct worker * THR_GetWorker(void); |
324 | | void THR_Init(void); |
325 | | |
326 | | /* cache_lck.c */ |
327 | | void LCK_Init(void); |
328 | | |
329 | | /* cache_mempool.c */ |
330 | | void MPL_AssertSane(const void *item); |
331 | | struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, |
332 | | volatile unsigned *cur_size); |
333 | | void MPL_Destroy(struct mempool **mpp); |
334 | | void *MPL_Get(struct mempool *mpl, unsigned *size); |
335 | | void MPL_Free(struct mempool *mpl, void *item); |
336 | | |
337 | | /* cache_obj.c */ |
338 | | void ObjInit(void); |
339 | | struct objcore * ObjNew(const struct worker *); |
340 | | void ObjDestroy(const struct worker *, struct objcore **); |
341 | | int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr); |
342 | | void ObjExtend(struct worker *, struct objcore *, ssize_t l, int final); |
343 | | uint64_t ObjWaitExtend(const struct worker *, const struct objcore *, |
344 | | uint64_t l, enum boc_state_e *statep); |
345 | | void ObjSetState(struct worker *, const struct objcore *, |
346 | | enum boc_state_e next); |
347 | | void ObjWaitState(const struct objcore *, enum boc_state_e want); |
348 | | void ObjTouch(struct worker *, struct objcore *, vtim_real now); |
349 | | void ObjFreeObj(struct worker *, struct objcore *); |
350 | | void ObjSlim(struct worker *, struct objcore *); |
351 | | void *ObjSetAttr(struct worker *, struct objcore *, enum obj_attr, |
352 | | ssize_t len, const void *); |
353 | | int ObjCopyAttr(struct worker *, struct objcore *, struct objcore *, |
354 | | enum obj_attr attr); |
355 | | void ObjBocDone(struct worker *, struct objcore *, struct boc **); |
356 | | // VAI |
357 | | uint64_t ObjVAIGetExtend(struct worker *, const struct objcore *, uint64_t, |
358 | | enum boc_state_e *, struct vai_qe *); |
359 | | void ObjVAICancel(struct worker *, struct boc *, struct vai_qe *); |
360 | | |
361 | | int ObjSetDouble(struct worker *, struct objcore *, enum obj_attr, double); |
362 | | int ObjSetU64(struct worker *, struct objcore *, enum obj_attr, uint64_t); |
363 | | int ObjSetXID(struct worker *, struct objcore *, vxid_t); |
364 | | |
365 | | void ObjSetFlag(struct worker *, struct objcore *, enum obj_flags of, int val); |
366 | | |
367 | | void ObjSendEvent(struct worker *, struct objcore *oc, unsigned event); |
368 | | |
369 | | #define OEV_INSERT (1U<<1) |
370 | | #define OEV_BANCHG (1U<<2) |
371 | | #define OEV_TTLCHG (1U<<3) |
372 | | #define OEV_EXPIRE (1U<<4) |
373 | | |
374 | | #define OEV_MASK (OEV_INSERT|OEV_BANCHG|OEV_TTLCHG|OEV_EXPIRE) |
375 | | |
376 | | typedef void obj_event_f(struct worker *, void *priv, struct objcore *, |
377 | | unsigned); |
378 | | |
379 | | uintptr_t ObjSubscribeEvents(obj_event_f *, void *, unsigned mask); |
380 | | void ObjUnsubscribeEvents(uintptr_t *); |
381 | | |
382 | | /* cache_panic.c */ |
383 | | void PAN_Init(void); |
384 | | int PAN__DumpStruct(struct vsb *vsb, int block, int track, const void *ptr, |
385 | | const char *smagic, unsigned magic, const char *fmt, ...) |
386 | | v_printflike_(7,8); |
387 | | |
388 | | #define PAN_CheckMagic(vsb, ptr, exp) \ |
389 | | do { \ |
390 | | if ((ptr)->magic != (exp)) \ |
391 | | VSB_printf((vsb), \ |
392 | | "MAGIC at %p is 0x%08x (Should be: %s/0x%08x)\n", \ |
393 | | ptr, (ptr)->magic, #exp, exp); \ |
394 | | } while(0) |
395 | | |
396 | | #define PAN_dump_struct(vsb, ptr, magic, ...) \ |
397 | 0 | PAN__DumpStruct(vsb, 1, 1, ptr, #magic, magic, __VA_ARGS__) |
398 | | |
399 | | #define PAN_dump_oneline(vsb, ptr, magic, ...) \ |
400 | | PAN__DumpStruct(vsb, 0, 1, ptr, #magic, magic, __VA_ARGS__) |
401 | | |
402 | | #define PAN_dump_once(vsb, ptr, magic, ...) \ |
403 | 0 | PAN__DumpStruct(vsb, 1, 0, ptr, #magic, magic, __VA_ARGS__) |
404 | | |
405 | | #define PAN_dump_once_oneline(vsb, ptr, magic, ...) \ |
406 | 0 | PAN__DumpStruct(vsb, 0, 0, ptr, #magic, magic, __VA_ARGS__) |
407 | | |
408 | | /* cache_pool.c */ |
409 | | void Pool_Init(void); |
410 | | int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio); |
411 | | int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *, |
412 | | const void *arg, size_t arg_len); |
413 | | void Pool_Sumstat(const struct worker *w); |
414 | | int Pool_TrySumstat(const struct worker *wrk); |
415 | | void Pool_PurgeStat(unsigned nobj); |
416 | | int Pool_Task_Any(struct pool_task *task, enum task_prio prio); |
417 | | void pan_pool(struct vsb *); |
418 | | |
419 | | /* cache_range.c */ |
420 | | int VRG_CheckBo(struct busyobj *); |
421 | | |
422 | | /* cache_req.c */ |
423 | | struct req *Req_New(struct sess *, const struct req *); |
424 | | void Req_Release(struct req *); |
425 | | void Req_Rollback(VRT_CTX); |
426 | | void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); |
427 | | void Req_Fail(struct req *req, stream_close_t reason); |
428 | | void Req_AcctLogCharge(struct VSC_main_wrk *, struct req *); |
429 | | void Req_LogHit(struct worker *, struct req *, struct objcore *, intmax_t); |
430 | | const char *Req_LogStart(const struct worker *, struct req *); |
431 | | |
432 | | /* cache_req_body.c */ |
433 | | int VRB_Ignore(struct req *); |
434 | | ssize_t VRB_Cache(struct req *, ssize_t maxsize); |
435 | | void VRB_Free(struct req *); |
436 | | |
437 | | /* cache_req_fsm.c [CNT] */ |
438 | | |
439 | | int Resp_Setup_Deliver(struct req *); |
440 | | void Resp_Setup_Synth(struct req *); |
441 | | |
442 | | enum req_fsm_nxt { |
443 | | REQ_FSM_MORE, |
444 | | REQ_FSM_DONE, |
445 | | REQ_FSM_DISEMBARK, |
446 | | }; |
447 | | |
448 | | void CNT_Embark(struct worker *, struct req *); |
449 | | enum req_fsm_nxt CNT_Request(struct req *); |
450 | | |
451 | | /* cache_session.c */ |
452 | | void SES_NewPool(struct pool *, unsigned pool_no); |
453 | | void SES_DestroyPool(struct pool *); |
454 | | void SES_Wait(struct sess *, const struct transport *); |
455 | | void SES_Ref(struct sess *sp); |
456 | | void SES_Rel(struct sess *sp); |
457 | | |
458 | | void HTC_Status(enum htc_status_e, const char **, const char **); |
459 | | void HTC_RxInit(struct http_conn *htc, struct ws *ws); |
460 | | void HTC_RxPipeline(struct http_conn *htc, char *); |
461 | | enum htc_status_e HTC_RxStuff(struct http_conn *, htc_complete_f *, |
462 | | vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, vtim_dur td, |
463 | | int maxbytes); |
464 | | |
465 | | #define SESS_ATTR(UP, low, typ, len) \ |
466 | | int SES_Set_##low(const struct sess *sp, const typ *src); \ |
467 | | int SES_Reserve_##low(struct sess *sp, typ **dst, ssize_t *sz); |
468 | | #include "tbl/sess_attr.h" |
469 | | int SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src); |
470 | | |
471 | | /* cache_shmlog.c */ |
472 | | extern struct VSC_main *VSC_C_main; |
473 | | void VSM_Init(void); |
474 | | void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); |
475 | | void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, |
476 | | vxid_t vxid); |
477 | | void VSL_End(struct vsl_log *vsl); |
478 | | void VSL_Flush(struct vsl_log *, int overflow); |
479 | | |
480 | | /* cache_conn_pool.c */ |
481 | | struct conn_pool; |
482 | | void VCP_Init(void); |
483 | | void VCP_Panic(struct vsb *, struct conn_pool *); |
484 | | void VCP_RelPoll(void); |
485 | | |
486 | | /* cache_backend_probe.c */ |
487 | | void VBP_Init(void); |
488 | | |
489 | | /* cache_vary.c */ |
490 | | int VRY_Create(struct busyobj *bo, struct vsb **psb); |
491 | | int VRY_Match(const struct req *, const uint8_t *vary); |
492 | | void VRY_Prep(struct req *); |
493 | | void VRY_Clear(struct req *); |
494 | | enum vry_finish_flag { KEEP, DISCARD }; |
495 | | void VRY_Finish(struct req *req, enum vry_finish_flag); |
496 | | |
497 | | /* cache_vcl.c */ |
498 | | void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *); |
499 | | void VCL_Req2Ctx(struct vrt_ctx *, struct req *); |
500 | | struct vrt_ctx *VCL_Get_CliCtx(int); |
501 | | struct vsb *VCL_Rel_CliCtx(struct vrt_ctx **); |
502 | | void VCL_Panic(struct vsb *, const char *nm, const struct vcl *); |
503 | | void VCL_Poll(void); |
504 | | void VCL_Init(void); |
505 | | |
506 | | #define VCL_MET_MAC(l,u,t,b) \ |
507 | | void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \ |
508 | | struct busyobj *bo, void *specific); |
509 | | #include "tbl/vcl_returns.h" |
510 | | |
511 | | |
512 | | typedef int vcl_be_func(struct cli *, struct director *, void *); |
513 | | |
514 | | int VCL_IterDirector(struct cli *, const char *, vcl_be_func *, void *); |
515 | | |
516 | | /* cache_vrt.c */ |
517 | | void pan_privs(struct vsb *, const struct vrt_privs *); |
518 | | |
519 | | /* cache_vrt_filter.c */ |
520 | | int VCL_StackVFP(struct vfp_ctx *, const struct vcl *, const char *); |
521 | | int VCL_StackVDP(struct vdp_ctx *vdc, const struct vcl *vcl, const char *fl, |
522 | | struct req *req, struct busyobj *bo); |
523 | | const char *resp_Get_Filter_List(struct req *req); |
524 | | void VCL_VRT_Init(void); |
525 | | |
526 | | /* cache_vrt_vcl.c */ |
527 | | const char *VCL_Return_Name(unsigned); |
528 | | const char *VCL_Method_Name(unsigned); |
529 | | void VCL_Refresh(struct vcl **); |
530 | | void VCL_Recache(const struct worker *, struct vcl **); |
531 | | void VCL_Ref(struct vcl *); |
532 | | void VCL_Rel(struct vcl **); |
533 | | VCL_BACKEND VCL_DefaultDirector(const struct vcl *); |
534 | | const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *); |
535 | | |
536 | | /* cache_vrt_priv.c */ |
537 | | extern struct vrt_privs cli_task_privs[1]; |
538 | | void VCL_TaskEnter(struct vrt_privs *); |
539 | | void VCL_TaskLeave(VRT_CTX, struct vrt_privs *); |
540 | | |
541 | | /* cache_vrt_vmod.c */ |
542 | | void VMOD_Init(void); |
543 | | void VMOD_Panic(struct vsb *); |
544 | | |
545 | | #if defined(ENABLE_COVERAGE) || defined(ENABLE_SANITIZER) |
546 | | # define DONT_DLCLOSE_VMODS |
547 | | #endif |
548 | | |
549 | | /* cache_wrk.c */ |
550 | | void WRK_Init(void); |
551 | | void WRK_AddStat(const struct worker *); |
552 | | void WRK_Log(enum VSL_tag_e, const char *, ...); |
553 | | |
554 | | /* cache_vpi.c */ |
555 | | extern const size_t vpi_wrk_len; |
556 | | void VPI_wrk_init(struct worker *, void *, size_t); |
557 | | void VPI_Panic(struct vsb *, const struct wrk_vpi *, const struct vcl *); |
558 | | |
559 | | /* cache_ws.c */ |
560 | | void WS_Panic(struct vsb *, const struct ws *); |
561 | | static inline int |
562 | | WS_IsReserved(const struct ws *ws) |
563 | 0 | { |
564 | 0 |
|
565 | 0 | return (ws->r != NULL); |
566 | 0 | } Unexecuted instantiation: cache_ws_emu.c:WS_IsReserved Unexecuted instantiation: cache_ws_common.c:WS_IsReserved Unexecuted instantiation: cache_esi_parse.c:WS_IsReserved Unexecuted instantiation: esi_parse_fuzzer.c:WS_IsReserved |
567 | | |
568 | | void *WS_AtOffset(const struct ws *ws, unsigned off, unsigned len); |
569 | | unsigned WS_ReservationOffset(const struct ws *ws); |
570 | | int WS_Pipeline(struct ws *, const void *b, const void *e, unsigned rollback); |
571 | | |
572 | | /* cache_ws_common.c */ |
573 | | void WS_Id(const struct ws *ws, char *id); |
574 | | void WS_Rollback(struct ws *, uintptr_t); |
575 | | |
576 | | /* http1/cache_http1_pipe.c */ |
577 | | void V1P_Init(void); |
578 | | |
579 | | /* cache_http2_deliver.c */ |
580 | | void V2D_Init(void); |
581 | | |
582 | | /* stevedore.c */ |
583 | | void STV_open(void); |
584 | | void STV_close(void); |
585 | | const struct stevedore *STV_next(void); |
586 | | int STV_BanInfoDrop(const uint8_t *ban, unsigned len); |
587 | | int STV_BanInfoNew(const uint8_t *ban, unsigned len); |
588 | | void STV_BanExport(const uint8_t *banlist, unsigned len); |
589 | | // STV_NewObject() len is space for OBJ_VARATTR |
590 | | int STV_NewObject(struct worker *, struct objcore *, |
591 | | const struct stevedore *, unsigned len); |
592 | | |
593 | | struct stv_buffer; |
594 | | struct stv_buffer *STV_AllocBuf(struct worker *wrk, const struct stevedore *stv, |
595 | | size_t size); |
596 | | void STV_FreeBuf(struct worker *wrk, struct stv_buffer **pstvbuf); |
597 | | void *STV_GetBufPtr(struct stv_buffer *stvbuf, size_t *psize); |
598 | | |
599 | | #ifdef WITH_PERSISTENT_STORAGE |
600 | | /* storage_persistent.c */ |
601 | | void SMP_Ready(void); |
602 | | #endif |
603 | | |
604 | 86.3k | #define FEATURE(x) COM_FEATURE(cache_param->feature_bits, x) |
605 | | #define EXPERIMENT(x) COM_EXPERIMENT(cache_param->experimental_bits, x) |
606 | 6.88k | #define DO_DEBUG(x) COM_DO_DEBUG(cache_param->debug_bits, x) |
607 | | |
608 | | #define DSL(debug_bit, id, ...) \ |
609 | | do { \ |
610 | | if (DO_DEBUG(debug_bit)) \ |
611 | | VSL(SLT_Debug, (id), __VA_ARGS__); \ |
612 | | } while (0) |
613 | | |
614 | | #define DSLb(debug_bit, ...) \ |
615 | 6.88k | do { \ |
616 | 6.88k | if (DO_DEBUG(debug_bit)) \ |
617 | 6.88k | WRK_Log(SLT_Debug, __VA_ARGS__); \ |
618 | 6.88k | } while (0) |