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
9a714650
Commit
9a714650
authored
Jan 08, 2016
by
Geoff Simmons
Committed by
Lasse Karstensen
Jan 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
director VMODs use a rwlock for mutexing, add_backend() uses a wrlock,
all other methods use rdlock
parent
da727cb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
12 deletions
+20
-12
fall_back.c
lib/libvmod_directors/fall_back.c
+1
-1
round_robin.c
lib/libvmod_directors/round_robin.c
+1
-1
vdir.c
lib/libvmod_directors/vdir.c
+15
-8
vdir.h
lib/libvmod_directors/vdir.h
+3
-2
No files found.
lib/libvmod_directors/fall_back.c
View file @
9a714650
...
...
@@ -66,7 +66,7 @@ vmod_fallback_resolve(const struct director *dir, struct worker *wrk,
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CAST_OBJ_NOTNULL
(
rr
,
dir
->
priv
,
VMOD_DIRECTORS_FALLBACK_MAGIC
);
vdir_lock
(
rr
->
vd
);
vdir_
rd
lock
(
rr
->
vd
);
for
(
u
=
0
;
u
<
rr
->
vd
->
n_backend
;
u
++
)
{
be
=
rr
->
vd
->
backend
[
u
];
CHECK_OBJ_NOTNULL
(
be
,
DIRECTOR_MAGIC
);
...
...
lib/libvmod_directors/round_robin.c
View file @
9a714650
...
...
@@ -67,7 +67,7 @@ vmod_rr_resolve(const struct director *dir, struct worker *wrk,
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CAST_OBJ_NOTNULL
(
rr
,
dir
->
priv
,
VMOD_DIRECTORS_ROUND_ROBIN_MAGIC
);
vdir_lock
(
rr
->
vd
);
vdir_
rd
lock
(
rr
->
vd
);
for
(
u
=
0
;
u
<
rr
->
vd
->
n_backend
;
u
++
)
{
rr
->
nxt
%=
rr
->
vd
->
n_backend
;
be
=
rr
->
vd
->
backend
[
rr
->
nxt
];
...
...
lib/libvmod_directors/vdir.c
View file @
9a714650
...
...
@@ -63,7 +63,7 @@ vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
ALLOC_OBJ
(
vd
,
VDIR_MAGIC
);
AN
(
vd
);
*
vdp
=
vd
;
AZ
(
pthread_
mutex
_init
(
&
vd
->
mtx
,
NULL
));
AZ
(
pthread_
rwlock
_init
(
&
vd
->
mtx
,
NULL
));
ALLOC_OBJ
(
vd
->
dir
,
DIRECTOR_MAGIC
);
AN
(
vd
->
dir
);
...
...
@@ -89,7 +89,7 @@ vdir_delete(struct vdir **vdp)
free
(
vd
->
backend
);
free
(
vd
->
weight
);
AZ
(
pthread_
mutex
_destroy
(
&
vd
->
mtx
));
AZ
(
pthread_
rwlock
_destroy
(
&
vd
->
mtx
));
free
(
vd
->
dir
->
vcl_name
);
FREE_OBJ
(
vd
->
dir
);
vbit_destroy
(
vd
->
vbm
);
...
...
@@ -97,17 +97,24 @@ vdir_delete(struct vdir **vdp)
}
void
vdir_lock
(
struct
vdir
*
vd
)
vdir_
rd
lock
(
struct
vdir
*
vd
)
{
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
vd
->
mtx
));
AZ
(
pthread_rwlock_rdlock
(
&
vd
->
mtx
));
}
void
vdir_wrlock
(
struct
vdir
*
vd
)
{
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
AZ
(
pthread_rwlock_wrlock
(
&
vd
->
mtx
));
}
void
vdir_unlock
(
struct
vdir
*
vd
)
{
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
AZ
(
pthread_
mutex
_unlock
(
&
vd
->
mtx
));
AZ
(
pthread_
rwlock
_unlock
(
&
vd
->
mtx
));
}
...
...
@@ -118,7 +125,7 @@ vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight)
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
AN
(
be
);
vdir_lock
(
vd
);
vdir_
wr
lock
(
vd
);
if
(
vd
->
n_backend
>=
vd
->
l_backend
)
vdir_expand
(
vd
,
vd
->
l_backend
+
16
);
assert
(
vd
->
n_backend
<
vd
->
l_backend
);
...
...
@@ -140,7 +147,7 @@ vdir_any_healthy(struct vdir *vd, const struct busyobj *bo, double *changed)
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
CHECK_OBJ_ORNULL
(
bo
,
BUSYOBJ_MAGIC
);
vdir_lock
(
vd
);
vdir_
rd
lock
(
vd
);
if
(
changed
!=
NULL
)
*
changed
=
0
;
for
(
u
=
0
;
u
<
vd
->
n_backend
;
u
++
)
{
...
...
@@ -183,7 +190,7 @@ vdir_pick_be(struct vdir *vd, double w, const struct busyobj *bo)
double
tw
=
0
.
0
;
VCL_BACKEND
be
=
NULL
;
vdir_lock
(
vd
);
vdir_
rd
lock
(
vd
);
for
(
u
=
0
;
u
<
vd
->
n_backend
;
u
++
)
{
if
(
vd
->
backend
[
u
]
->
healthy
(
vd
->
backend
[
u
],
bo
,
NULL
))
{
vbit_clr
(
vd
->
vbm
,
u
);
...
...
lib/libvmod_directors/vdir.h
View file @
9a714650
...
...
@@ -31,7 +31,7 @@ struct vbitmap;
struct
vdir
{
unsigned
magic
;
#define VDIR_MAGIC 0x99f4b726
pthread_
mutex_t
mtx
;
pthread_
rwlock_t
mtx
;
unsigned
n_backend
;
unsigned
l_backend
;
VCL_BACKEND
*
backend
;
...
...
@@ -44,7 +44,8 @@ struct vdir {
void
vdir_new
(
struct
vdir
**
vdp
,
const
char
*
name
,
const
char
*
vcl_name
,
vdi_healthy_f
*
healthy
,
vdi_resolve_f
*
resolve
,
void
*
priv
);
void
vdir_delete
(
struct
vdir
**
vdp
);
void
vdir_lock
(
struct
vdir
*
vd
);
void
vdir_rdlock
(
struct
vdir
*
vd
);
void
vdir_wrlock
(
struct
vdir
*
vd
);
void
vdir_unlock
(
struct
vdir
*
vd
);
unsigned
vdir_add_backend
(
struct
vdir
*
,
VCL_BACKEND
be
,
double
weight
);
unsigned
vdir_any_healthy
(
struct
vdir
*
,
const
struct
busyobj
*
,
...
...
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