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
05184e90
Commit
05184e90
authored
Jan 17, 2012
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups while waiting for tests
parent
0471b9bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
52 deletions
+60
-52
cache_center.c
bin/varnishd/cache/cache_center.c
+1
-1
cache_lck.c
bin/varnishd/cache/cache_lck.c
+1
-1
cache_response.c
bin/varnishd/cache/cache_response.c
+58
-50
No files found.
bin/varnishd/cache/cache_center.c
View file @
05184e90
...
@@ -1405,7 +1405,7 @@ DOT err_pipe [label="ERROR",shape=plaintext]
...
@@ -1405,7 +1405,7 @@ DOT err_pipe [label="ERROR",shape=plaintext]
*/
*/
static
int
static
int
cnt_pipe
(
struct
sess
*
sp
,
struct
worker
*
wrk
,
struct
req
*
req
)
cnt_pipe
(
struct
sess
*
sp
,
struct
worker
*
wrk
,
const
struct
req
*
req
)
{
{
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
...
...
bin/varnishd/cache/cache_lck.c
View file @
05184e90
...
@@ -107,7 +107,7 @@ Lck__Unlock(struct lock *lck, const char *p, const char *f, int l)
...
@@ -107,7 +107,7 @@ Lck__Unlock(struct lock *lck, const char *p, const char *f, int l)
* We hack it and fill it with zero bits, hoping for sane
* We hack it and fill it with zero bits, hoping for sane
* implementations of pthread.
* implementations of pthread.
* #endif
* #endif
*/
*/
memset
(
&
ilck
->
owner
,
0
,
sizeof
ilck
->
owner
);
memset
(
&
ilck
->
owner
,
0
,
sizeof
ilck
->
owner
);
AZ
(
pthread_mutex_unlock
(
&
ilck
->
mtx
));
AZ
(
pthread_mutex_unlock
(
&
ilck
->
mtx
));
if
(
cache_param
->
diag_bitmap
&
0x8
)
if
(
cache_param
->
diag_bitmap
&
0x8
)
...
...
bin/varnishd/cache/cache_response.c
View file @
05184e90
...
@@ -40,8 +40,11 @@ static void
...
@@ -40,8 +40,11 @@ static void
res_dorange
(
const
struct
sess
*
sp
,
const
char
*
r
,
ssize_t
*
plow
,
ssize_t
*
phigh
)
res_dorange
(
const
struct
sess
*
sp
,
const
char
*
r
,
ssize_t
*
plow
,
ssize_t
*
phigh
)
{
{
ssize_t
low
,
high
,
has_low
;
ssize_t
low
,
high
,
has_low
;
struct
req
*
req
;
assert
(
sp
->
req
->
obj
->
response
==
200
);
req
=
sp
->
req
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
assert
(
req
->
obj
->
response
==
200
);
if
(
strncmp
(
r
,
"bytes="
,
6
))
if
(
strncmp
(
r
,
"bytes="
,
6
))
return
;
return
;
r
+=
6
;
r
+=
6
;
...
@@ -57,7 +60,7 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
...
@@ -57,7 +60,7 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
r
++
;
r
++
;
}
}
if
(
low
>=
sp
->
req
->
obj
->
len
)
if
(
low
>=
req
->
obj
->
len
)
return
;
return
;
if
(
*
r
!=
'-'
)
if
(
*
r
!=
'-'
)
...
@@ -73,28 +76,28 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
...
@@ -73,28 +76,28 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
r
++
;
r
++
;
}
}
if
(
!
has_low
)
{
if
(
!
has_low
)
{
low
=
sp
->
req
->
obj
->
len
-
high
;
low
=
req
->
obj
->
len
-
high
;
high
=
sp
->
req
->
obj
->
len
-
1
;
high
=
req
->
obj
->
len
-
1
;
}
}
}
else
}
else
high
=
sp
->
req
->
obj
->
len
-
1
;
high
=
req
->
obj
->
len
-
1
;
if
(
*
r
!=
'\0'
)
if
(
*
r
!=
'\0'
)
return
;
return
;
if
(
high
>=
sp
->
req
->
obj
->
len
)
if
(
high
>=
req
->
obj
->
len
)
high
=
sp
->
req
->
obj
->
len
-
1
;
high
=
req
->
obj
->
len
-
1
;
if
(
low
>
high
)
if
(
low
>
high
)
return
;
return
;
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
"Content-Range: bytes %jd-%jd/%jd"
,
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
sp
->
req
->
obj
->
len
);
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
req
->
obj
->
len
);
http_Unset
(
sp
->
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
assert
(
sp
->
wrk
->
res_mode
&
RES_LEN
);
assert
(
sp
->
wrk
->
res_mode
&
RES_LEN
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Content-Length: %jd"
,
(
intmax_t
)(
1
+
high
-
low
));
"Content-Length: %jd"
,
(
intmax_t
)(
1
+
high
-
low
));
http_SetResp
(
sp
->
req
->
resp
,
"HTTP/1.1"
,
206
,
"Partial Content"
);
http_SetResp
(
req
->
resp
,
"HTTP/1.1"
,
206
,
"Partial Content"
);
*
plow
=
low
;
*
plow
=
low
;
*
phigh
=
high
;
*
phigh
=
high
;
...
@@ -106,44 +109,46 @@ void
...
@@ -106,44 +109,46 @@ void
RES_BuildHttp
(
const
struct
sess
*
sp
)
RES_BuildHttp
(
const
struct
sess
*
sp
)
{
{
char
time_str
[
30
];
char
time_str
[
30
];
struct
req
*
req
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
req
=
sp
->
req
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
http_ClrHeader
(
req
->
resp
);
http_ClrHeader
(
sp
->
req
->
resp
);
req
->
resp
->
logtag
=
HTTP_Tx
;
sp
->
req
->
resp
->
logtag
=
HTTP_Tx
;
http_CopyResp
(
req
->
resp
,
req
->
obj
->
http
);
http_CopyResp
(
sp
->
req
->
resp
,
sp
->
req
->
obj
->
http
);
http_FilterFields
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_FilterFields
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
req
->
obj
->
http
,
HTTPH_A_DELIVER
);
sp
->
req
->
obj
->
http
,
HTTPH_A_DELIVER
);
if
(
!
(
sp
->
wrk
->
res_mode
&
RES_LEN
))
{
if
(
!
(
sp
->
wrk
->
res_mode
&
RES_LEN
))
{
http_Unset
(
sp
->
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
}
else
if
(
cache_param
->
http_range_support
)
{
}
else
if
(
cache_param
->
http_range_support
)
{
/* We only accept ranges if we know the length */
/* We only accept ranges if we know the length */
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Accept-Ranges: bytes"
);
"Accept-Ranges: bytes"
);
}
}
if
(
sp
->
wrk
->
res_mode
&
RES_CHUNKED
)
if
(
sp
->
wrk
->
res_mode
&
RES_CHUNKED
)
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Transfer-Encoding: chunked"
);
"Transfer-Encoding: chunked"
);
VTIM_format
(
VTIM_real
(),
time_str
);
VTIM_format
(
VTIM_real
(),
time_str
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Date: %s"
,
time_str
);
"Date: %s"
,
time_str
);
if
(
sp
->
req
->
xid
!=
sp
->
req
->
obj
->
xid
)
if
(
req
->
xid
!=
req
->
obj
->
xid
)
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"X-Varnish: %u %u"
,
sp
->
req
->
xid
,
sp
->
req
->
obj
->
xid
);
"X-Varnish: %u %u"
,
req
->
xid
,
req
->
obj
->
xid
);
else
else
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"X-Varnish: %u"
,
sp
->
req
->
xid
);
"X-Varnish: %u"
,
req
->
xid
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
"Age: %.0f"
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Age: %.0f"
,
sp
->
req
->
obj
->
exp
.
age
+
sp
->
req
->
t_resp
-
req
->
obj
->
exp
.
age
+
req
->
t_resp
-
sp
->
req
->
obj
->
exp
.
entered
);
req
->
obj
->
exp
.
entered
);
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
"Via: 1.1 varnish"
);
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Via: 1.1 varnish"
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
"Connection: %s"
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Connection: %s"
,
sp
->
req
->
doclose
?
"close"
:
"keep-alive"
);
req
->
doclose
?
"close"
:
"keep-alive"
);
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
@@ -254,63 +259,66 @@ RES_WriteObj(struct sess *sp)
...
@@ -254,63 +259,66 @@ RES_WriteObj(struct sess *sp)
{
{
char
*
r
;
char
*
r
;
ssize_t
low
,
high
;
ssize_t
low
,
high
;
struct
req
*
req
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
req
=
sp
->
req
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
WRW_Reserve
(
sp
->
wrk
,
&
sp
->
fd
);
WRW_Reserve
(
sp
->
wrk
,
&
sp
->
fd
);
if
(
sp
->
req
->
obj
->
response
==
200
&&
if
(
req
->
obj
->
response
==
200
&&
sp
->
req
->
http
->
conds
&&
req
->
http
->
conds
&&
RFC2616_Do_Cond
(
sp
))
{
RFC2616_Do_Cond
(
sp
))
{
sp
->
req
->
wantbody
=
0
;
req
->
wantbody
=
0
;
http_SetResp
(
sp
->
req
->
resp
,
"HTTP/1.1"
,
304
,
"Not Modified"
);
http_SetResp
(
req
->
resp
,
"HTTP/1.1"
,
304
,
"Not Modified"
);
http_Unset
(
sp
->
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
http_Unset
(
sp
->
req
->
resp
,
H_Transfer_Encoding
);
http_Unset
(
req
->
resp
,
H_Transfer_Encoding
);
}
}
/*
/*
* If nothing special planned, we can attempt Range support
* If nothing special planned, we can attempt Range support
*/
*/
low
=
0
;
low
=
0
;
high
=
sp
->
req
->
obj
->
len
-
1
;
high
=
req
->
obj
->
len
-
1
;
if
(
if
(
sp
->
req
->
wantbody
&&
req
->
wantbody
&&
(
sp
->
wrk
->
res_mode
&
RES_LEN
)
&&
(
sp
->
wrk
->
res_mode
&
RES_LEN
)
&&
!
(
sp
->
wrk
->
res_mode
&
(
RES_ESI
|
RES_ESI_CHILD
|
RES_GUNZIP
))
&&
!
(
sp
->
wrk
->
res_mode
&
(
RES_ESI
|
RES_ESI_CHILD
|
RES_GUNZIP
))
&&
cache_param
->
http_range_support
&&
cache_param
->
http_range_support
&&
sp
->
req
->
obj
->
response
==
200
&&
req
->
obj
->
response
==
200
&&
http_GetHdr
(
sp
->
req
->
http
,
H_Range
,
&
r
))
http_GetHdr
(
req
->
http
,
H_Range
,
&
r
))
res_dorange
(
sp
,
r
,
&
low
,
&
high
);
res_dorange
(
sp
,
r
,
&
low
,
&
high
);
/*
/*
* Always remove C-E if client don't grok it
* Always remove C-E if client don't grok it
*/
*/
if
(
sp
->
wrk
->
res_mode
&
RES_GUNZIP
)
if
(
sp
->
wrk
->
res_mode
&
RES_GUNZIP
)
http_Unset
(
sp
->
req
->
resp
,
H_Content_Encoding
);
http_Unset
(
req
->
resp
,
H_Content_Encoding
);
/*
/*
* Send HTTP protocol header, unless interior ESI object
* Send HTTP protocol header, unless interior ESI object
*/
*/
if
(
!
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
))
if
(
!
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
))
sp
->
wrk
->
acct_tmp
.
hdrbytes
+=
sp
->
wrk
->
acct_tmp
.
hdrbytes
+=
http_Write
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
1
);
http_Write
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
1
);
if
(
!
sp
->
req
->
wantbody
)
if
(
!
req
->
wantbody
)
sp
->
wrk
->
res_mode
&=
~
RES_CHUNKED
;
sp
->
wrk
->
res_mode
&=
~
RES_CHUNKED
;
if
(
sp
->
wrk
->
res_mode
&
RES_CHUNKED
)
if
(
sp
->
wrk
->
res_mode
&
RES_CHUNKED
)
WRW_Chunked
(
sp
->
wrk
);
WRW_Chunked
(
sp
->
wrk
);
if
(
!
sp
->
req
->
wantbody
)
{
if
(
!
req
->
wantbody
)
{
/* This was a HEAD or conditional request */
/* This was a HEAD or conditional request */
}
else
if
(
sp
->
req
->
obj
->
len
==
0
)
{
}
else
if
(
req
->
obj
->
len
==
0
)
{
/* Nothing to do here */
/* Nothing to do here */
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI
)
{
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI
)
{
ESI_Deliver
(
sp
);
ESI_Deliver
(
sp
);
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
&&
sp
->
req
->
gzip_resp
)
{
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
&&
req
->
gzip_resp
)
{
ESI_DeliverChild
(
sp
);
ESI_DeliverChild
(
sp
);
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
&&
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_ESI_CHILD
&&
!
sp
->
req
->
gzip_resp
&&
sp
->
req
->
obj
->
gziped
)
{
!
req
->
gzip_resp
&&
req
->
obj
->
gziped
)
{
res_WriteGunzipObj
(
sp
);
res_WriteGunzipObj
(
sp
);
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_GUNZIP
)
{
}
else
if
(
sp
->
wrk
->
res_mode
&
RES_GUNZIP
)
{
res_WriteGunzipObj
(
sp
);
res_WriteGunzipObj
(
sp
);
...
...
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