Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
1d0298e1
Commit
1d0298e1
authored
May 08, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring more clarity to what and how VMODs can veto
cold&discard for their VCL. Closes: #2471
parent
5df6f8d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
24 deletions
+52
-24
cache_vcl.h
bin/varnishd/cache/cache_vcl.h
+1
-1
cache_vrt_vcl.c
bin/varnishd/cache/cache_vrt_vcl.c
+51
-23
No files found.
bin/varnishd/cache/cache_vcl.h
View file @
1d0298e1
...
...
@@ -62,7 +62,7 @@ struct vclref {
#define VCLREF_MAGIC 0x47fb6848
struct
vcl
*
vcl
;
VTAILQ_ENTRY
(
vclref
)
list
;
char
desc
[
32
]
;
char
*
desc
;
};
extern
struct
lock
vcl_mtx
;
...
...
bin/varnishd/cache/cache_vrt_vcl.c
View file @
1d0298e1
...
...
@@ -142,28 +142,6 @@ VCL_Rel(struct vcl **vcc)
/*--------------------------------------------------------------------*/
void
VRT_VCL_Busy
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
vcl
,
VCL_MAGIC
);
VCL_Ref
(
ctx
->
vcl
);
}
void
VRT_VCL_Unbusy
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
struct
vcl
*
vcl
;
CHECK_OBJ_NOTNULL
(
ctx
->
vcl
,
VCL_MAGIC
);
vcl
=
ctx
->
vcl
;
VCL_Rel
(
&
vcl
);
}
/*--------------------------------------------------------------------*/
VCL_BACKEND
VRT_AddDirector
(
VRT_CTX
,
const
struct
vdi_methods
*
m
,
void
*
priv
,
const
char
*
fmt
,
...)
...
...
@@ -322,6 +300,55 @@ VCL_DefaultProbe(const struct vcl *vcl)
return
(
vcl
->
conf
->
default_probe
);
}
/*--------------------------------------------------------------------*/
struct
vclref
*
VRT_VCL_Prevent_Cold
(
VRT_CTX
,
const
char
*
desc
)
{
struct
vclref
*
ref
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
vcl
,
VCL_MAGIC
);
ALLOC_OBJ
(
ref
,
VCLREF_MAGIC
);
AN
(
ref
);
ref
->
vcl
=
ctx
->
vcl
;
REPLACE
(
ref
->
desc
,
desc
);
VCL_Ref
(
ctx
->
vcl
);
Lck_Lock
(
&
vcl_mtx
);
VTAILQ_INSERT_TAIL
(
&
ctx
->
vcl
->
ref_list
,
ref
,
list
);
Lck_Unlock
(
&
vcl_mtx
);
return
(
ref
);
}
void
VRT_VCL_Allow_Cold
(
struct
vclref
**
refp
)
{
struct
vcl
*
vcl
;
struct
vclref
*
ref
;
AN
(
refp
);
ref
=
*
refp
;
*
refp
=
NULL
;
CHECK_OBJ_NOTNULL
(
ref
,
VCLREF_MAGIC
);
vcl
=
ref
->
vcl
;
CHECK_OBJ_NOTNULL
(
vcl
,
VCL_MAGIC
);
Lck_Lock
(
&
vcl_mtx
);
assert
(
!
VTAILQ_EMPTY
(
&
vcl
->
ref_list
));
VTAILQ_REMOVE
(
&
vcl
->
ref_list
,
ref
,
list
);
Lck_Unlock
(
&
vcl_mtx
);
VCL_Rel
(
&
vcl
);
REPLACE
(
ref
->
desc
,
NULL
);
FREE_OBJ
(
ref
);
}
struct
vclref
*
VRT_VCL_Prevent_Discard
(
VRT_CTX
,
const
char
*
desc
)
{
...
...
@@ -340,7 +367,7 @@ VRT_VCL_Prevent_Discard(VRT_CTX, const char *desc)
ALLOC_OBJ
(
ref
,
VCLREF_MAGIC
);
AN
(
ref
);
ref
->
vcl
=
vcl
;
bprintf
(
ref
->
desc
,
"%s"
,
desc
);
REPLACE
(
ref
->
desc
,
desc
);
Lck_Lock
(
&
vcl_mtx
);
VTAILQ_INSERT_TAIL
(
&
vcl
->
ref_list
,
ref
,
list
);
...
...
@@ -377,6 +404,7 @@ VRT_VCL_Allow_Discard(struct vclref **refp)
/* No garbage collection here, for the same reasons as in VCL_Rel. */
Lck_Unlock
(
&
vcl_mtx
);
REPLACE
(
ref
->
desc
,
NULL
);
FREE_OBJ
(
ref
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment