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
d68a7210
Commit
d68a7210
authored
Nov 20, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce the new VSM "per-child" lifetime.
parent
2d1ca366
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
24 deletions
+98
-24
common_vsm.c
bin/varnishd/common/common_vsm.c
+3
-0
mgt.h
bin/varnishd/mgt/mgt.h
+4
-0
mgt_child.c
bin/varnishd/mgt/mgt_child.c
+11
-3
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+3
-0
mgt_shmem.c
bin/varnishd/mgt/mgt_shmem.c
+77
-21
No files found.
bin/varnishd/common/common_vsm.c
View file @
d68a7210
...
...
@@ -317,7 +317,10 @@ VSM_common_delete(struct vsm_sc **scp)
free
(
vr
->
ptr
);
FREE_OBJ
(
vr
);
}
/* Mark VSM as abandoned */
sc
->
head
->
alloc_seq
=
0
;
VWMB
();
FREE_OBJ
(
sc
);
}
...
...
bin/varnishd/mgt/mgt.h
View file @
d68a7210
...
...
@@ -84,6 +84,10 @@ void mgt_sandbox_solaris_privsep(void);
void
mgt_SHM_Init
(
void
);
void
mgt_SHM_static_alloc
(
const
void
*
,
ssize_t
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
);
void
mgt_SHM_Create
(
void
);
void
mgt_SHM_Destroy
(
int
keep
);
void
mgt_SHM_Size_Adjust
(
void
);
/* stevedore_mgt.c */
void
STV_Config
(
const
char
*
spec
);
...
...
bin/varnishd/mgt/mgt_child.c
View file @
d68a7210
...
...
@@ -315,6 +315,9 @@ start_child(struct cli *cli)
heritage
.
std_fd
=
cp
[
1
];
child_output
=
cp
[
0
];
AN
(
heritage
.
vsm
);
mgt_SHM_Size_Adjust
();
AN
(
heritage
.
vsm
);
AN
(
heritage
.
param
);
if
((
pid
=
fork
())
<
0
)
{
perror
(
"Could not fork child"
);
...
...
@@ -427,8 +430,7 @@ mgt_handle_panicstr(pid_t r)
{
char
time_str
[
30
];
if
(
heritage
.
panic_str
[
0
]
==
'\0'
)
return
;
AN
(
heritage
.
panic_str
[
0
]);
REPORT
(
LOG_ERR
,
"Child (%jd) Panic message: %s"
,
(
intmax_t
)
r
,
heritage
.
panic_str
);
...
...
@@ -492,7 +494,13 @@ mgt_sigchld(const struct vev *e, int what)
REPORT
(
LOG_INFO
,
"%s"
,
VSB_data
(
vsb
));
VSB_delete
(
vsb
);
if
(
heritage
.
panic_str
[
0
]
!=
'\0'
)
{
mgt_handle_panicstr
(
r
);
mgt_SHM_Destroy
(
1
);
}
else
{
mgt_SHM_Destroy
(
0
);
}
mgt_SHM_Create
();
child_pid
=
-
1
;
...
...
bin/varnishd/mgt/mgt_main.c
View file @
d68a7210
...
...
@@ -652,6 +652,9 @@ main(int argc, char * const *argv)
if
(
T_arg
!=
NULL
)
mgt_cli_telnet
(
T_arg
);
/* Instantiate VSM */
mgt_SHM_Create
();
MGT_Run
();
if
(
pfh
!=
NULL
)
...
...
bin/varnishd/mgt/mgt_shmem.c
View file @
d68a7210
...
...
@@ -59,6 +59,9 @@
#define PAN_CLASS "Panic"
static
void
*
mgt_vsm_p
;
static
ssize_t
mgt_vsm_l
;
/*--------------------------------------------------------------------
* Use a bogo-VSM to hold master-copies of the VSM chunks the master
* publishes, such as -S & -T arguments.
...
...
@@ -174,20 +177,31 @@ vsm_zerofile(const char *fn, ssize_t size)
}
/*--------------------------------------------------------------------
* Create a VSM instance
*/
static
void
mgt_
SHM_Setup
(
void
)
static
size_t
mgt_
shm_size
(
void
)
{
uintmax_t
size
,
ps
;
void
*
p
;
char
fnbuf
[
64
];
int
vsm_fd
;
size_t
size
,
ps
;
size
=
mgt_param
.
vsl_space
+
mgt_param
.
vsm_space
;
ps
=
getpagesize
();
size
+=
ps
-
1
;
size
&=
~
(
ps
-
1
);
size
&=
~
(
ps
-
1U
);
return
(
size
);
}
void
mgt_SHM_Create
(
void
)
{
size_t
size
;
void
*
p
;
char
fnbuf
[
64
];
int
vsm_fd
;
AZ
(
heritage
.
vsm
);
size
=
mgt_shm_size
();
bprintf
(
fnbuf
,
"%s.%jd"
,
VSM_FILENAME
,
(
intmax_t
)
getpid
());
...
...
@@ -207,11 +221,26 @@ mgt_SHM_Setup(void)
exit
(
-
1
);
}
mgt_vsm_p
=
p
;
mgt_vsm_l
=
size
;
/* This may or may not work */
(
void
)
mlock
(
p
,
size
);
heritage
.
vsm
=
VSM_common_new
(
p
,
size
);
VSM_common_copy
(
heritage
.
vsm
,
static_vsm
);
heritage
.
param
=
VSM_common_alloc
(
heritage
.
vsm
,
sizeof
*
heritage
.
param
,
VSM_CLASS_PARAM
,
""
,
""
);
AN
(
heritage
.
param
);
*
heritage
.
param
=
mgt_param
;
heritage
.
panic_str_len
=
64
*
1024
;
heritage
.
panic_str
=
VSM_common_alloc
(
heritage
.
vsm
,
heritage
.
panic_str_len
,
PAN_CLASS
,
""
,
""
);
AN
(
heritage
.
panic_str
);
if
(
rename
(
fnbuf
,
VSM_FILENAME
))
{
fprintf
(
stderr
,
"Rename failed %s -> %s: %s
\n
"
,
fnbuf
,
VSM_FILENAME
,
strerror
(
errno
));
...
...
@@ -220,6 +249,41 @@ mgt_SHM_Setup(void)
}
}
/*--------------------------------------------------------------------
* Destroy a VSM instance
*/
void
mgt_SHM_Destroy
(
int
keep
)
{
AN
(
heritage
.
vsm
);
if
(
keep
)
(
void
)
rename
(
VSM_FILENAME
,
VSM_FILENAME
".keep"
);
heritage
.
panic_str
=
NULL
;
heritage
.
panic_str_len
=
0
;
heritage
.
param
=
NULL
;
VSM_common_delete
(
&
heritage
.
vsm
);
AZ
(
munmap
(
mgt_vsm_p
,
mgt_vsm_l
));
mgt_vsm_p
=
NULL
;
mgt_vsm_l
=
0
;
}
/*--------------------------------------------------------------------
* Destroy and recreate VSM if its size should change
*/
void
mgt_SHM_Size_Adjust
(
void
)
{
AN
(
heritage
.
vsm
);
if
(
mgt_vsm_l
==
mgt_shm_size
())
return
;
mgt_SHM_Destroy
(
0
);
mgt_SHM_Create
();
}
/*--------------------------------------------------------------------
* Exit handler that clears the owning pid from the SHMLOG
*/
...
...
@@ -233,6 +297,10 @@ mgt_shm_atexit(void)
VSM_common_delete
(
&
heritage
.
vsm
);
}
/*--------------------------------------------------------------------
* Initialize VSM subsystem
*/
void
mgt_SHM_Init
(
void
)
{
...
...
@@ -243,21 +311,9 @@ mgt_SHM_Init(void)
if
(
i
)
exit
(
i
);
/* Create our static VSM instance */
static_vsm
=
VSM_common_new
(
static_vsm_buf
,
sizeof
static_vsm_buf
);
mgt_SHM_Setup
();
/* Setup atexit handler */
AZ
(
atexit
(
mgt_shm_atexit
));
VSM_common_copy
(
heritage
.
vsm
,
static_vsm
);
heritage
.
param
=
VSM_common_alloc
(
heritage
.
vsm
,
sizeof
*
heritage
.
param
,
VSM_CLASS_PARAM
,
""
,
""
);
AN
(
heritage
.
param
);
*
heritage
.
param
=
mgt_param
;
heritage
.
panic_str_len
=
64
*
1024
;
heritage
.
panic_str
=
VSM_common_alloc
(
heritage
.
vsm
,
heritage
.
panic_str_len
,
PAN_CLASS
,
""
,
""
);
AN
(
heritage
.
panic_str
);
}
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