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
ff374453
Commit
ff374453
authored
Aug 16, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement new VRT functions for VCL switching
parent
c3909ca6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
27 deletions
+66
-27
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+56
-27
vrt.h
include/vrt.h
+5
-0
vcc_types.c
lib/libvcc/vcc_types.c
+5
-0
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
ff374453
...
...
@@ -89,6 +89,23 @@ static struct vcl *vcl_active; /* protected by vcl_mtx */
/*--------------------------------------------------------------------*/
static
struct
vcl
*
vcl_find
(
const
char
*
name
)
{
struct
vcl
*
vcl
;
ASSERT_CLI
();
VTAILQ_FOREACH
(
vcl
,
&
vcl_head
,
list
)
{
if
(
vcl
->
discard
)
continue
;
if
(
!
strcmp
(
vcl
->
loaded_name
,
name
))
return
(
vcl
);
}
return
(
NULL
);
}
/*--------------------------------------------------------------------*/
void
VCL_Panic
(
struct
vsb
*
vsb
,
const
struct
vcl
*
vcl
)
{
...
...
@@ -155,27 +172,34 @@ VCL_Method_Name(unsigned m)
/*--------------------------------------------------------------------*/
static
void
VCL_Get
(
struct
vcl
**
vcc
)
vcl_get
(
struct
vcl
**
vcc
,
struct
vcl
*
vcl
)
{
while
(
vcl_active
==
NULL
)
(
void
)
usleep
(
100000
);
CHECK_OBJ_NOTNULL
(
vcl
_active
,
VCL_MAGIC
);
assert
(
vcl
_active
->
temp
==
VCL_TEMP_WARM
);
CHECK_OBJ_NOTNULL
(
vcl
,
VCL_MAGIC
);
assert
(
vcl
->
temp
==
VCL_TEMP_WARM
);
Lck_Lock
(
&
vcl_mtx
);
AN
(
vcl
_active
);
if
(
vcl
_active
->
label
==
NULL
)
*
vcc
=
vcl
_active
;
else
if
(
strcmp
(
vcl
_active
->
state
,
VCL_TEMP_LABEL
))
*
vcc
=
vcl
_active
;
AN
(
vcl
);
if
(
vcl
->
label
==
NULL
)
*
vcc
=
vcl
;
else
if
(
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
))
*
vcc
=
vcl
;
else
*
vcc
=
vcl
_active
->
label
;
*
vcc
=
vcl
->
label
;
AN
(
*
vcc
);
AZ
((
*
vcc
)
->
discard
);
(
*
vcc
)
->
busy
++
;
Lck_Unlock
(
&
vcl_mtx
);
}
static
void
vcl_get_active
(
struct
vcl
**
vcc
)
{
while
(
vcl_active
==
NULL
)
(
void
)
usleep
(
100000
);
vcl_get
(
vcc
,
vcl_active
);
}
void
VCL_Refresh
(
struct
vcl
**
vcc
)
{
...
...
@@ -185,7 +209,7 @@ VCL_Refresh(struct vcl **vcc)
return
;
if
(
*
vcc
!=
NULL
)
VCL_Rel
(
vcc
);
/* XXX: optimize locking */
VCL_Get
(
vcc
);
vcl_get_active
(
vcc
);
}
void
...
...
@@ -411,6 +435,26 @@ VRT_count(VRT_CTX, unsigned u)
ctx
->
vcl
->
conf
->
ref
[
u
].
line
,
ctx
->
vcl
->
conf
->
ref
[
u
].
pos
);
}
VCL_VCL
VRT_vcl_lookup
(
const
char
*
name
)
{
VCL_VCL
vcl
;
vcl
=
vcl_find
(
name
);
AN
(
vcl
);
return
(
vcl
);
}
void
VRT_vcl_select
(
VRT_CTX
,
VCL_VCL
vcl
)
{
struct
req
*
req
=
ctx
->
req
;
CHECK_OBJ_NOTNULL
(
vcl
,
VCL_MAGIC
);
VCL_Rel
(
&
req
->
vcl
);
vcl_get
(
&
req
->
vcl
,
vcl
);
}
struct
vclref
*
VRT_ref_vcl
(
VRT_CTX
,
const
char
*
desc
)
{
...
...
@@ -468,21 +512,6 @@ VRT_rel_vcl(VRT_CTX, struct vclref **refp)
/*--------------------------------------------------------------------*/
static
struct
vcl
*
vcl_find
(
const
char
*
name
)
{
struct
vcl
*
vcl
;
ASSERT_CLI
();
VTAILQ_FOREACH
(
vcl
,
&
vcl_head
,
list
)
{
if
(
vcl
->
discard
)
continue
;
if
(
!
strcmp
(
vcl
->
loaded_name
,
name
))
return
(
vcl
);
}
return
(
NULL
);
}
static
int
vcl_setup_event
(
VRT_CTX
,
enum
vcl_event_e
ev
)
{
...
...
include/vrt.h
View file @
ff374453
...
...
@@ -98,6 +98,7 @@ typedef double VCL_REAL;
typedef
const
struct
stevedore
*
VCL_STEVEDORE
;
typedef
const
char
*
VCL_STRING
;
typedef
double
VCL_TIME
;
typedef
struct
vcl
*
VCL_VCL
;
typedef
void
VCL_VOID
;
/***********************************************************************
...
...
@@ -313,6 +314,10 @@ int VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm,
const
char
*
path
,
const
char
*
file_id
,
VRT_CTX
);
void
VRT_Vmod_Fini
(
struct
vmod
**
hdl
);
/* VCL program related */
VCL_VCL
VRT_vcl_lookup
(
const
char
*
);
void
VRT_vcl_select
(
VRT_CTX
,
VCL_VCL
);
struct
vmod_priv
;
typedef
void
vmod_priv_free_f
(
void
*
);
struct
vmod_priv
{
...
...
lib/libvcc/vcc_types.c
View file @
ff374453
...
...
@@ -150,6 +150,11 @@ const struct type TIME[1] = {{
.
tostring
=
"VRT_TIME_string(ctx,
\v
1)"
,
}};
const
struct
type
VCL
[
1
]
=
{{
.
magic
=
TYPE_MAGIC
,
.
name
=
"VCL"
,
}};
const
struct
type
VOID
[
1
]
=
{{
.
magic
=
TYPE_MAGIC
,
.
name
=
"VOID"
,
...
...
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