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
17f2e938
Commit
17f2e938
authored
Mar 11, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the VCC generated round-robin and fallback directors,
these now live in VMOD.directors (and can be stacked :-)
parent
e810830a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
10 additions
and
293 deletions
+10
-293
Makefile.am
bin/varnishd/Makefile.am
+0
-1
cache_backend.h
bin/varnishd/cache/cache_backend.h
+0
-2
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+0
-4
cache_dir_round_robin.c
bin/varnishd/cache/cache_dir_round_robin.c
+0
-175
vrt.h
include/vrt.h
+0
-14
Makefile.am
lib/libvcl/Makefile.am
+0
-1
vcc_backend.c
lib/libvcl/vcc_backend.c
+10
-2
vcc_compile.h
lib/libvcl/vcc_compile.h
+0
-3
vcc_dir_round_robin.c
lib/libvcl/vcc_dir_round_robin.c
+0
-91
No files found.
bin/varnishd/Makefile.am
View file @
17f2e938
...
...
@@ -21,7 +21,6 @@ varnishd_SOURCES = \
cache/cache_dir.c
\
cache/cache_dir_dns.c
\
cache/cache_dir_random.c
\
cache/cache_dir_round_robin.c
\
cache/cache_esi_deliver.c
\
cache/cache_esi_fetch.c
\
cache/cache_esi_parse.c
\
...
...
bin/varnishd/cache/cache_backend.h
View file @
17f2e938
...
...
@@ -187,6 +187,4 @@ dir_init_f VRT_init_dir_simple;
dir_init_f
VRT_init_dir_dns
;
dir_init_f
VRT_init_dir_hash
;
dir_init_f
VRT_init_dir_random
;
dir_init_f
VRT_init_dir_round_robin
;
dir_init_f
VRT_init_dir_fallback
;
dir_init_f
VRT_init_dir_client
;
bin/varnishd/cache/cache_backend_cfg.c
View file @
17f2e938
...
...
@@ -257,10 +257,6 @@ VRT_init_dir(struct cli *cli, struct director **dir, const char *name,
VRT_init_dir_random
(
cli
,
dir
,
idx
,
priv
);
else
if
(
!
strcmp
(
name
,
"dns"
))
VRT_init_dir_dns
(
cli
,
dir
,
idx
,
priv
);
else
if
(
!
strcmp
(
name
,
"round-robin"
))
VRT_init_dir_round_robin
(
cli
,
dir
,
idx
,
priv
);
else
if
(
!
strcmp
(
name
,
"fallback"
))
VRT_init_dir_fallback
(
cli
,
dir
,
idx
,
priv
);
else
if
(
!
strcmp
(
name
,
"client"
))
VRT_init_dir_client
(
cli
,
dir
,
idx
,
priv
);
else
...
...
bin/varnishd/cache/cache_dir_round_robin.c
deleted
100644 → 0
View file @
e810830a
/*-
* Copyright (c) 2008-2011 Varnish Software AS
* All rights reserved.
*
* Author: Petter Knudsen <petter@linpro.no>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "config.h"
#include <stdlib.h>
#include "cache.h"
#include "cache_backend.h"
#include "vrt.h"
/*--------------------------------------------------------------------*/
struct
vdi_round_robin_host
{
struct
director
*
backend
;
};
enum
mode_e
{
m_round_robin
,
m_fallback
};
struct
vdi_round_robin
{
unsigned
magic
;
#define VDI_ROUND_ROBIN_MAGIC 0x2114a178
struct
director
dir
;
enum
mode_e
mode
;
struct
vdi_round_robin_host
*
hosts
;
unsigned
nhosts
;
unsigned
next_host
;
};
static
struct
vbc
*
vdi_round_robin_getfd
(
const
struct
director
*
d
,
struct
req
*
req
)
{
int
i
;
struct
vdi_round_robin
*
vs
;
struct
director
*
backend
;
struct
vbc
*
vbe
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
vs
,
d
->
priv
,
VDI_ROUND_ROBIN_MAGIC
);
/*
* In fallback mode we ignore the next_host and always grab the
* first healthy backend we can find.
*/
for
(
i
=
0
;
i
<
vs
->
nhosts
;
i
++
)
{
if
(
vs
->
mode
==
m_round_robin
)
{
backend
=
vs
->
hosts
[
vs
->
next_host
].
backend
;
vs
->
next_host
=
(
vs
->
next_host
+
1
)
%
vs
->
nhosts
;
}
else
/* m_fallback */
{
backend
=
vs
->
hosts
[
i
].
backend
;
}
if
(
!
VDI_Healthy
(
backend
,
req
))
continue
;
vbe
=
VDI_GetFd
(
backend
,
req
);
if
(
vbe
!=
NULL
)
return
(
vbe
);
}
return
(
NULL
);
}
static
unsigned
vdi_round_robin_healthy
(
const
struct
director
*
d
,
const
struct
req
*
req
)
{
struct
vdi_round_robin
*
vs
;
struct
director
*
backend
;
int
i
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
vs
,
d
->
priv
,
VDI_ROUND_ROBIN_MAGIC
);
for
(
i
=
0
;
i
<
vs
->
nhosts
;
i
++
)
{
backend
=
vs
->
hosts
[
i
].
backend
;
if
(
VDI_Healthy
(
backend
,
req
))
return
(
1
);
}
return
(
0
);
}
static
void
vdi_round_robin_fini
(
const
struct
director
*
d
)
{
struct
vdi_round_robin
*
vs
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
vs
,
d
->
priv
,
VDI_ROUND_ROBIN_MAGIC
);
free
(
vs
->
hosts
);
free
(
vs
->
dir
.
vcl_name
);
vs
->
dir
.
magic
=
0
;
vs
->
next_host
=
0
;
FREE_OBJ
(
vs
);
}
static
void
vrt_init_dir
(
struct
cli
*
cli
,
struct
director
**
bp
,
int
idx
,
const
void
*
priv
,
enum
mode_e
mode
)
{
const
struct
vrt_dir_round_robin
*
t
;
struct
vdi_round_robin
*
vs
;
const
struct
vrt_dir_round_robin_entry
*
te
;
struct
vdi_round_robin_host
*
vh
;
int
i
;
ASSERT_CLI
();
(
void
)
cli
;
t
=
priv
;
ALLOC_OBJ
(
vs
,
VDI_ROUND_ROBIN_MAGIC
);
XXXAN
(
vs
);
vs
->
hosts
=
calloc
(
sizeof
*
vh
,
t
->
nmember
);
XXXAN
(
vs
->
hosts
);
vs
->
dir
.
magic
=
DIRECTOR_MAGIC
;
vs
->
dir
.
priv
=
vs
;
vs
->
dir
.
name
=
"round_robin"
;
REPLACE
(
vs
->
dir
.
vcl_name
,
t
->
name
);
vs
->
dir
.
getfd
=
vdi_round_robin_getfd
;
vs
->
dir
.
fini
=
vdi_round_robin_fini
;
vs
->
dir
.
healthy
=
vdi_round_robin_healthy
;
vs
->
mode
=
mode
;
vh
=
vs
->
hosts
;
te
=
t
->
members
;
for
(
i
=
0
;
i
<
t
->
nmember
;
i
++
,
vh
++
,
te
++
)
{
vh
->
backend
=
bp
[
te
->
host
];
AN
(
vh
->
backend
);
}
vs
->
nhosts
=
t
->
nmember
;
vs
->
next_host
=
0
;
bp
[
idx
]
=
&
vs
->
dir
;
}
void
VRT_init_dir_round_robin
(
struct
cli
*
cli
,
struct
director
**
bp
,
int
idx
,
const
void
*
priv
)
{
vrt_init_dir
(
cli
,
bp
,
idx
,
priv
,
m_round_robin
);
}
void
VRT_init_dir_fallback
(
struct
cli
*
cli
,
struct
director
**
bp
,
int
idx
,
const
void
*
priv
)
{
vrt_init_dir
(
cli
,
bp
,
idx
,
priv
,
m_fallback
);
}
include/vrt.h
View file @
17f2e938
...
...
@@ -121,20 +121,6 @@ struct vrt_dir_random {
const
struct
vrt_dir_random_entry
*
members
;
};
/*
* A director with round robin selection
*/
struct
vrt_dir_round_robin_entry
{
int
host
;
};
struct
vrt_dir_round_robin
{
const
char
*
name
;
unsigned
nmember
;
const
struct
vrt_dir_round_robin_entry
*
members
;
};
/*
* A director with dns-based selection
*/
...
...
lib/libvcl/Makefile.am
View file @
17f2e938
...
...
@@ -18,7 +18,6 @@ libvcl_la_SOURCES = \
vcc_backend_util.c
\
vcc_compile.c
\
vcc_dir_random.c
\
vcc_dir_round_robin.c
\
vcc_dir_dns.c
\
vcc_expr.c
\
vcc_parse.c
\
...
...
lib/libvcl/vcc_backend.c
View file @
17f2e938
...
...
@@ -696,6 +696,7 @@ vcc_ParseSimpleDirector(struct vcc *tl)
* Parse directors and backends
*/
static
const
struct
dirlist
{
const
char
*
name
;
parsedirector_f
*
func
;
...
...
@@ -703,8 +704,8 @@ static const struct dirlist {
{
"hash"
,
vcc_ParseRandomDirector
},
{
"random"
,
vcc_ParseRandomDirector
},
{
"client"
,
vcc_ParseRandomDirector
},
{
"round-robin"
,
vcc_ParseRoundRobinDirector
},
{
"fallback"
,
vcc_ParseRoundRobinDirector
},
{
"round-robin"
,
NULL
},
{
"fallback"
,
NULL
},
{
"dns"
,
vcc_ParseDnsDirector
},
{
NULL
,
NULL
}
};
...
...
@@ -753,6 +754,13 @@ vcc_ParseDirector(struct vcc *tl)
vcc_ErrWhere
(
tl
,
tl
->
t_policy
);
return
;
}
if
(
dl
->
func
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"
\n
%.*s director are now in VMOD.directors
\n
"
,
PF
(
tl
->
t_policy
));
vcc_ErrWhere
(
tl
,
tl
->
t_policy
);
return
;
}
Ff
(
tl
,
0
,
"
\t
VRT_fini_dir(cli, VGCDIR(_%.*s));
\n
"
,
PF
(
tl
->
t_dir
));
SkipToken
(
tl
,
'{'
);
...
...
lib/libvcl/vcc_compile.h
View file @
17f2e938
...
...
@@ -269,9 +269,6 @@ void EncString(struct vsb *sb, const char *b, const char *e, int mode);
/* vcc_dir_random.c */
parsedirector_f
vcc_ParseRandomDirector
;
/* vcc_dir_round_robin.c */
parsedirector_f
vcc_ParseRoundRobinDirector
;
/* vcc_expr.c */
void
vcc_Duration
(
struct
vcc
*
tl
,
double
*
);
unsigned
vcc_UintVal
(
struct
vcc
*
tl
);
...
...
lib/libvcl/vcc_dir_round_robin.c
deleted
100644 → 0
View file @
e810830a
/*-
* Copyright (c) 2008-2009 Varnish Software AS
* All rights reserved.
*
* Author: Petter Knudsen <petter@linpro.no>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "vcc_compile.h"
/*--------------------------------------------------------------------
* Parse directors
*/
void
vcc_ParseRoundRobinDirector
(
struct
vcc
*
tl
)
{
struct
token
*
t_field
,
*
t_be
;
int
nelem
;
struct
fld_spec
*
fs
;
const
char
*
first
;
char
*
p
;
fs
=
vcc_FldSpec
(
tl
,
"!backend"
,
NULL
);
Fc
(
tl
,
0
,
"
\n
static const struct vrt_dir_round_robin_entry "
"vdrre_%.*s[] = {
\n
"
,
PF
(
tl
->
t_dir
));
for
(
nelem
=
0
;
tl
->
t
->
tok
!=
'}'
;
nelem
++
)
{
/* List of members */
first
=
""
;
t_be
=
tl
->
t
;
vcc_ResetFldSpec
(
fs
);
SkipToken
(
tl
,
'{'
);
Fc
(
tl
,
0
,
"
\t
{"
);
while
(
tl
->
t
->
tok
!=
'}'
)
{
/* Member fields */
vcc_IsField
(
tl
,
&
t_field
,
fs
);
ERRCHK
(
tl
);
if
(
vcc_IdIs
(
t_field
,
"backend"
))
{
vcc_ParseBackendHost
(
tl
,
nelem
,
&
p
);
ERRCHK
(
tl
);
AN
(
p
);
Fc
(
tl
,
0
,
"%s .host = VGC_backend_%s"
,
first
,
p
);
}
else
{
ErrInternal
(
tl
);
}
first
=
", "
;
}
vcc_FieldsOk
(
tl
,
fs
);
if
(
tl
->
err
)
{
VSB_printf
(
tl
->
sb
,
"
\n
In member host specification starting at:
\n
"
);
vcc_ErrWhere
(
tl
,
t_be
);
return
;
}
Fc
(
tl
,
0
,
" },
\n
"
);
vcc_NextToken
(
tl
);
}
Fc
(
tl
,
0
,
"};
\n
"
);
Fc
(
tl
,
0
,
"
\n
static const struct vrt_dir_round_robin vgc_dir_priv_%.*s = {
\n
"
,
PF
(
tl
->
t_dir
));
Fc
(
tl
,
0
,
"
\t
.name =
\"
%.*s
\"
,
\n
"
,
PF
(
tl
->
t_dir
));
Fc
(
tl
,
0
,
"
\t
.nmember = %d,
\n
"
,
nelem
);
Fc
(
tl
,
0
,
"
\t
.members = vdrre_%.*s,
\n
"
,
PF
(
tl
->
t_dir
));
Fc
(
tl
,
0
,
"};
\n
"
);
}
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