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
d34a356c
Commit
d34a356c
authored
Jan 26, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add VRT_Endpoint_Clone() and give backends a copy of the endpoint
information to make them easier to clone.
parent
94af15e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
1 deletion
+54
-1
cache_backend.c
bin/varnishd/cache/cache_backend.c
+3
-0
cache_backend.h
bin/varnishd/cache/cache_backend.h
+2
-0
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+46
-0
vrt.h
include/vrt.h
+3
-1
No files found.
bin/varnishd/cache/cache_backend.c
View file @
d34a356c
...
...
@@ -438,6 +438,7 @@ vbe_free(struct backend *be)
VRT_BACKEND_HANDLE
();
#undef DA
#undef DN
free
(
be
->
endpoint
);
Lck_Delete
(
&
be
->
mtx
);
FREE_OBJ
(
be
);
...
...
@@ -588,6 +589,8 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
return
(
NULL
);
Lck_New
(
&
be
->
mtx
,
lck_backend
);
be
->
endpoint
=
VRT_Endpoint_Clone
(
vrt
->
endpoint
);
vep
=
be
->
endpoint
;
#define DA(x) do { if (vrt->x != NULL) REPLACE((be->x), (vrt->x)); } while (0)
#define DN(x) do { be->x = vrt->x; } while (0)
VRT_BACKEND_HANDLE
();
...
...
bin/varnishd/cache/cache_backend.h
View file @
d34a356c
...
...
@@ -57,6 +57,8 @@ struct backend {
VTAILQ_ENTRY
(
backend
)
list
;
struct
lock
mtx
;
struct
vrt_endpoint
*
endpoint
;
VRT_BACKEND_FIELDS
()
unsigned
sick
;
...
...
bin/varnishd/cache/cache_vrt.c
View file @
d34a356c
...
...
@@ -33,6 +33,8 @@
#include "config.h"
#include <stdlib.h>
#include "cache_varnishd.h"
#include "cache_objhead.h"
...
...
@@ -1061,3 +1063,47 @@ VRT_Format_Proxy(struct vsb *vsb, VCL_INT version, VCL_IP sac, VCL_IP sas,
{
VPX_Format_Proxy
(
vsb
,
(
int
)
version
,
sac
,
sas
,
auth
);
}
/*
* Clone a struct vrt_endpoint in a single malloc() allocation
*/
struct
vrt_endpoint
*
VRT_Endpoint_Clone
(
const
struct
vrt_endpoint
*
vep
)
{
size_t
sz
;
struct
vrt_endpoint
*
nvep
;
struct
suckaddr
*
sa
;
char
*
p
;
CHECK_OBJ_NOTNULL
(
vep
,
VRT_ENDPOINT_MAGIC
);
sz
=
sizeof
*
nvep
;
if
(
vep
->
ipv4
)
sz
+=
vsa_suckaddr_len
;
if
(
vep
->
ipv6
)
sz
+=
vsa_suckaddr_len
;
if
(
vep
->
uds_path
!=
NULL
)
sz
+=
strlen
(
vep
->
uds_path
)
+
1
;
p
=
malloc
(
sz
);
AN
(
p
);
nvep
=
(
void
*
)
p
;
p
+=
sizeof
*
nvep
;
INIT_OBJ
(
nvep
,
VRT_ENDPOINT_MAGIC
);
if
(
vep
->
ipv4
)
{
sa
=
(
void
*
)
p
;
//lint !e826
memcpy
(
sa
,
vep
->
ipv4
,
vsa_suckaddr_len
);
//lint !e826
nvep
->
ipv4
=
sa
;
p
+=
vsa_suckaddr_len
;
}
if
(
vep
->
ipv6
)
{
sa
=
(
void
*
)
p
;
//lint !e826
memcpy
(
sa
,
vep
->
ipv6
,
vsa_suckaddr_len
);
//lint !e826
nvep
->
ipv6
=
sa
;
p
+=
vsa_suckaddr_len
;
}
if
(
vep
->
uds_path
!=
NULL
)
{
strcpy
(
p
,
vep
->
uds_path
);
nvep
->
uds_path
=
p
;
}
return
(
nvep
);
}
include/vrt.h
View file @
d34a356c
...
...
@@ -53,8 +53,9 @@
* binary/load-time compatible, increment MAJOR version
*
* 13.0 (2021-03-15)
* VRT_Endpoint_Clone() added.
* Calling convention for VDP implementation changed
*
Added VRT_ValidHdr()
*
VRT_ValidHdr() added.
* struct vmod_priv_methods added
* struct vmod_priv free member replaced with methods
* VRT_CTX_Assert() added
...
...
@@ -521,6 +522,7 @@ VCL_BACKEND VRT_new_backend_clustered(VRT_CTX,
struct
vsmw_cluster
*
,
const
struct
vrt_backend
*
);
size_t
VRT_backend_vsm_need
(
VRT_CTX
);
void
VRT_delete_backend
(
VRT_CTX
,
VCL_BACKEND
*
);
struct
vrt_endpoint
*
VRT_Endpoint_Clone
(
const
struct
vrt_endpoint
*
vep
);
/* VSM related */
struct
vsmw_cluster
*
VRT_VSM_Cluster_New
(
VRT_CTX
,
size_t
);
...
...
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