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
4fe2ad4a
Commit
4fe2ad4a
authored
Jan 28, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a WS_Printf() function and use it.
Other minor polish around workspaces.
parent
6df57da0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
27 deletions
+38
-27
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_http.c
bin/varnishd/cache/cache_http.c
+2
-5
cache_http1_proto.c
bin/varnishd/cache/cache_http1_proto.c
+1
-0
cache_panic.c
bin/varnishd/cache/cache_panic.c
+4
-3
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+2
-12
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+3
-7
cache_ws.c
bin/varnishd/cache/cache_ws.c
+25
-0
No files found.
bin/varnishd/cache/cache.h
View file @
4fe2ad4a
...
...
@@ -1197,6 +1197,7 @@ char *WS_Alloc(struct ws *ws, unsigned bytes);
void
*
WS_Copy
(
struct
ws
*
ws
,
const
void
*
str
,
int
len
);
char
*
WS_Snapshot
(
struct
ws
*
ws
);
int
WS_Overflowed
(
const
struct
ws
*
ws
);
void
*
WS_Printf
(
struct
ws
*
ws
,
const
char
*
fmt
,
...)
__printflike
(
2
,
3
);
/* rfc2616.c */
void
RFC2616_Ttl
(
struct
busyobj
*
);
...
...
bin/varnishd/cache/cache_http.c
View file @
4fe2ad4a
...
...
@@ -718,20 +718,17 @@ static void
http_PutField
(
const
struct
http
*
to
,
int
field
,
const
char
*
string
)
{
char
*
p
;
unsigned
l
;
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
l
=
strlen
(
string
);
p
=
WS_Alloc
(
to
->
ws
,
l
+
1
);
p
=
WS_Copy
(
to
->
ws
,
string
,
-
1
);
if
(
p
==
NULL
)
{
VSLb
(
to
->
vsl
,
SLT_LostHeader
,
"%s"
,
string
);
to
->
hd
[
field
].
b
=
NULL
;
to
->
hd
[
field
].
e
=
NULL
;
to
->
hdf
[
field
]
=
0
;
}
else
{
memcpy
(
p
,
string
,
l
+
1L
);
to
->
hd
[
field
].
b
=
p
;
to
->
hd
[
field
].
e
=
p
+
l
;
to
->
hd
[
field
].
e
=
strchr
(
p
,
'\0'
)
;
to
->
hdf
[
field
]
=
0
;
http_VSLH
(
to
,
field
);
}
...
...
bin/varnishd/cache/cache_http1_proto.c
View file @
4fe2ad4a
...
...
@@ -517,6 +517,7 @@ HTTP1_Write(const struct worker *w, const struct http *hp, int resp)
hp
->
hd
[
HTTP_HDR_STATUS
].
b
=
WS_Alloc
(
hp
->
ws
,
4
);
AN
(
hp
->
hd
[
HTTP_HDR_STATUS
].
b
);
assert
(
hp
->
status
>=
100
&&
hp
->
status
<=
999
);
sprintf
(
hp
->
hd
[
HTTP_HDR_STATUS
].
b
,
"%3d"
,
hp
->
status
);
hp
->
hd
[
HTTP_HDR_STATUS
].
e
=
hp
->
hd
[
HTTP_HDR_STATUS
].
b
+
3
;
...
...
bin/varnishd/cache/cache_panic.c
View file @
4fe2ad4a
...
...
@@ -109,7 +109,10 @@ pan_ws(const struct ws *ws, int indent)
{
VSB_printf
(
pan_vsp
,
"%*sws = %p {"
,
indent
,
""
,
ws
);
if
(
VALID_OBJ
(
ws
,
WS_MAGIC
))
{
if
(
!
VALID_OBJ
(
ws
,
WS_MAGIC
))
{
if
(
ws
!=
NULL
)
VSB_printf
(
pan_vsp
,
" BAD_MAGIC(0x%08x) "
,
ws
->
magic
);
}
else
{
if
(
WS_Overflowed
(
ws
))
VSB_printf
(
pan_vsp
,
" OVERFLOW"
);
VSB_printf
(
pan_vsp
,
...
...
@@ -128,8 +131,6 @@ pan_ws(const struct ws *ws, int indent)
VSB_printf
(
pan_vsp
,
",+%ld"
,
(
long
)
(
ws
->
e
-
ws
->
s
));
else
VSB_printf
(
pan_vsp
,
",%p"
,
ws
->
e
);
}
else
{
VSB_printf
(
pan_vsp
,
" BAD_MAGIC(0x%08x) "
,
ws
->
magic
);
}
VSB_printf
(
pan_vsp
,
"},
\n
"
);
VSB_printf
(
pan_vsp
,
"%*s},
\n
"
,
indent
,
""
);
...
...
bin/varnishd/cache/cache_vrt.c
View file @
4fe2ad4a
...
...
@@ -313,27 +313,17 @@ VRT_IP_string(const struct vrt_ctx *ctx, VCL_IP ip)
char
*
VRT_INT_string
(
const
struct
vrt_ctx
*
ctx
,
long
num
)
{
char
*
p
;
int
size
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
size
=
snprintf
(
NULL
,
0
,
"%ld"
,
num
)
+
1
;
AN
(
p
=
WS_Alloc
(
ctx
->
ws
,
size
));
assert
(
snprintf
(
p
,
size
,
"%ld"
,
num
)
<
size
);
return
(
p
);
return
(
WS_Printf
(
ctx
->
ws
,
"%ld"
,
num
));
}
char
*
VRT_REAL_string
(
const
struct
vrt_ctx
*
ctx
,
double
num
)
{
char
*
p
;
int
size
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
size
=
snprintf
(
NULL
,
0
,
"%.3f"
,
num
)
+
1
;
AN
(
p
=
WS_Alloc
(
ctx
->
ws
,
size
));
assert
(
snprintf
(
p
,
size
,
"%.3f"
,
num
)
<
size
);
return
(
p
);
return
(
WS_Printf
(
ctx
->
ws
,
"%.3f"
,
num
));
}
char
*
...
...
bin/varnishd/cache/cache_vrt_var.c
View file @
4fe2ad4a
...
...
@@ -471,16 +471,12 @@ VRT_DO_EXP(beresp, ctx->bo->exp, keep, 0, ctx->bo->exp.t_origin,)
const
char
*
VRT_r_req_xid
(
const
struct
vrt_ctx
*
ctx
)
{
char
*
p
;
int
size
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
// XXX ?
size
=
snprintf
(
NULL
,
0
,
"%u"
,
ctx
->
req
->
vsl
->
wid
&
VSL_IDENTMASK
)
+
1
;
AN
(
p
=
WS_Alloc
(
ctx
->
req
->
http
->
ws
,
size
));
assert
(
snprintf
(
p
,
size
,
"%u"
,
ctx
->
req
->
vsl
->
wid
&
VSL_IDENTMASK
)
<
size
);
return
(
p
);
return
(
WS_Printf
(
ctx
->
req
->
http
->
ws
,
"%u"
,
ctx
->
req
->
vsl
->
wid
&
VSL_IDENTMASK
));
}
/*--------------------------------------------------------------------*/
...
...
bin/varnishd/cache/cache_ws.c
View file @
4fe2ad4a
...
...
@@ -30,6 +30,9 @@
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include "cache.h"
void
...
...
@@ -159,6 +162,28 @@ WS_Copy(struct ws *ws, const void *str, int len)
return
(
r
);
}
void
*
WS_Printf
(
struct
ws
*
ws
,
const
char
*
fmt
,
...)
{
unsigned
u
,
v
;
va_list
ap
;
char
*
p
;
WS_Assert
(
ws
);
assert
(
ws
->
r
==
NULL
);
u
=
WS_Reserve
(
ws
,
0
);
p
=
ws
->
f
;
va_start
(
ap
,
fmt
);
v
=
vsnprintf
(
p
,
u
,
fmt
,
ap
);
if
(
v
>
u
)
{
WS_Release
(
ws
,
0
);
p
=
NULL
;
}
else
{
WS_Release
(
ws
,
v
);
}
return
(
p
);
}
char
*
WS_Snapshot
(
struct
ws
*
ws
)
{
...
...
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