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
f2c1e642
Commit
f2c1e642
authored
May 21, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch from dridi to replace CLI with mutext for locking backend config.
parent
cbc829fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+10
-7
locks.h
include/tbl/locks.h
+1
-0
No files found.
bin/varnishd/cache/cache_backend_cfg.c
View file @
f2c1e642
...
@@ -46,11 +46,8 @@
...
@@ -46,11 +46,8 @@
#include "vrt.h"
#include "vrt.h"
#include "vtim.h"
#include "vtim.h"
/*
* The list of backends is not locked, it is only ever accessed from
* the CLI thread, so there is no need.
*/
static
VTAILQ_HEAD
(,
backend
)
backends
=
VTAILQ_HEAD_INITIALIZER
(
backends
);
static
VTAILQ_HEAD
(,
backend
)
backends
=
VTAILQ_HEAD_INITIALIZER
(
backends
);
static
struct
lock
backends_mtx
;
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
*/
*/
...
@@ -59,10 +56,13 @@ void
...
@@ -59,10 +56,13 @@ void
VBE_DeleteBackend
(
struct
backend
*
b
)
VBE_DeleteBackend
(
struct
backend
*
b
)
{
{
ASSERT_CLI
();
CHECK_OBJ_NOTNULL
(
b
,
BACKEND_MAGIC
);
CHECK_OBJ_NOTNULL
(
b
,
BACKEND_MAGIC
);
Lck_Lock
(
&
backends_mtx
);
VTAILQ_REMOVE
(
&
backends
,
b
,
list
);
VTAILQ_REMOVE
(
&
backends
,
b
,
list
);
VSC_C_main
->
n_backend
--
;
Lck_Unlock
(
&
backends_mtx
);
free
(
b
->
ipv4
);
free
(
b
->
ipv4
);
free
(
b
->
ipv6
);
free
(
b
->
ipv6
);
free
(
b
->
display_name
);
free
(
b
->
display_name
);
...
@@ -70,7 +70,6 @@ VBE_DeleteBackend(struct backend *b)
...
@@ -70,7 +70,6 @@ VBE_DeleteBackend(struct backend *b)
VBT_Rel
(
&
b
->
tcp_pool
);
VBT_Rel
(
&
b
->
tcp_pool
);
Lck_Delete
(
&
b
->
mtx
);
Lck_Delete
(
&
b
->
mtx
);
FREE_OBJ
(
b
);
FREE_OBJ
(
b
);
VSC_C_main
->
n_backend
--
;
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
@@ -85,7 +84,6 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
...
@@ -85,7 +84,6 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
struct
backend
*
b
;
struct
backend
*
b
;
char
buf
[
128
];
char
buf
[
128
];
ASSERT_CLI
();
AN
(
vb
->
vcl_name
);
AN
(
vb
->
vcl_name
);
assert
(
vb
->
ipv4_suckaddr
!=
NULL
||
vb
->
ipv6_suckaddr
!=
NULL
);
assert
(
vb
->
ipv4_suckaddr
!=
NULL
||
vb
->
ipv6_suckaddr
!=
NULL
);
...
@@ -118,8 +116,10 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
...
@@ -118,8 +116,10 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
b
->
health_changed
=
VTIM_real
();
b
->
health_changed
=
VTIM_real
();
b
->
admin_health
=
ah_probe
;
b
->
admin_health
=
ah_probe
;
Lck_Lock
(
&
backends_mtx
);
VTAILQ_INSERT_TAIL
(
&
backends
,
b
,
list
);
VTAILQ_INSERT_TAIL
(
&
backends
,
b
,
list
);
VSC_C_main
->
n_backend
++
;
VSC_C_main
->
n_backend
++
;
Lck_Unlock
(
&
backends_mtx
);
return
(
b
);
return
(
b
);
}
}
...
@@ -176,6 +176,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
...
@@ -176,6 +176,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
VSB_printf
(
vsb
,
"%s.%s"
,
vcc
->
loaded_name
,
matcher
);
VSB_printf
(
vsb
,
"%s.%s"
,
vcc
->
loaded_name
,
matcher
);
}
}
AZ
(
VSB_finish
(
vsb
));
AZ
(
VSB_finish
(
vsb
));
Lck_Lock
(
&
backends_mtx
);
VTAILQ_FOREACH
(
b
,
&
backends
,
list
)
{
VTAILQ_FOREACH
(
b
,
&
backends
,
list
)
{
if
(
fnmatch
(
VSB_data
(
vsb
),
b
->
display_name
,
0
))
if
(
fnmatch
(
VSB_data
(
vsb
),
b
->
display_name
,
0
))
continue
;
continue
;
...
@@ -186,6 +187,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
...
@@ -186,6 +187,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
break
;
break
;
}
}
}
}
Lck_Unlock
(
&
backends_mtx
);
VSB_delete
(
vsb
);
VSB_delete
(
vsb
);
return
(
found
);
return
(
found
);
}
}
...
@@ -313,4 +315,5 @@ VBE_InitCfg(void)
...
@@ -313,4 +315,5 @@ VBE_InitCfg(void)
{
{
CLI_AddFuncs
(
backend_cmds
);
CLI_AddFuncs
(
backend_cmds
);
Lck_New
(
&
backends_mtx
,
lck_vbe
);
}
}
include/tbl/locks.h
View file @
f2c1e642
...
@@ -46,6 +46,7 @@ LOCK(exp)
...
@@ -46,6 +46,7 @@ LOCK(exp)
LOCK
(
lru
)
LOCK
(
lru
)
LOCK
(
cli
)
LOCK
(
cli
)
LOCK
(
ban
)
LOCK
(
ban
)
LOCK
(
vbe
)
LOCK
(
vbp
)
LOCK
(
vbp
)
LOCK
(
backend
)
LOCK
(
backend
)
LOCK
(
vcapace
)
LOCK
(
vcapace
)
...
...
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