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
45edc4df
Commit
45edc4df
authored
Nov 07, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move vlu to the private cli struct and turn ->cmd into a VSB.
parent
ea9bb000
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
26 deletions
+26
-26
cache_cli.c
bin/varnishd/cache/cache_cli.c
+1
-1
mgt_cli.c
bin/varnishd/mgt/mgt_cli.c
+3
-3
vcli_serve.h
include/vcli_serve.h
+9
-11
vcli_serve.c
lib/libvarnish/vcli_serve.c
+13
-11
No files found.
bin/varnishd/cache/cache_cli.c
View file @
45edc4df
...
...
@@ -73,7 +73,7 @@ cli_cb_before(const struct cli *cli)
{
ASSERT_CLI
();
VSL
(
SLT_CLI
,
0
,
"Rd %s"
,
cli
->
cmd
);
VSL
(
SLT_CLI
,
0
,
"Rd %s"
,
VSB_data
(
cli
->
cmd
)
);
VCL_Poll
();
VBE_Poll
();
Lck_Lock
(
&
cli_mtx
);
...
...
bin/varnishd/mgt/mgt_cli.c
View file @
45edc4df
...
...
@@ -340,8 +340,8 @@ mgt_cli_cb_before(const struct cli *cli)
{
if
(
cli
->
priv
==
stderr
)
fprintf
(
stderr
,
"> %s
\n
"
,
cli
->
cmd
);
MGT_Complain
(
C_CLI
,
"CLI %s Rd %s"
,
cli
->
ident
,
cli
->
cmd
);
fprintf
(
stderr
,
"> %s
\n
"
,
VSB_data
(
cli
->
cmd
)
);
MGT_Complain
(
C_CLI
,
"CLI %s Rd %s"
,
cli
->
ident
,
VSB_data
(
cli
->
cmd
)
);
}
static
void
...
...
@@ -351,7 +351,7 @@ mgt_cli_cb_after(const struct cli *cli)
MGT_Complain
(
C_CLI
,
"CLI %s Wr %03u %s"
,
cli
->
ident
,
cli
->
result
,
VSB_data
(
cli
->
sb
));
if
(
cli
->
priv
==
stderr
&&
cli
->
result
!=
CLIS_OK
&&
cli
->
cmd
[
0
]
!=
'-'
)
{
cli
->
result
!=
CLIS_OK
&&
*
VSB_data
(
cli
->
cmd
)
!=
'-'
)
{
MGT_Complain
(
C_ERR
,
"-I file CLI command failed (%d)
\n
%s
\n
"
,
cli
->
result
,
VSB_data
(
cli
->
sb
));
exit
(
2
);
...
...
include/vcli_serve.h
View file @
45edc4df
...
...
@@ -34,7 +34,6 @@
#include "vcli.h"
struct
cli
;
/* NB: struct cli is opaque at this level. */
struct
vlu
;
struct
VCLS
;
typedef
void
cli_func_t
(
struct
cli
*
,
const
char
*
const
*
av
,
void
*
priv
);
...
...
@@ -68,18 +67,17 @@ struct cli_proto {
/* a CLI session */
struct
cli
{
unsigned
magic
;
unsigned
magic
;
#define CLI_MAGIC 0x4038d570
void
*
priv
;
struct
vsb
*
sb
;
enum
VCLI_status_e
result
;
char
*
cmd
;
unsigned
auth
;
char
challenge
[
34
];
char
*
ident
;
struct
vlu
*
vlu
;
struct
VCLS
*
cls
;
volatile
unsigned
*
limit
;
struct
vsb
*
sb
;
enum
VCLI_status_e
result
;
struct
vsb
*
cmd
;
unsigned
auth
;
char
challenge
[
34
];
char
*
ident
;
struct
VCLS
*
cls
;
volatile
unsigned
*
limit
;
};
/* The implementation must provide these functions */
...
...
lib/libvarnish/vcli_serve.c
View file @
45edc4df
...
...
@@ -64,6 +64,7 @@ struct VCLS_fd {
struct
vsb
*
last_arg
;
int
last_idx
;
char
**
argv
;
struct
vlu
*
vlu
;
};
struct
VCLS
{
...
...
@@ -342,9 +343,13 @@ cls_vlu(void *priv, const char *p)
continue
;
if
(
*
p
==
'\0'
)
return
(
0
);
REPLACE
(
cli
->
cmd
,
p
);
AN
(
p
);
/* for FlexeLint */
cli
->
cmd
=
VSB_new
(
NULL
,
NULL
,
strlen
(
p
)
+
1
,
0
);
AN
(
cli
->
cmd
);
VSB_cat
(
cli
->
cmd
,
p
);
AZ
(
VSB_finish
(
cli
->
cmd
));
/* We ignore a single leading '-' (for -I cli_file) */
if
(
p
[
0
]
==
'-'
)
av
=
VAV_Parse
(
p
+
1
,
NULL
,
0
);
...
...
@@ -354,8 +359,7 @@ cls_vlu(void *priv, const char *p)
if
(
av
[
0
]
!=
NULL
)
{
i
=
cls_vlu2
(
priv
,
av
);
VAV_Free
(
av
);
free
(
cli
->
cmd
);
cli
->
cmd
=
NULL
;
VSB_destroy
(
&
cli
->
cmd
);
return
(
i
);
}
for
(
i
=
1
;
av
[
i
]
!=
NULL
;
i
++
)
...
...
@@ -363,8 +367,7 @@ cls_vlu(void *priv, const char *p)
if
(
i
<
3
||
cli
->
auth
==
0
||
strcmp
(
av
[
i
-
2
],
"<<"
))
{
i
=
cls_vlu2
(
priv
,
av
);
VAV_Free
(
av
);
free
(
cli
->
cmd
);
cli
->
cmd
=
NULL
;
VSB_destroy
(
&
cli
->
cmd
);
return
(
i
);
}
cfd
->
argv
=
av
;
...
...
@@ -391,8 +394,7 @@ cls_vlu(void *priv, const char *p)
cfd
->
argv
[
cfd
->
last_idx
]
=
NULL
;
VAV_Free
(
cfd
->
argv
);
cfd
->
argv
=
NULL
;
free
(
cli
->
cmd
);
cli
->
cmd
=
NULL
;
VSB_destroy
(
&
cli
->
cmd
);
VSB_destroy
(
&
cfd
->
last_arg
);
cfd
->
last_idx
=
0
;
return
(
i
);
...
...
@@ -437,8 +439,8 @@ VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
cfd
->
fdo
=
fdo
;
cfd
->
cli
=
&
cfd
->
clis
;
cfd
->
cli
->
magic
=
CLI_MAGIC
;
cfd
->
cli
->
vlu
=
VLU_New
(
cls_vlu
,
cfd
,
*
cs
->
maxlen
);
AN
(
cfd
->
cli
->
vlu
);
cfd
->
vlu
=
VLU_New
(
cls_vlu
,
cfd
,
*
cs
->
maxlen
);
AN
(
cfd
->
vlu
);
cfd
->
cli
->
sb
=
VSB_new_auto
();
AN
(
cfd
->
cli
->
sb
);
cfd
->
cli
->
limit
=
cs
->
limit
;
...
...
@@ -459,7 +461,7 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
VTAILQ_REMOVE
(
&
cs
->
fds
,
cfd
,
list
);
cs
->
nfd
--
;
VLU_Destroy
(
&
cfd
->
cli
->
vlu
);
VLU_Destroy
(
&
cfd
->
vlu
);
VSB_destroy
(
&
cfd
->
cli
->
sb
);
if
(
cfd
->
closefunc
==
NULL
)
{
(
void
)
close
(
cfd
->
fdi
);
...
...
@@ -538,7 +540,7 @@ VCLS_Poll(struct VCLS *cs, const struct cli *cli, int timeout)
if
(
pfd
[
0
].
revents
&
POLLHUP
)
k
=
1
;
else
k
=
VLU_Fd
(
cfd
->
cli
->
vlu
,
cfd
->
fdi
);
k
=
VLU_Fd
(
cfd
->
vlu
,
cfd
->
fdi
);
if
(
k
)
cls_close_fd
(
cs
,
cfd
);
return
(
k
);
...
...
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