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
9a85dfdf
Commit
9a85dfdf
authored
Apr 04, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the code to configure parameter min/max/default values.
parent
25647b48
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
70 deletions
+50
-70
cache_ban_build.c
bin/varnishd/cache/cache_ban_build.c
+1
-1
mgt.h
bin/varnishd/mgt/mgt.h
+8
-3
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+8
-13
mgt_param.c
bin/varnishd/mgt/mgt_param.c
+25
-27
mgt_param_tcp.c
bin/varnishd/mgt/mgt_param_tcp.c
+1
-6
mgt_param_tweak.c
bin/varnishd/mgt/mgt_param_tweak.c
+3
-7
mgt_pool.c
bin/varnishd/mgt/mgt_pool.c
+4
-13
No files found.
bin/varnishd/cache/cache_ban_build.c
View file @
9a85dfdf
...
...
@@ -130,7 +130,7 @@ ban_error(struct ban_proto *bp, const char *fmt, ...)
/* Record the error message in the vsb */
VSB_clear
(
bp
->
vsb
);
va_start
(
ap
,
fmt
);
(
void
)
VSB_vprintf
(
bp
->
vsb
,
fmt
,
ap
);
VSB_vprintf
(
bp
->
vsb
,
fmt
,
ap
);
va_end
(
ap
);
AZ
(
VSB_finish
(
bp
->
vsb
));
bp
->
err
=
VSB_data
(
bp
->
vsb
);
...
...
bin/varnishd/mgt/mgt.h
View file @
9a85dfdf
...
...
@@ -133,9 +133,14 @@ void MGT_complain(const char *loud, const char *, ...) __v_printflike(2, 3);
/* mgt_param.c */
void
MCF_InitParams
(
struct
cli
*
);
void
MCF_CollectParams
(
void
);
void
MCF_SetDefault
(
const
char
*
param
,
const
char
*
def
);
void
MCF_SetMinimum
(
const
char
*
param
,
const
char
*
def
);
void
MCF_SetMaximum
(
const
char
*
param
,
const
char
*
def
);
enum
mcf_which_e
{
MCF_DEFAULT
=
32
,
MCF_MINIMUM
=
33
,
MCF_MAXIMUM
=
34
,
};
void
MCF_ParamConf
(
enum
mcf_which_e
,
const
char
*
param
,
const
char
*
,
...)
__v_printflike
(
3
,
4
);
void
MCF_ParamSet
(
struct
cli
*
,
const
char
*
param
,
const
char
*
val
);
void
MCF_ParamProtect
(
struct
cli
*
,
const
char
*
arg
);
void
MCF_DumpRstParam
(
void
);
...
...
bin/varnishd/mgt/mgt_main.c
View file @
9a85dfdf
...
...
@@ -425,9 +425,6 @@ make_secret(const char *dirname)
/*--------------------------------------------------------------------*/
static
char
stackmin
[
20
];
static
char
stackdef
[
20
];
static
void
init_params
(
struct
cli
*
cli
)
{
...
...
@@ -442,26 +439,24 @@ init_params(struct cli *cli)
* Adjust default parameters for 32 bit systems to conserve
* VM space.
*/
MCF_
SetDefault
(
"workspace_client"
,
"24k"
);
MCF_
SetDefault
(
"workspace_backend"
,
"16k"
);
MCF_
SetDefault
(
"http_resp_size"
,
"8k"
);
MCF_
SetDefault
(
"http_req_size"
,
"12k"
);
MCF_
SetDefault
(
"gzip_buffer"
,
"4k"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"workspace_client"
,
"24k"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"workspace_backend"
,
"16k"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"http_resp_size"
,
"8k"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"http_req_size"
,
"12k"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"gzip_buffer"
,
"4k"
);
}
#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux)
MCF_
SetDefault
(
"accept_filter"
,
"off"
);
MCF_
ParamConf
(
MCF_DEFAULT
,
"accept_filter"
,
"off"
);
#endif
low
=
sysconf
(
_SC_THREAD_STACK_MIN
);
bprintf
(
stackmin
,
"%jd"
,
(
intmax_t
)
low
);
MCF_SetMinimum
(
"thread_pool_stack"
,
stackmin
);
MCF_ParamConf
(
MCF_MINIMUM
,
"thread_pool_stack"
,
"%jd"
,
(
intmax_t
)
low
);
def
=
48
*
1024
;
if
(
def
<
low
)
def
=
low
;
bprintf
(
stackdef
,
"%jd"
,
(
intmax_t
)
def
);
MCF_SetDefault
(
"thread_pool_stack"
,
stackdef
);
MCF_ParamConf
(
MCF_DEFAULT
,
"thread_pool_stack"
,
"%jd"
,
(
intmax_t
)
def
);
MCF_InitParams
(
cli
);
}
...
...
bin/varnishd/mgt/mgt_param.c
View file @
9a85dfdf
...
...
@@ -30,6 +30,7 @@
#include "config.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -483,38 +484,35 @@ MCF_CollectParams(void)
/*--------------------------------------------------------------------*/
void
MCF_
SetDefault
(
const
char
*
param
,
const
char
*
new_def
)
MCF_
ParamConf
(
enum
mcf_which_e
which
,
const
char
*
param
,
const
char
*
fmt
,
...
)
{
struct
parspec
*
pp
;
struct
vsb
*
vsb
;
va_list
ap
;
pp
=
mcf_findpar
(
param
);
AN
(
pp
);
pp
->
def
=
new_def
;
vsb
=
VSB_new_auto
();
AN
(
vsb
);
va_start
(
ap
,
fmt
);
VSB_vprintf
(
vsb
,
fmt
,
ap
);
va_end
(
ap
);
AZ
(
VSB_finish
(
vsb
));
switch
(
which
)
{
case
MCF_DEFAULT
:
pp
->
def
=
strdup
(
VSB_data
(
vsb
));
AN
(
pp
->
def
);
}
void
MCF_SetMinimum
(
const
char
*
param
,
const
char
*
new_min
)
{
struct
parspec
*
pp
;
AN
(
new_min
);
pp
=
mcf_findpar
(
param
);
AN
(
pp
);
pp
->
min
=
new_min
;
break
;
case
MCF_MINIMUM
:
pp
->
min
=
strdup
(
VSB_data
(
vsb
));
AN
(
pp
->
min
);
}
void
MCF_SetMaximum
(
const
char
*
param
,
const
char
*
new_max
)
{
struct
parspec
*
pp
;
AN
(
new_max
);
pp
=
mcf_findpar
(
param
);
AN
(
pp
);
pp
->
max
=
new_max
;
break
;
case
MCF_MAXIMUM
:
pp
->
max
=
strdup
(
VSB_data
(
vsb
));
AN
(
pp
->
max
);
break
;
}
VSB_delete
(
vsb
);
}
/*--------------------------------------------------------------------*/
...
...
bin/varnishd/mgt/mgt_param_tcp.c
View file @
9a85dfdf
...
...
@@ -79,17 +79,12 @@ tcp_probe(int sock, int nam, const char *param, unsigned def)
int
i
;
socklen_t
l
;
unsigned
u
;
char
buf
[
10
];
const
char
*
p
;
l
=
sizeof
u
;
i
=
getsockopt
(
sock
,
IPPROTO_TCP
,
nam
,
&
u
,
&
l
);
if
(
i
<
0
||
u
==
0
)
u
=
def
;
bprintf
(
buf
,
"%u"
,
u
);
p
=
strdup
(
buf
);
AN
(
p
);
MCF_SetDefault
(
param
,
p
);
MCF_ParamConf
(
MCF_DEFAULT
,
param
,
"%u"
,
u
);
}
static
void
...
...
bin/varnishd/mgt/mgt_param_tweak.c
View file @
9a85dfdf
...
...
@@ -329,16 +329,14 @@ tweak_vsl_buffer(struct vsb *vsb, const struct parspec *par, const char *arg)
{
volatile
unsigned
*
d1
;
volatile
ssize_t
dest
;
char
buf
[
20
];
d1
=
par
->
priv
;
dest
=
*
d1
;
if
(
tweak_generic_bytes
(
vsb
,
&
dest
,
arg
,
par
->
min
,
par
->
max
))
return
(
-
1
);
*
d1
=
dest
;
bprintf
(
buf
,
"%u"
,
*
d1
-
12
);
MCF_SetMaximum
(
"vsl_reclen"
,
strdup
(
buf
));
MCF_SetMaximum
(
"shm_reclen"
,
strdup
(
buf
));
MCF_ParamConf
(
MCF_MAXIMUM
,
"vsl_reclen"
,
"%u"
,
*
d1
-
12
);
MCF_ParamConf
(
MCF_MAXIMUM
,
"shm_reclen"
,
"%u"
,
*
d1
-
12
);
return
(
0
);
}
...
...
@@ -347,15 +345,13 @@ tweak_vsl_reclen(struct vsb *vsb, const struct parspec *par, const char *arg)
{
volatile
unsigned
*
d1
;
volatile
ssize_t
dest
;
char
buf
[
20
];
d1
=
par
->
priv
;
dest
=
*
d1
;
if
(
tweak_generic_bytes
(
vsb
,
&
dest
,
arg
,
par
->
min
,
par
->
max
))
return
(
-
1
);
*
d1
=
dest
;
bprintf
(
buf
,
"%u"
,
*
d1
+
12
);
MCF_SetMinimum
(
"vsl_buffer"
,
strdup
(
buf
));
MCF_ParamConf
(
MCF_MINIMUM
,
"vsl_buffer"
,
"%u"
,
*
d1
+
12
);
return
(
0
);
}
...
...
bin/varnishd/mgt/mgt_pool.c
View file @
9a85dfdf
...
...
@@ -53,21 +53,15 @@
* limit, so they don't end up crossing.
*/
static
char
min_val
[
20
];
static
char
max_val
[
20
];
static
int
tweak_thread_pool_min
(
struct
vsb
*
vsb
,
const
struct
parspec
*
par
,
const
char
*
arg
)
{
struct
vsb
v2
;
if
(
tweak_generic_uint
(
vsb
,
par
->
priv
,
arg
,
par
->
min
,
par
->
max
))
return
(
-
1
);
AN
(
VSB_new
(
&
v2
,
min_val
,
sizeof
min_val
,
0
));
AZ
(
tweak_generic_uint
(
&
v2
,
&
mgt_param
.
wthread_min
,
NULL
,
NULL
,
NULL
));
AZ
(
VSB_finish
(
&
v2
));
MCF_SetMinimum
(
"thread_pool_max"
,
min_val
);
MCF_ParamConf
(
MCF_MINIMUM
,
"thread_pool_max"
,
"%u"
,
mgt_param
.
wthread_min
);
return
(
0
);
}
...
...
@@ -75,14 +69,11 @@ static int
tweak_thread_pool_max
(
struct
vsb
*
vsb
,
const
struct
parspec
*
par
,
const
char
*
arg
)
{
struct
vsb
v2
;
if
(
tweak_generic_uint
(
vsb
,
par
->
priv
,
arg
,
par
->
min
,
par
->
max
))
return
(
-
1
);
AN
(
VSB_new
(
&
v2
,
max_val
,
sizeof
max_val
,
0
));
AZ
(
tweak_generic_uint
(
&
v2
,
&
mgt_param
.
wthread_max
,
NULL
,
NULL
,
NULL
));
AZ
(
VSB_finish
(
&
v2
));
MCF_SetMaximum
(
"thread_pool_min"
,
max_val
);
MCF_ParamConf
(
MCF_MAXIMUM
,
"thread_pool_min"
,
"%u"
,
mgt_param
.
wthread_max
);
return
(
0
);
}
...
...
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