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
5fa4368e
Commit
5fa4368e
authored
Aug 25, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make range processing log real messages rather than line numbers
parent
8796fa66
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
cache_range.c
bin/varnishd/cache/cache_range.c
+18
-18
No files found.
bin/varnishd/cache/cache_range.c
View file @
5fa4368e
...
@@ -85,14 +85,14 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv,
...
@@ -85,14 +85,14 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv,
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
int
static
const
char
*
vrg_dorange
(
struct
req
*
req
,
const
char
*
r
)
vrg_dorange
(
struct
req
*
req
,
const
char
*
r
)
{
{
ssize_t
low
,
high
,
has_low
,
has_high
,
t
;
ssize_t
low
,
high
,
has_low
,
has_high
,
t
;
struct
vrg_priv
*
vrg_priv
;
struct
vrg_priv
*
vrg_priv
;
if
(
strncasecmp
(
r
,
"bytes="
,
6
))
if
(
strncasecmp
(
r
,
"bytes="
,
6
))
return
(
__LINE__
);
return
(
"Not Bytes"
);
r
+=
6
;
r
+=
6
;
/* The low end of range */
/* The low end of range */
...
@@ -103,11 +103,11 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -103,11 +103,11 @@ vrg_dorange(struct req *req, const char *r)
low
*=
10
;
low
*=
10
;
low
+=
*
r
++
-
'0'
;
low
+=
*
r
++
-
'0'
;
if
(
low
<
t
)
if
(
low
<
t
)
return
(
__LINE__
);
return
(
"Low number too big"
);
}
}
if
(
*
r
++
!=
'-'
)
if
(
*
r
++
!=
'-'
)
return
(
__LINE__
);
return
(
"Missing hyphen"
);
/* The high end of range */
/* The high end of range */
has_high
=
high
=
0
;
has_high
=
high
=
0
;
...
@@ -117,20 +117,20 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -117,20 +117,20 @@ vrg_dorange(struct req *req, const char *r)
high
*=
10
;
high
*=
10
;
high
+=
*
r
++
-
'0'
;
high
+=
*
r
++
-
'0'
;
if
(
high
<
t
)
if
(
high
<
t
)
return
(
__LINE__
);
return
(
"High number too big"
);
}
}
if
(
*
r
!=
'\0'
)
if
(
*
r
!=
'\0'
)
return
(
__LINE__
);
return
(
"Trailing stuff"
);
if
(
has_high
+
has_low
==
0
)
if
(
has_high
+
has_low
==
0
)
return
(
__LINE__
);
return
(
"Neither high nor low"
);
if
(
!
has_low
)
{
if
(
!
has_low
)
{
if
(
req
->
resp_len
<
0
)
if
(
req
->
resp_len
<
0
)
return
(
0
);
// Allow 200 response
return
(
NULL
);
// Allow 200 response
if
(
high
==
0
)
if
(
high
==
0
)
return
(
__LINE__
);
return
(
"No low, high is zero"
);
low
=
req
->
resp_len
-
high
;
low
=
req
->
resp_len
-
high
;
if
(
low
<
0
)
if
(
low
<
0
)
low
=
0
;
low
=
0
;
...
@@ -138,7 +138,7 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -138,7 +138,7 @@ vrg_dorange(struct req *req, const char *r)
}
else
if
(
req
->
resp_len
>=
0
&&
(
high
>=
req
->
resp_len
||
!
has_high
))
}
else
if
(
req
->
resp_len
>=
0
&&
(
high
>=
req
->
resp_len
||
!
has_high
))
high
=
req
->
resp_len
-
1
;
high
=
req
->
resp_len
-
1
;
else
if
(
!
has_high
)
else
if
(
!
has_high
)
return
(
0
);
// Allow 200 response
return
(
NULL
);
// Allow 200 response
/*
/*
* else (bo != NULL) {
* else (bo != NULL) {
* We assume that the client knows what it's doing and trust
* We assume that the client knows what it's doing and trust
...
@@ -147,10 +147,10 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -147,10 +147,10 @@ vrg_dorange(struct req *req, const char *r)
*/
*/
if
(
high
<
low
)
if
(
high
<
low
)
return
(
__LINE__
);
return
(
"high smaller than low"
);
if
(
req
->
resp_len
>=
0
&&
low
>=
req
->
resp_len
)
if
(
req
->
resp_len
>=
0
&&
low
>=
req
->
resp_len
)
return
(
__LINE__
);
return
(
"low range beyond object"
);
if
(
req
->
resp_len
>=
0
)
if
(
req
->
resp_len
>=
0
)
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
...
@@ -162,7 +162,7 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -162,7 +162,7 @@ vrg_dorange(struct req *req, const char *r)
vrg_priv
=
WS_Alloc
(
req
->
ws
,
sizeof
*
vrg_priv
);
vrg_priv
=
WS_Alloc
(
req
->
ws
,
sizeof
*
vrg_priv
);
if
(
vrg_priv
==
NULL
)
if
(
vrg_priv
==
NULL
)
return
(
-
1
);
return
(
"WS too small"
);
XXXAN
(
vrg_priv
);
XXXAN
(
vrg_priv
);
INIT_OBJ
(
vrg_priv
,
VRG_PRIV_MAGIC
);
INIT_OBJ
(
vrg_priv
,
VRG_PRIV_MAGIC
);
...
@@ -171,13 +171,13 @@ vrg_dorange(struct req *req, const char *r)
...
@@ -171,13 +171,13 @@ vrg_dorange(struct req *req, const char *r)
vrg_priv
->
range_high
=
high
+
1
;
vrg_priv
->
range_high
=
high
+
1
;
VDP_push
(
req
,
vrg_range_bytes
,
vrg_priv
,
1
);
VDP_push
(
req
,
vrg_range_bytes
,
vrg_priv
,
1
);
http_PutResponse
(
req
->
resp
,
"HTTP/1.1"
,
206
,
NULL
);
http_PutResponse
(
req
->
resp
,
"HTTP/1.1"
,
206
,
NULL
);
return
(
0
);
return
(
NULL
);
}
}
void
void
VRG_dorange
(
struct
req
*
req
,
const
char
*
r
)
VRG_dorange
(
struct
req
*
req
,
const
char
*
r
)
{
{
int
i
;
const
char
*
err
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
->
objcore
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
->
objcore
,
OBJCORE_MAGIC
);
...
@@ -185,9 +185,9 @@ VRG_dorange(struct req *req, const char *r)
...
@@ -185,9 +185,9 @@ VRG_dorange(struct req *req, const char *r)
/* We must snapshot the length if we're streaming from the backend */
/* We must snapshot the length if we're streaming from the backend */
i
=
vrg_dorange
(
req
,
r
);
err
=
vrg_dorange
(
req
,
r
);
if
(
i
>
0
)
{
if
(
err
!=
NULL
)
{
VSLb
(
req
->
vsl
,
SLT_Debug
,
"RANGE_FAIL
line %d"
,
i
);
VSLb
(
req
->
vsl
,
SLT_Debug
,
"RANGE_FAIL
%s"
,
err
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
if
(
req
->
resp_len
>=
0
)
if
(
req
->
resp_len
>=
0
)
http_PrintfHeader
(
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
...
...
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