Commit 7c4b4a58 authored by Geoff Simmons's avatar Geoff Simmons

Simplify setting the default buffer size.

parent 104b0069
......@@ -55,6 +55,13 @@
/* == default first_byte_ and between_bytes_timeout (in ms) */
#define TIMEOUT_MS 60000
/* XXX make bufsz configurable per object (and at runtime?) */
#ifdef PIPE_BUF
#define DEFAULT_BUFSZ ((size_t)PIPE_BUF)
#else
#define DEFAULT_BUFSZ ((size_t)4096)
#endif
struct VPFX(pipe_vdp) {
unsigned magic;
#define PIPE_VDP_MAGIC 0xa887d6c3
......@@ -104,11 +111,6 @@ struct vdp_state {
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
......@@ -167,10 +169,10 @@ vdp_init(struct req *req, void **priv)
"state: %s", obj->name, vstrerror(errno));
return (-1);
}
state->buf = malloc(default_bufsz);
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,
"buffer size %zd: %s", obj->name, DEFAULT_BUFSZ,
vstrerror(errno));
return (-1);
}
......@@ -412,7 +414,7 @@ rw_child(struct req *req, struct vdp_state *state, enum vdp_action act,
continue;
}
errno = 0;
nbytes = read(fds[i].fd, state->buf, default_bufsz);
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",
......@@ -509,16 +511,6 @@ 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);
......@@ -537,6 +529,7 @@ 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment