Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvdfp-pipe
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvdfp-pipe
Commits
5c03356c
Commit
5c03356c
authored
Aug 04, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allocate the buffer in the VDP state, default size PIPE_BUF.
parent
cc352245
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
vdfp_pipe.c
src/vdfp_pipe.c
+30
-6
No files found.
src/vdfp_pipe.c
View file @
5c03356c
...
...
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdlib.h>
#include <poll.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/wait.h>
...
...
@@ -91,12 +92,18 @@ struct vdp_state {
unsigned
magic
;
#define PIPE_VDP_STATE_MAGIC 0xaeb87f5f
struct
VPFX
(
pipe_vdp
)
*
obj
;
char
*
buf
;
pid_t
chldpid
;
int
chldin
;
int
chldout
;
int
chlderr
;
};
/* XXX make bufsz configurable per object (and at runtime?) */
static
size_t
default_bufsz
=
0
;
#define DEFAULT_DEFAULT_BUFSZ (4096)
/* VDP */
static
inline
int
...
...
@@ -156,6 +163,13 @@ vdp_init(struct req *req, void **priv)
"state: %s"
,
obj
->
name
,
vstrerror
(
errno
));
return
(
-
1
);
}
state
->
buf
=
malloc
(
default_bufsz
);
if
(
state
->
buf
==
NULL
)
{
VSLb
(
req
->
vsl
,
SLT_Error
,
"vdfp_pipe: vdp %s: cannot allocate "
"buffer size %zd: %s"
,
obj
->
name
,
default_bufsz
,
vstrerror
(
errno
));
return
(
-
1
);
}
*
priv
=
state
;
state
->
obj
=
obj
;
state
->
chldpid
=
-
1
;
...
...
@@ -295,8 +309,6 @@ rw_child(struct req *req, struct vdp_state *state, enum vdp_action act,
struct
pollfd
fds
[
3
];
int
retval
,
nfds
;
ssize_t
nbytes
;
// XXX allocate buf in state
char
buf
[
4096
];
CHECK_OBJ_NOTNULL
(
state
->
obj
,
PIPE_VDP_MAGIC
);
AN
(
state
->
obj
->
name
);
...
...
@@ -383,7 +395,7 @@ rw_child(struct req *req, struct vdp_state *state, enum vdp_action act,
assert
(
fds
[
i
].
fd
==
state
->
chldout
||
fds
[
i
].
fd
==
state
->
chlderr
);
errno
=
0
;
nbytes
=
read
(
fds
[
i
].
fd
,
buf
,
4096
);
nbytes
=
read
(
fds
[
i
].
fd
,
state
->
buf
,
default_bufsz
);
if
(
nbytes
<
0
)
{
VSLb
(
req
->
vsl
,
SLT_Error
,
"vdfp_pipe: vdp %s:"
" error reading %s from %s: %s"
,
...
...
@@ -399,7 +411,8 @@ rw_child(struct req *req, struct vdp_state *state, enum vdp_action act,
break
;
}
if
(
fds
[
i
].
fd
==
state
->
chldout
)
{
retval
=
VDP_bytes
(
req
,
VDP_FLUSH
,
buf
,
nbytes
);
retval
=
VDP_bytes
(
req
,
VDP_FLUSH
,
state
->
buf
,
nbytes
);
if
(
retval
<
0
)
{
close_all
(
state
);
return
(
-
1
);
...
...
@@ -409,7 +422,7 @@ rw_child(struct req *req, struct vdp_state *state, enum vdp_action act,
// XXX write one line at a time
VSLb
(
req
->
vsl
,
SLT_Error
,
"vdfp_pipe: vdp %s: %s "
"stderr ..."
,
state
->
obj
->
name
,
state
->
obj
->
path
);
VSLb_bin
(
req
->
vsl
,
SLT_Error
,
nbytes
,
buf
);
VSLb_bin
(
req
->
vsl
,
SLT_Error
,
nbytes
,
state
->
buf
);
}
if
(
len
==
0
)
break
;
...
...
@@ -452,6 +465,8 @@ vdp_fini(struct req *req, void **priv)
if
(
state
->
chldpid
!=
-
1
)
(
void
)
check_pid
(
state
,
req
->
vsl
,
0
);
if
(
state
->
buf
!=
NULL
)
free
(
state
->
buf
);
FREE_OBJ
(
state
);
*
priv
=
NULL
;
return
(
0
);
...
...
@@ -469,6 +484,16 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
AN
(
priv
);
switch
(
e
)
{
case
VCL_EVENT_LOAD
:
if
(
default_bufsz
==
0
)
{
#ifdef PIPE_BUF
default_bufsz
=
PIPE_BUF
;
#else
default_bufsz
=
DEFAULT_DEFAULT_BUFSZ
;
#endif
AN
(
default_bufsz
);
}
return
(
0
);
case
VCL_EVENT_DISCARD
:
AN
(
ctx
->
vcl
);
map
=
VRBT_MIN
(
vdp_tree
,
&
tree_h
);
...
...
@@ -491,7 +516,6 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
}
}
return
(
0
);
case
VCL_EVENT_LOAD
:
case
VCL_EVENT_WARM
:
case
VCL_EVENT_COLD
:
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