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
6e25bf69
Commit
6e25bf69
authored
Feb 10, 2020
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Two more uses for WS_VSB()
parent
7c4dcd66
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
42 deletions
+31
-42
cache_http.c
bin/varnishd/cache/cache_http.c
+21
-17
cache_vrt_filter.c
bin/varnishd/cache/cache_vrt_filter.c
+6
-19
cache_ws.c
bin/varnishd/cache/cache_ws.c
+4
-6
No files found.
bin/varnishd/cache/cache_http.c
View file @
6e25bf69
...
@@ -1228,28 +1228,32 @@ http_ForceHeader(struct http *to, const char *hdr, const char *val)
...
@@ -1228,28 +1228,32 @@ http_ForceHeader(struct http *to, const char *hdr, const char *val)
void
void
http_PrintfHeader
(
struct
http
*
to
,
const
char
*
fmt
,
...)
http_PrintfHeader
(
struct
http
*
to
,
const
char
*
fmt
,
...)
{
{
va_list
ap
;
va_list
ap
,
ap2
;
unsigned
l
,
n
;
struct
vsb
vsb
[
1
];
size_t
sz
;
char
*
p
;
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
l
=
WS_ReserveAll
(
to
->
ws
);
va_start
(
ap
,
fmt
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
to
->
ws
->
f
,
l
,
fmt
,
ap
);
va_copy
(
ap2
,
ap
);
va_end
(
ap
);
if
(
n
+
1
>=
l
||
to
->
nhd
>=
to
->
shd
)
{
WS_VSB_new
(
vsb
,
to
->
ws
);
VSB_vprintf
(
vsb
,
fmt
,
ap
);
p
=
WS_VSB_finish
(
vsb
,
to
->
ws
,
&
sz
);
if
(
p
==
NULL
||
to
->
nhd
>=
to
->
shd
)
{
http_fail
(
to
);
http_fail
(
to
);
va_start
(
ap
,
fmt
);
VSLbv
(
to
->
vsl
,
SLT_LostHeader
,
fmt
,
ap2
);
VSLbv
(
to
->
vsl
,
SLT_LostHeader
,
fmt
,
ap
);
}
else
{
va_end
(
ap
);
to
->
hd
[
to
->
nhd
].
b
=
p
;
WS_Release
(
to
->
ws
,
0
);
to
->
hd
[
to
->
nhd
].
e
=
p
+
sz
;
return
;
}
to
->
hd
[
to
->
nhd
].
b
=
to
->
ws
->
f
;
to
->
hd
[
to
->
nhd
].
e
=
to
->
ws
->
f
+
n
;
to
->
hdf
[
to
->
nhd
]
=
0
;
to
->
hdf
[
to
->
nhd
]
=
0
;
WS_Release
(
to
->
ws
,
n
+
1
);
http_VSLH
(
to
,
to
->
nhd
);
http_VSLH
(
to
,
to
->
nhd
);
to
->
nhd
++
;
to
->
nhd
++
;
}
va_end
(
ap
);
va_end
(
ap2
);
}
}
void
void
...
...
bin/varnishd/cache/cache_vrt_filter.c
View file @
6e25bf69
...
@@ -248,30 +248,17 @@ typedef void filter_list_t(void *, struct vsb *vsb);
...
@@ -248,30 +248,17 @@ typedef void filter_list_t(void *, struct vsb *vsb);
static
const
char
*
static
const
char
*
filter_on_ws
(
struct
ws
*
ws
,
filter_list_t
*
func
,
void
*
arg
)
filter_on_ws
(
struct
ws
*
ws
,
filter_list_t
*
func
,
void
*
arg
)
{
{
unsigned
u
;
struct
vsb
vsb
[
1
];
struct
vsb
vsb
[
1
];
const
char
*
p
;
AN
(
func
);
AN
(
func
);
AN
(
arg
);
AN
(
arg
);
u
=
WS_ReserveAll
(
ws
);
WS_VSB_new
(
vsb
,
ws
);
if
(
u
==
0
)
{
WS_Release
(
ws
,
0
);
WS_MarkOverflow
(
ws
);
return
(
NULL
);
}
AN
(
VSB_new
(
vsb
,
ws
->
f
,
u
,
VSB_FIXEDLEN
));
func
(
arg
,
vsb
);
func
(
arg
,
vsb
);
if
(
VSB_finish
(
vsb
))
{
p
=
WS_VSB_finish
(
vsb
,
ws
,
NULL
);
WS_Release
(
ws
,
0
);
if
(
p
==
NULL
)
WS_MarkOverflow
(
ws
);
p
=
""
;
return
(
NULL
);
return
(
p
);
}
if
(
VSB_len
(
vsb
))
{
WS_Release
(
ws
,
VSB_len
(
vsb
)
+
1
);
return
(
VSB_data
(
vsb
)
+
1
);
}
WS_Release
(
ws
,
0
);
return
(
""
);
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
...
bin/varnishd/cache/cache_ws.c
View file @
6e25bf69
...
@@ -361,16 +361,14 @@ void
...
@@ -361,16 +361,14 @@ void
WS_VSB_new
(
struct
vsb
*
vsb
,
struct
ws
*
ws
)
WS_VSB_new
(
struct
vsb
*
vsb
,
struct
ws
*
ws
)
{
{
unsigned
u
;
unsigned
u
;
static
char
bogus
[
2
];
// Smallest possible vsb
WS_Assert
(
ws
);
WS_Assert
(
ws
);
u
=
WS_ReserveAll
(
ws
);
u
=
WS_ReserveAll
(
ws
);
if
(
WS_Overflowed
(
ws
)
||
u
<
2
)
{
if
(
WS_Overflowed
(
ws
)
||
u
<
2
)
/* Create a malloced-buffer VSB, and fail it up front */
AN
(
VSB_new
(
vsb
,
bogus
,
sizeof
bogus
,
0
));
AN
(
VSB_new
(
vsb
,
NULL
,
2
,
0
));
else
VSB_cat
(
vsb
,
"XXX"
);
}
else
{
AN
(
VSB_new
(
vsb
,
WS_Front
(
ws
),
u
,
0
));
AN
(
VSB_new
(
vsb
,
WS_Front
(
ws
),
u
,
0
));
}
}
}
char
*
char
*
...
...
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