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
4aeb4f63
Commit
4aeb4f63
authored
Nov 06, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the mgt->child handover of CLI setup
parent
d0eb0f15
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
37 deletions
+21
-37
cache_cli.c
bin/varnishd/cache/cache_cli.c
+7
-8
mgt_cli.c
bin/varnishd/mgt/mgt_cli.c
+2
-2
vcli_serve.h
include/vcli_serve.h
+2
-3
vcli_serve.c
lib/libvarnish/vcli_serve.c
+10
-24
No files found.
bin/varnishd/cache/cache_cli.c
View file @
4aeb4f63
...
...
@@ -44,7 +44,7 @@
pthread_t
cli_thread
;
static
struct
lock
cli_mtx
;
static
int
add_check
;
static
struct
VCLS
*
cls
;
static
struct
VCLS
*
c
ache_c
ls
;
/*
* The CLI commandlist is split in three:
...
...
@@ -64,7 +64,7 @@ CLI_AddFuncs(struct cli_proto *p)
AZ
(
add_check
);
Lck_Lock
(
&
cli_mtx
);
VCLS_AddFunc
(
cls
,
0
,
p
);
VCLS_AddFunc
(
c
ache_c
ls
,
0
,
p
);
Lck_Unlock
(
&
cli_mtx
);
}
...
...
@@ -96,10 +96,10 @@ CLI_Run(void)
add_check
=
1
;
AN
(
VCLS_AddFd
(
cls
,
heritage
.
cli_in
,
heritage
.
cli_out
,
NULL
,
NULL
));
AN
(
VCLS_AddFd
(
c
ache_c
ls
,
heritage
.
cli_in
,
heritage
.
cli_out
,
NULL
,
NULL
));
do
{
i
=
VCLS_PollFd
(
cls
,
heritage
.
cli_in
,
-
1
);
i
=
VCLS_PollFd
(
c
ache_c
ls
,
heritage
.
cli_in
,
-
1
);
}
while
(
i
==
0
);
VSL
(
SLT_CLI
,
0
,
"EOF on CLI connection, worker stops"
);
}
...
...
@@ -123,10 +123,9 @@ CLI_Init(void)
Lck_New
(
&
cli_mtx
,
lck_cli
);
cli_thread
=
pthread_self
();
cls
=
VCLS_New
(
cli_cb_before
,
cli_cb_after
,
&
cache_param
->
cli_buffer
,
&
cache_param
->
cli_limit
);
AN
(
cls
);
VCLS_Clone
(
cls
,
heritage
.
cls
);
cache_cls
=
heritage
.
cls
;
AN
(
cache_cls
);
VCLS_SetHooks
(
cache_cls
,
cli_cb_before
,
cli_cb_after
);
CLI_AddFuncs
(
cli_cmds
);
}
bin/varnishd/mgt/mgt_cli.c
View file @
4aeb4f63
...
...
@@ -364,9 +364,9 @@ void
mgt_cli_init_cls
(
void
)
{
mgt_cls
=
VCLS_New
(
mgt_cli_cb_before
,
mgt_cli_cb_after
,
&
mgt_param
.
cli_buffer
,
&
mgt_param
.
cli_limit
);
mgt_cls
=
VCLS_New
(
&
mgt_param
.
cli_buffer
,
&
mgt_param
.
cli_limit
);
AN
(
mgt_cls
);
VCLS_SetHooks
(
mgt_cls
,
mgt_cli_cb_before
,
mgt_cli_cb_after
);
VCLS_AddFunc
(
mgt_cls
,
MCF_NOAUTH
,
cli_auth
);
VCLS_AddFunc
(
mgt_cls
,
MCF_AUTH
,
cli_proto
);
VCLS_AddFunc
(
mgt_cls
,
MCF_AUTH
,
cli_debug
);
...
...
include/vcli_serve.h
View file @
4aeb4f63
...
...
@@ -92,14 +92,13 @@ void VCLI_SetResult(struct cli *cli, unsigned r);
typedef
void
cls_cb_f
(
void
*
priv
);
typedef
void
cls_cbc_f
(
const
struct
cli
*
);
struct
VCLS
*
VCLS_New
(
cls_cbc_f
*
before
,
cls_cbc_f
*
after
,
volatile
unsigned
*
maxlen
,
volatile
unsigned
*
limit
);
struct
VCLS
*
VCLS_New
(
volatile
unsigned
*
maxlen
,
volatile
unsigned
*
limit
);
void
VCLS_SetHooks
(
struct
VCLS
*
,
cls_cbc_f
*
,
cls_cbc_f
*
);
struct
cli
*
VCLS_AddFd
(
struct
VCLS
*
cs
,
int
fdi
,
int
fdo
,
cls_cb_f
*
closefunc
,
void
*
priv
);
void
VCLS_AddFunc
(
struct
VCLS
*
cs
,
unsigned
auth
,
struct
cli_proto
*
clp
);
int
VCLS_PollFd
(
struct
VCLS
*
cs
,
int
fd
,
int
timeout
);
void
VCLS_Destroy
(
struct
VCLS
**
);
void
VCLS_Clone
(
struct
VCLS
*
cs
,
struct
VCLS
*
cso
);
/* From libvarnish/cli.c */
cli_func_t
VCLS_func_close
;
...
...
lib/libvarnish/vcli_serve.c
View file @
4aeb4f63
...
...
@@ -400,8 +400,7 @@ cls_vlu(void *priv, const char *p)
}
struct
VCLS
*
VCLS_New
(
cls_cbc_f
*
before
,
cls_cbc_f
*
after
,
volatile
unsigned
*
maxlen
,
volatile
unsigned
*
limit
)
VCLS_New
(
volatile
unsigned
*
maxlen
,
volatile
unsigned
*
limit
)
{
struct
VCLS
*
cs
;
...
...
@@ -409,13 +408,20 @@ VCLS_New(cls_cbc_f *before, cls_cbc_f *after, volatile unsigned *maxlen,
AN
(
cs
);
VTAILQ_INIT
(
&
cs
->
fds
);
VTAILQ_INIT
(
&
cs
->
funcs
);
cs
->
before
=
before
;
cs
->
after
=
after
;
cs
->
maxlen
=
maxlen
;
cs
->
limit
=
limit
;
return
(
cs
);
}
void
VCLS_SetHooks
(
struct
VCLS
*
cs
,
cls_cbc_f
*
before
,
cls_cbc_f
*
after
)
{
CHECK_OBJ_NOTNULL
(
cs
,
VCLS_MAGIC
);
cs
->
before
=
before
;
cs
->
after
=
after
;
}
struct
cli
*
VCLS_AddFd
(
struct
VCLS
*
cs
,
int
fdi
,
int
fdo
,
cls_cb_f
*
closefunc
,
void
*
priv
)
{
...
...
@@ -499,26 +505,6 @@ VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp)
}
}
/*
* This function has *very* special semantics, related to the mgt/worker
* process Copy-On-Write memory relationship.
*/
void
VCLS_Clone
(
struct
VCLS
*
cs
,
struct
VCLS
*
cso
)
{
struct
cli_proto
*
clp
,
*
clp2
;
CHECK_OBJ_NOTNULL
(
cs
,
VCLS_MAGIC
);
CHECK_OBJ_NOTNULL
(
cso
,
VCLS_MAGIC
);
VTAILQ_FOREACH_SAFE
(
clp
,
&
cso
->
funcs
,
list
,
clp2
)
{
VTAILQ_REMOVE
(
&
cso
->
funcs
,
clp
,
list
);
VTAILQ_INSERT_TAIL
(
&
cs
->
funcs
,
clp
,
list
);
clp
->
auth
=
0
;
clp
->
func
=
NULL
;
}
}
int
VCLS_PollFd
(
struct
VCLS
*
cs
,
int
fd
,
int
timeout
)
{
...
...
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