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
1b429348
Commit
1b429348
authored
Nov 06, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renovate the VLU API (Inspired by #2481)
parent
f78a90b8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
30 deletions
+39
-30
mgt_child.c
bin/varnishd/mgt/mgt_child.c
+3
-3
vtc_process.c
bin/varnishtest/vtc_process.c
+2
-8
vlu.h
include/vlu.h
+7
-5
vcli_serve.c
lib/libvarnish/vcli_serve.c
+4
-4
vlu.c
lib/libvarnish/vlu.c
+22
-3
vsub.c
lib/libvarnish/vsub.c
+1
-7
No files found.
bin/varnishd/mgt/mgt_child.c
View file @
1b429348
...
@@ -221,7 +221,7 @@ static int __match_proto__(vev_cb_f)
...
@@ -221,7 +221,7 @@ static int __match_proto__(vev_cb_f)
child_listener
(
const
struct
vev
*
e
,
int
what
)
child_listener
(
const
struct
vev
*
e
,
int
what
)
{
{
if
((
what
&
~
EV_RD
)
||
VLU_Fd
(
child_
output
,
child_std_vlu
))
{
if
((
what
&
~
EV_RD
)
||
VLU_Fd
(
child_
std_vlu
,
child_output
))
{
ev_listen
=
NULL
;
ev_listen
=
NULL
;
if
(
e
!=
NULL
)
if
(
e
!=
NULL
)
mgt_reap_child
();
mgt_reap_child
();
...
@@ -361,7 +361,7 @@ mgt_launch_child(struct cli *cli)
...
@@ -361,7 +361,7 @@ mgt_launch_child(struct cli *cli)
MCH_Fd_Inherit
(
heritage
.
cli_out
,
NULL
);
MCH_Fd_Inherit
(
heritage
.
cli_out
,
NULL
);
closefd
(
&
heritage
.
cli_out
);
closefd
(
&
heritage
.
cli_out
);
child_std_vlu
=
VLU_New
(
NULL
,
child_line
,
0
);
child_std_vlu
=
VLU_New
(
child_line
,
NULL
,
0
);
AN
(
child_std_vlu
);
AN
(
child_std_vlu
);
AZ
(
ev_listen
);
AZ
(
ev_listen
);
...
@@ -515,7 +515,7 @@ mgt_reap_child(void)
...
@@ -515,7 +515,7 @@ mgt_reap_child(void)
/* Pick up any stuff lingering on stdout/stderr */
/* Pick up any stuff lingering on stdout/stderr */
(
void
)
child_listener
(
NULL
,
EV_RD
);
(
void
)
child_listener
(
NULL
,
EV_RD
);
closefd
(
&
child_output
);
closefd
(
&
child_output
);
VLU_Destroy
(
child_std_vlu
);
VLU_Destroy
(
&
child_std_vlu
);
child_pid
=
-
1
;
child_pid
=
-
1
;
...
...
bin/varnishtest/vtc_process.c
View file @
1b429348
...
@@ -169,16 +169,10 @@ process_thread(void *priv)
...
@@ -169,16 +169,10 @@ process_thread(void *priv)
struct
process
*
p
;
struct
process
*
p
;
struct
rusage
ru
;
struct
rusage
ru
;
int
r
;
int
r
;
struct
vlu
*
vlu
;
CAST_OBJ_NOTNULL
(
p
,
priv
,
PROCESS_MAGIC
);
CAST_OBJ_NOTNULL
(
p
,
priv
,
PROCESS_MAGIC
);
if
(
p
->
fd_from
>
0
)
{
if
(
p
->
fd_from
>
0
)
vlu
=
VLU_New
(
p
,
process_vlu_func
,
1024
);
(
void
)
VLU_File
(
p
->
fd_from
,
process_vlu_func
,
p
,
1024
);
AN
(
vlu
);
while
(
!
VLU_Fd
(
p
->
fd_from
,
vlu
))
continue
;
VLU_Destroy
(
vlu
);
}
r
=
wait4
(
p
->
pid
,
&
p
->
status
,
0
,
&
ru
);
r
=
wait4
(
p
->
pid
,
&
p
->
status
,
0
,
&
ru
);
AZ
(
pthread_mutex_lock
(
&
p
->
mtx
));
AZ
(
pthread_mutex_lock
(
&
p
->
mtx
));
...
...
include/vlu.h
View file @
1b429348
...
@@ -27,11 +27,13 @@
...
@@ -27,11 +27,13 @@
* a function on each.
* a function on each.
*/
*/
#ifndef VLU_H_INCLUDED
#ifdef VLU_H_INCLUDED
# error "vlu.h included multiple times"
#endif
#define VLU_H_INCLUDED
#define VLU_H_INCLUDED
typedef
int
(
vlu_f
)(
void
*
,
const
char
*
);
typedef
int
(
vlu_f
)(
void
*
,
const
char
*
);
struct
vlu
*
VLU_New
(
v
oid
*
priv
,
vlu_f
*
func
,
unsigned
bufsize
);
struct
vlu
*
VLU_New
(
v
lu_f
*
,
void
*
,
unsigned
);
int
VLU_Fd
(
int
fd
,
struct
vlu
*
l
);
int
VLU_Fd
(
struct
vlu
*
,
int
);
void
VLU_Destroy
(
struct
vlu
*
l
);
void
VLU_Destroy
(
struct
vlu
*
*
);
#endif
int
VLU_File
(
int
,
vlu_f
*
,
void
*
,
unsigned
);
lib/libvarnish/vcli_serve.c
View file @
1b429348
...
@@ -431,7 +431,7 @@ VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
...
@@ -431,7 +431,7 @@ VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
cfd
->
fdo
=
fdo
;
cfd
->
fdo
=
fdo
;
cfd
->
cli
=
&
cfd
->
clis
;
cfd
->
cli
=
&
cfd
->
clis
;
cfd
->
cli
->
magic
=
CLI_MAGIC
;
cfd
->
cli
->
magic
=
CLI_MAGIC
;
cfd
->
cli
->
vlu
=
VLU_New
(
c
fd
,
cls_vlu
,
*
cs
->
maxlen
);
cfd
->
cli
->
vlu
=
VLU_New
(
c
ls_vlu
,
cfd
,
*
cs
->
maxlen
);
AN
(
cfd
->
cli
->
vlu
);
AN
(
cfd
->
cli
->
vlu
);
cfd
->
cli
->
sb
=
VSB_new_auto
();
cfd
->
cli
->
sb
=
VSB_new_auto
();
AN
(
cfd
->
cli
->
sb
);
AN
(
cfd
->
cli
->
sb
);
...
@@ -453,7 +453,7 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
...
@@ -453,7 +453,7 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
VTAILQ_REMOVE
(
&
cs
->
fds
,
cfd
,
list
);
VTAILQ_REMOVE
(
&
cs
->
fds
,
cfd
,
list
);
cs
->
nfd
--
;
cs
->
nfd
--
;
VLU_Destroy
(
cfd
->
cli
->
vlu
);
VLU_Destroy
(
&
cfd
->
cli
->
vlu
);
VSB_destroy
(
&
cfd
->
cli
->
sb
);
VSB_destroy
(
&
cfd
->
cli
->
sb
);
if
(
cfd
->
closefunc
==
NULL
)
{
if
(
cfd
->
closefunc
==
NULL
)
{
(
void
)
close
(
cfd
->
fdi
);
(
void
)
close
(
cfd
->
fdi
);
...
@@ -552,7 +552,7 @@ VCLS_PollFd(struct VCLS *cs, int fd, int timeout)
...
@@ -552,7 +552,7 @@ VCLS_PollFd(struct VCLS *cs, int fd, int timeout)
if
(
pfd
[
0
].
revents
&
POLLHUP
)
if
(
pfd
[
0
].
revents
&
POLLHUP
)
k
=
1
;
k
=
1
;
else
else
k
=
VLU_Fd
(
cfd
->
fdi
,
cfd
->
cli
->
vlu
);
k
=
VLU_Fd
(
cfd
->
cli
->
vlu
,
cfd
->
fdi
);
if
(
k
)
if
(
k
)
cls_close_fd
(
cs
,
cfd
);
cls_close_fd
(
cs
,
cfd
);
return
(
k
);
return
(
k
);
...
@@ -591,7 +591,7 @@ VCLS_Poll(struct VCLS *cs, int timeout)
...
@@ -591,7 +591,7 @@ VCLS_Poll(struct VCLS *cs, int timeout)
if
(
pfd
[
i
].
revents
&
POLLHUP
)
if
(
pfd
[
i
].
revents
&
POLLHUP
)
k
=
1
;
k
=
1
;
else
else
k
=
VLU_Fd
(
cfd
->
fdi
,
cfd
->
cli
->
vlu
);
k
=
VLU_Fd
(
cfd
->
cli
->
vlu
,
cfd
->
fdi
);
if
(
k
)
if
(
k
)
cls_close_fd
(
cs
,
cfd
);
cls_close_fd
(
cs
,
cfd
);
i
++
;
i
++
;
...
...
lib/libvarnish/vlu.c
View file @
1b429348
...
@@ -50,7 +50,7 @@ struct vlu {
...
@@ -50,7 +50,7 @@ struct vlu {
};
};
struct
vlu
*
struct
vlu
*
VLU_New
(
v
oid
*
priv
,
vlu_f
*
func
,
unsigned
bufsize
)
VLU_New
(
v
lu_f
*
func
,
void
*
priv
,
unsigned
bufsize
)
{
{
struct
vlu
*
l
;
struct
vlu
*
l
;
...
@@ -71,9 +71,13 @@ VLU_New(void *priv, vlu_f *func, unsigned bufsize)
...
@@ -71,9 +71,13 @@ VLU_New(void *priv, vlu_f *func, unsigned bufsize)
}
}
void
void
VLU_Destroy
(
struct
vlu
*
l
)
VLU_Destroy
(
struct
vlu
*
*
lp
)
{
{
struct
vlu
*
l
;
AN
(
lp
);
l
=
*
lp
;
*
lp
=
NULL
;
CHECK_OBJ_NOTNULL
(
l
,
LINEUP_MAGIC
);
CHECK_OBJ_NOTNULL
(
l
,
LINEUP_MAGIC
);
free
(
l
->
buf
);
free
(
l
->
buf
);
FREE_OBJ
(
l
);
FREE_OBJ
(
l
);
...
@@ -111,7 +115,7 @@ LineUpProcess(struct vlu *l)
...
@@ -111,7 +115,7 @@ LineUpProcess(struct vlu *l)
}
}
int
int
VLU_Fd
(
int
fd
,
struct
vlu
*
l
)
VLU_Fd
(
struct
vlu
*
l
,
int
fd
)
{
{
int
i
;
int
i
;
...
@@ -122,3 +126,18 @@ VLU_Fd(int fd, struct vlu *l)
...
@@ -122,3 +126,18 @@ VLU_Fd(int fd, struct vlu *l)
l
->
bufp
+=
i
;
l
->
bufp
+=
i
;
return
(
LineUpProcess
(
l
));
return
(
LineUpProcess
(
l
));
}
}
int
VLU_File
(
int
fd
,
vlu_f
*
func
,
void
*
priv
,
unsigned
bufsize
)
{
struct
vlu
*
vlu
;
int
i
;
vlu
=
VLU_New
(
func
,
priv
,
bufsize
);
AN
(
vlu
);
do
{
i
=
VLU_Fd
(
vlu
,
fd
);
}
while
(
i
==
0
);
VLU_Destroy
(
&
vlu
);
return
(
i
);
}
lib/libvarnish/vsub.c
View file @
1b429348
...
@@ -89,7 +89,6 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
...
@@ -89,7 +89,6 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
{
{
int
rv
,
p
[
2
],
status
;
int
rv
,
p
[
2
],
status
;
pid_t
pid
;
pid_t
pid
;
struct
vlu
*
vlu
;
struct
vsub_priv
sp
;
struct
vsub_priv
sp
;
sp
.
sb
=
sb
;
sp
.
sb
=
sb
;
...
@@ -126,12 +125,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
...
@@ -126,12 +125,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name,
_exit
(
4
);
_exit
(
4
);
}
}
closefd
(
&
p
[
1
]);
closefd
(
&
p
[
1
]);
vlu
=
VLU_New
(
&
sp
,
vsub_vlu
,
0
);
(
void
)
VLU_File
(
p
[
0
],
vsub_vlu
,
&
sp
,
0
);
AN
(
vlu
);
while
(
!
VLU_Fd
(
p
[
0
],
vlu
))
continue
;
closefd
(
&
p
[
0
]);
VLU_Destroy
(
vlu
);
if
(
sp
.
maxlines
>=
0
&&
sp
.
lines
>
sp
.
maxlines
)
if
(
sp
.
maxlines
>=
0
&&
sp
.
lines
>
sp
.
maxlines
)
VSB_printf
(
sb
,
"[%d lines truncated]
\n
"
,
VSB_printf
(
sb
,
"[%d lines truncated]
\n
"
,
sp
.
lines
-
sp
.
maxlines
);
sp
.
lines
-
sp
.
maxlines
);
...
...
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