Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
e9e3e2e8
Commit
e9e3e2e8
authored
Feb 14, 2012
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate a lot of arguments to http_ functions which used to convey
the VSL coords which are now a property of struct http.
parent
f7dbf53e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
80 deletions
+58
-80
cache.h
bin/varnishd/cache/cache.h
+7
-11
cache_backend.c
bin/varnishd/cache/cache_backend.c
+2
-4
cache_center.c
bin/varnishd/cache/cache_center.c
+10
-14
cache_esi_deliver.c
bin/varnishd/cache/cache_esi_deliver.c
+1
-1
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+10
-11
cache_http.c
bin/varnishd/cache/cache_http.c
+13
-19
cache_response.c
bin/varnishd/cache/cache_response.c
+12
-17
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+2
-2
flint.lnt
bin/varnishd/flint.lnt
+1
-1
No files found.
bin/varnishd/cache/cache.h
View file @
e9e3e2e8
...
@@ -691,7 +691,7 @@ struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
...
@@ -691,7 +691,7 @@ struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
int
VDI_Healthy
(
const
struct
director
*
,
const
struct
sess
*
sp
);
int
VDI_Healthy
(
const
struct
director
*
,
const
struct
sess
*
sp
);
void
VDI_CloseFd
(
struct
worker
*
wrk
,
struct
vbc
**
vbp
);
void
VDI_CloseFd
(
struct
worker
*
wrk
,
struct
vbc
**
vbp
);
void
VDI_RecycleFd
(
struct
worker
*
wrk
,
struct
vbc
**
vbp
);
void
VDI_RecycleFd
(
struct
worker
*
wrk
,
struct
vbc
**
vbp
);
void
VDI_AddHostHeader
(
struct
worker
*
wrk
,
const
struct
vbc
*
vbc
);
void
VDI_AddHostHeader
(
struct
http
*
to
,
const
struct
vbc
*
vbc
);
void
VBE_Poll
(
void
);
void
VBE_Poll
(
void
);
void
VDI_Init
(
void
);
void
VDI_Init
(
void
);
...
@@ -804,16 +804,12 @@ void http_SetResp(struct http *to, const char *proto, uint16_t status,
...
@@ -804,16 +804,12 @@ void http_SetResp(struct http *to, const char *proto, uint16_t status,
const
char
*
response
);
const
char
*
response
);
void
http_FilterReq
(
const
struct
sess
*
sp
,
unsigned
how
);
void
http_FilterReq
(
const
struct
sess
*
sp
,
unsigned
how
);
void
http_FilterResp
(
const
struct
http
*
fm
,
struct
http
*
to
,
unsigned
how
);
void
http_FilterResp
(
const
struct
http
*
fm
,
struct
http
*
to
,
unsigned
how
);
void
http_PutProtocol
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
to
,
void
http_PutProtocol
(
const
struct
http
*
to
,
const
char
*
protocol
);
const
char
*
protocol
);
void
http_PutStatus
(
struct
http
*
to
,
uint16_t
status
);
void
http_PutStatus
(
struct
http
*
to
,
uint16_t
status
);
void
http_PutResponse
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
to
,
void
http_PutResponse
(
const
struct
http
*
to
,
const
char
*
response
);
const
char
*
response
);
void
http_PrintfHeader
(
struct
http
*
to
,
const
char
*
fmt
,
...)
void
http_PrintfHeader
(
struct
worker
*
w
,
unsigned
vsl_id
,
struct
http
*
to
,
__printflike
(
2
,
3
);
const
char
*
fmt
,
...)
void
http_SetHeader
(
struct
http
*
to
,
const
char
*
hdr
);
__printflike
(
4
,
5
);
void
http_SetHeader
(
struct
worker
*
w
,
unsigned
vsl_id
,
struct
http
*
to
,
const
char
*
hdr
);
void
http_SetH
(
const
struct
http
*
to
,
unsigned
n
,
const
char
*
fm
);
void
http_SetH
(
const
struct
http
*
to
,
unsigned
n
,
const
char
*
fm
);
void
http_ForceGet
(
const
struct
http
*
to
);
void
http_ForceGet
(
const
struct
http
*
to
);
void
http_Setup
(
struct
http
*
ht
,
struct
ws
*
ws
,
struct
vsl_log
*
);
void
http_Setup
(
struct
http
*
ht
,
struct
ws
*
ws
,
struct
vsl_log
*
);
...
@@ -830,7 +826,7 @@ int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
...
@@ -830,7 +826,7 @@ int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
uint16_t
http_DissectRequest
(
const
struct
sess
*
sp
);
uint16_t
http_DissectRequest
(
const
struct
sess
*
sp
);
uint16_t
http_DissectResponse
(
struct
http
*
sp
,
const
struct
http_conn
*
htc
);
uint16_t
http_DissectResponse
(
struct
http
*
sp
,
const
struct
http_conn
*
htc
);
const
char
*
http_DoConnection
(
const
struct
http
*
hp
);
const
char
*
http_DoConnection
(
const
struct
http
*
hp
);
void
http_CopyHome
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
hp
);
void
http_CopyHome
(
const
struct
http
*
hp
);
void
http_Unset
(
struct
http
*
hp
,
const
char
*
hdr
);
void
http_Unset
(
struct
http
*
hp
,
const
char
*
hdr
);
void
http_CollectHdr
(
struct
http
*
hp
,
const
char
*
hdr
);
void
http_CollectHdr
(
struct
http
*
hp
,
const
char
*
hdr
);
...
...
bin/varnishd/cache/cache_backend.c
View file @
e9e3e2e8
...
@@ -65,14 +65,12 @@ struct vdi_simple {
...
@@ -65,14 +65,12 @@ struct vdi_simple {
* Create default Host: header for backend request
* Create default Host: header for backend request
*/
*/
void
void
VDI_AddHostHeader
(
struct
worker
*
wrk
,
const
struct
vbc
*
vbc
)
VDI_AddHostHeader
(
struct
http
*
hp
,
const
struct
vbc
*
vbc
)
{
{
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
->
busyobj
->
bereq
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
vbc
,
VBC_MAGIC
);
CHECK_OBJ_NOTNULL
(
vbc
,
VBC_MAGIC
);
CHECK_OBJ_NOTNULL
(
vbc
->
vdis
,
VDI_SIMPLE_MAGIC
);
CHECK_OBJ_NOTNULL
(
vbc
->
vdis
,
VDI_SIMPLE_MAGIC
);
http_PrintfHeader
(
wrk
,
vbc
->
vsl_id
,
wrk
->
busyobj
->
bereq
,
http_PrintfHeader
(
hp
,
"Host: %s"
,
vbc
->
vdis
->
vrt
->
hosthdr
);
"Host: %s"
,
vbc
->
vdis
->
vrt
->
hosthdr
);
}
}
...
...
bin/varnishd/cache/cache_center.c
View file @
e9e3e2e8
...
@@ -501,17 +501,16 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -501,17 +501,16 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
if
(
req
->
err_code
<
100
||
req
->
err_code
>
999
)
if
(
req
->
err_code
<
100
||
req
->
err_code
>
999
)
req
->
err_code
=
501
;
req
->
err_code
=
501
;
http_PutProtocol
(
wrk
,
sp
->
vsl_id
,
h
,
"HTTP/1.1"
);
http_PutProtocol
(
h
,
"HTTP/1.1"
);
http_PutStatus
(
h
,
req
->
err_code
);
http_PutStatus
(
h
,
req
->
err_code
);
VTIM_format
(
W_TIM_real
(
wrk
),
date
);
VTIM_format
(
W_TIM_real
(
wrk
),
date
);
http_PrintfHeader
(
wrk
,
sp
->
vsl_id
,
h
,
"Date: %s"
,
date
);
http_PrintfHeader
(
h
,
"Date: %s"
,
date
);
http_SetHeader
(
wrk
,
sp
->
vsl_id
,
h
,
"Server: Varnish"
);
http_SetHeader
(
h
,
"Server: Varnish"
);
if
(
req
->
err_reason
!=
NULL
)
if
(
req
->
err_reason
!=
NULL
)
http_PutResponse
(
wrk
,
sp
->
vsl_id
,
h
,
req
->
err_reason
);
http_PutResponse
(
h
,
req
->
err_reason
);
else
else
http_PutResponse
(
wrk
,
sp
->
vsl_id
,
h
,
http_PutResponse
(
h
,
http_StatusMessage
(
req
->
err_code
));
http_StatusMessage
(
req
->
err_code
));
VCL_error_method
(
sp
);
VCL_error_method
(
sp
);
if
(
req
->
handling
==
VCL_RET_RESTART
&&
if
(
req
->
handling
==
VCL_RET_RESTART
&&
...
@@ -745,8 +744,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -745,8 +744,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
/* If we do gzip, add the C-E header */
/* If we do gzip, add the C-E header */
if
(
bo
->
do_gzip
)
if
(
bo
->
do_gzip
)
http_SetHeader
(
wrk
,
sp
->
vsl_id
,
bo
->
beresp
,
http_SetHeader
(
bo
->
beresp
,
"Content-Encoding: gzip"
);
"Content-Encoding: gzip"
);
/* But we can't do both at the same time */
/* But we can't do both at the same time */
assert
(
bo
->
do_gzip
==
0
||
bo
->
do_gunzip
==
0
);
assert
(
bo
->
do_gzip
==
0
||
bo
->
do_gunzip
==
0
);
...
@@ -839,7 +837,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -839,7 +837,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
hp2
->
logtag
=
HTTP_Obj
;
hp2
->
logtag
=
HTTP_Obj
;
http_FilterResp
(
hp
,
hp2
,
pass
?
HTTPH_R_PASS
:
HTTPH_A_INS
);
http_FilterResp
(
hp
,
hp2
,
pass
?
HTTPH_R_PASS
:
HTTPH_A_INS
);
http_CopyHome
(
wrk
,
sp
->
vsl_id
,
hp2
);
http_CopyHome
(
hp2
);
if
(
http_GetHdr
(
hp
,
H_Last_Modified
,
&
b
))
if
(
http_GetHdr
(
hp
,
H_Last_Modified
,
&
b
))
req
->
obj
->
last_modified
=
VTIM_parse
(
b
);
req
->
obj
->
last_modified
=
VTIM_parse
(
b
);
...
@@ -1233,8 +1231,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -1233,8 +1231,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
* the minority of clients which don't.
* the minority of clients which don't.
*/
*/
http_Unset
(
wrk
->
busyobj
->
bereq
,
H_Accept_Encoding
);
http_Unset
(
wrk
->
busyobj
->
bereq
,
H_Accept_Encoding
);
http_SetHeader
(
wrk
,
sp
->
vsl_id
,
wrk
->
busyobj
->
bereq
,
http_SetHeader
(
wrk
->
busyobj
->
bereq
,
"Accept-Encoding: gzip"
);
"Accept-Encoding: gzip"
);
}
}
VCL_miss_method
(
sp
);
VCL_miss_method
(
sp
);
...
@@ -1400,7 +1397,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green]
...
@@ -1400,7 +1397,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green]
*/
*/
static
int
static
int
cnt_recv
(
struct
sess
*
sp
,
struct
worker
*
wrk
,
struct
req
*
req
)
cnt_recv
(
struct
sess
*
sp
,
const
struct
worker
*
wrk
,
struct
req
*
req
)
{
{
unsigned
recv_handling
;
unsigned
recv_handling
;
struct
SHA256Context
sha256ctx
;
struct
SHA256Context
sha256ctx
;
...
@@ -1444,8 +1441,7 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -1444,8 +1441,7 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
(
recv_handling
!=
VCL_RET_PASS
))
{
(
recv_handling
!=
VCL_RET_PASS
))
{
if
(
RFC2616_Req_Gzip
(
sp
))
{
if
(
RFC2616_Req_Gzip
(
sp
))
{
http_Unset
(
req
->
http
,
H_Accept_Encoding
);
http_Unset
(
req
->
http
,
H_Accept_Encoding
);
http_SetHeader
(
wrk
,
sp
->
vsl_id
,
req
->
http
,
http_SetHeader
(
req
->
http
,
"Accept-Encoding: gzip"
);
"Accept-Encoding: gzip"
);
}
else
{
}
else
{
http_Unset
(
req
->
http
,
H_Accept_Encoding
);
http_Unset
(
req
->
http
,
H_Accept_Encoding
);
}
}
...
...
bin/varnishd/cache/cache_esi_deliver.c
View file @
e9e3e2e8
...
@@ -73,7 +73,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
...
@@ -73,7 +73,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
if
(
host
!=
NULL
&&
*
host
!=
'\0'
)
{
if
(
host
!=
NULL
&&
*
host
!=
'\0'
)
{
http_Unset
(
sp
->
req
->
http
,
H_Host
);
http_Unset
(
sp
->
req
->
http
,
H_Host
);
http_Unset
(
sp
->
req
->
http
,
H_If_Modified_Since
);
http_Unset
(
sp
->
req
->
http
,
H_If_Modified_Since
);
http_SetHeader
(
w
,
sp
->
vsl_id
,
sp
->
req
->
http
,
host
);
http_SetHeader
(
sp
->
req
->
http
,
host
);
}
}
/*
/*
* XXX: We should decide if we should cache the director
* XXX: We should decide if we should cache the director
...
...
bin/varnishd/cache/cache_fetch.c
View file @
e9e3e2e8
...
@@ -393,8 +393,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -393,8 +393,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
struct
http_conn
*
htc
;
struct
http_conn
*
htc
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
->
wrk
,
WORKER_MAGIC
);
wrk
=
sp
->
wrk
;
wrk
=
sp
->
wrk
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
->
busyobj
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
->
busyobj
,
BUSYOBJ_MAGIC
);
htc
=
&
wrk
->
busyobj
->
htc
;
htc
=
&
wrk
->
busyobj
->
htc
;
...
@@ -408,12 +408,12 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -408,12 +408,12 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
hp
=
wrk
->
busyobj
->
bereq
;
hp
=
wrk
->
busyobj
->
bereq
;
sp
->
wrk
->
busyobj
->
vbc
=
VDI_GetFd
(
NULL
,
sp
);
wrk
->
busyobj
->
vbc
=
VDI_GetFd
(
NULL
,
sp
);
if
(
sp
->
wrk
->
busyobj
->
vbc
==
NULL
)
{
if
(
wrk
->
busyobj
->
vbc
==
NULL
)
{
WSP
(
sp
,
SLT_FetchError
,
"no backend connection"
);
WSP
(
sp
,
SLT_FetchError
,
"no backend connection"
);
return
(
-
1
);
return
(
-
1
);
}
}
vc
=
sp
->
wrk
->
busyobj
->
vbc
;
vc
=
wrk
->
busyobj
->
vbc
;
if
(
vc
->
recycled
)
if
(
vc
->
recycled
)
retry
=
1
;
retry
=
1
;
...
@@ -423,7 +423,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -423,7 +423,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
* because the backend may be chosen by a director.
* because the backend may be chosen by a director.
*/
*/
if
(
need_host_hdr
)
if
(
need_host_hdr
)
VDI_AddHostHeader
(
sp
->
wrk
,
vc
);
VDI_AddHostHeader
(
wrk
->
busyobj
->
bereq
,
vc
);
(
void
)
VTCP_blocking
(
vc
->
fd
);
/* XXX: we should timeout instead */
(
void
)
VTCP_blocking
(
vc
->
fd
);
/* XXX: we should timeout instead */
WRW_Reserve
(
wrk
,
&
vc
->
fd
);
WRW_Reserve
(
wrk
,
&
vc
->
fd
);
...
@@ -434,7 +434,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -434,7 +434,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if
(
WRW_FlushRelease
(
wrk
)
||
i
>
0
)
{
if
(
WRW_FlushRelease
(
wrk
)
||
i
>
0
)
{
WSP
(
sp
,
SLT_FetchError
,
"backend write error: %d (%s)"
,
WSP
(
sp
,
SLT_FetchError
,
"backend write error: %d (%s)"
,
errno
,
strerror
(
errno
));
errno
,
strerror
(
errno
));
VDI_CloseFd
(
sp
->
wrk
,
&
sp
->
wrk
->
busyobj
->
vbc
);
VDI_CloseFd
(
wrk
,
&
wrk
->
busyobj
->
vbc
);
/* XXX: other cleanup ? */
/* XXX: other cleanup ? */
return
(
retry
);
return
(
retry
);
}
}
...
@@ -458,7 +458,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -458,7 +458,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if
(
i
<
0
)
{
if
(
i
<
0
)
{
WSP
(
sp
,
SLT_FetchError
,
"http first read error: %d %d (%s)"
,
WSP
(
sp
,
SLT_FetchError
,
"http first read error: %d %d (%s)"
,
i
,
errno
,
strerror
(
errno
));
i
,
errno
,
strerror
(
errno
));
VDI_CloseFd
(
sp
->
wrk
,
&
sp
->
wrk
->
busyobj
->
vbc
);
VDI_CloseFd
(
wrk
,
&
wrk
->
busyobj
->
vbc
);
/* XXX: other cleanup ? */
/* XXX: other cleanup ? */
/* Retryable if we never received anything */
/* Retryable if we never received anything */
return
(
i
==
-
1
?
retry
:
-
1
);
return
(
i
==
-
1
?
retry
:
-
1
);
...
@@ -472,7 +472,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -472,7 +472,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
WSP
(
sp
,
SLT_FetchError
,
WSP
(
sp
,
SLT_FetchError
,
"http first read error: %d %d (%s)"
,
"http first read error: %d %d (%s)"
,
i
,
errno
,
strerror
(
errno
));
i
,
errno
,
strerror
(
errno
));
VDI_CloseFd
(
sp
->
wrk
,
&
sp
->
wrk
->
busyobj
->
vbc
);
VDI_CloseFd
(
wrk
,
&
wrk
->
busyobj
->
vbc
);
/* XXX: other cleanup ? */
/* XXX: other cleanup ? */
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -482,7 +482,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
...
@@ -482,7 +482,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if
(
http_DissectResponse
(
hp
,
htc
))
{
if
(
http_DissectResponse
(
hp
,
htc
))
{
WSP
(
sp
,
SLT_FetchError
,
"http format error"
);
WSP
(
sp
,
SLT_FetchError
,
"http format error"
);
VDI_CloseFd
(
sp
->
wrk
,
&
sp
->
wrk
->
busyobj
->
vbc
);
VDI_CloseFd
(
wrk
,
&
wrk
->
busyobj
->
vbc
);
/* XXX: other cleanup ? */
/* XXX: other cleanup ? */
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -614,8 +614,7 @@ FetchBody(struct worker *wrk, struct object *obj)
...
@@ -614,8 +614,7 @@ FetchBody(struct worker *wrk, struct object *obj)
if
(
mklen
>
0
)
{
if
(
mklen
>
0
)
{
http_Unset
(
obj
->
http
,
H_Content_Length
);
http_Unset
(
obj
->
http
,
H_Content_Length
);
http_PrintfHeader
(
wrk
,
bo
->
vbc
->
vsl_id
,
obj
->
http
,
http_PrintfHeader
(
obj
->
http
,
"Content-Length: %zd"
,
obj
->
len
);
"Content-Length: %zd"
,
obj
->
len
);
}
}
if
(
cls
)
if
(
cls
)
...
...
bin/varnishd/cache/cache_http.c
View file @
e9e3e2e8
...
@@ -865,8 +865,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
...
@@ -865,8 +865,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
else
else
http_linkh
(
hp
,
sp
->
req
->
http
,
HTTP_HDR_PROTO
);
http_linkh
(
hp
,
sp
->
req
->
http
,
HTTP_HDR_PROTO
);
http_filterfields
(
hp
,
sp
->
req
->
http
,
how
);
http_filterfields
(
hp
,
sp
->
req
->
http
,
how
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
hp
,
http_PrintfHeader
(
hp
,
"X-Varnish: %u"
,
sp
->
req
->
xid
);
"X-Varnish: %u"
,
sp
->
req
->
xid
);
}
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
...
@@ -889,7 +888,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
...
@@ -889,7 +888,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
*/
*/
void
void
http_CopyHome
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
hp
)
http_CopyHome
(
const
struct
http
*
hp
)
{
{
unsigned
u
,
l
;
unsigned
u
,
l
;
char
*
p
;
char
*
p
;
...
@@ -911,7 +910,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
...
@@ -911,7 +910,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
}
else
{
}
else
{
/* XXX This leaves a slot empty */
/* XXX This leaves a slot empty */
VSC_C_main
->
losthdr
++
;
VSC_C_main
->
losthdr
++
;
WSLR
(
w
->
vsl
,
SLT_LostHeader
,
vsl_id
,
hp
->
hd
[
u
]);
WSLR
(
hp
->
vsl
,
SLT_LostHeader
,
-
1
,
hp
->
hd
[
u
]);
hp
->
hd
[
u
].
b
=
NULL
;
hp
->
hd
[
u
].
b
=
NULL
;
hp
->
hd
[
u
].
e
=
NULL
;
hp
->
hd
[
u
].
e
=
NULL
;
}
}
...
@@ -935,14 +934,13 @@ http_ClrHeader(struct http *to)
...
@@ -935,14 +934,13 @@ http_ClrHeader(struct http *to)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
void
void
http_SetHeader
(
struct
worker
*
w
,
unsigned
vsl_id
,
struct
http
*
to
,
http_SetHeader
(
struct
http
*
to
,
const
char
*
hdr
)
const
char
*
hdr
)
{
{
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
to
,
HTTP_MAGIC
);
if
(
to
->
nhd
>=
to
->
shd
)
{
if
(
to
->
nhd
>=
to
->
shd
)
{
VSC_C_main
->
losthdr
++
;
VSC_C_main
->
losthdr
++
;
WSL
(
w
->
vsl
,
SLT_LostHeader
,
vsl_id
,
"%s"
,
hdr
);
WSL
(
to
->
vsl
,
SLT_LostHeader
,
-
1
,
"%s"
,
hdr
);
return
;
return
;
}
}
http_SetH
(
to
,
to
->
nhd
++
,
hdr
);
http_SetH
(
to
,
to
->
nhd
++
,
hdr
);
...
@@ -951,8 +949,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
...
@@ -951,8 +949,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
http_PutField
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
to
,
http_PutField
(
const
struct
http
*
to
,
int
field
,
const
char
*
string
)
int
field
,
const
char
*
string
)
{
{
char
*
p
;
char
*
p
;
unsigned
l
;
unsigned
l
;
...
@@ -961,7 +958,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
...
@@ -961,7 +958,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
l
=
strlen
(
string
);
l
=
strlen
(
string
);
p
=
WS_Alloc
(
to
->
ws
,
l
+
1
);
p
=
WS_Alloc
(
to
->
ws
,
l
+
1
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
WSL
(
w
->
vsl
,
SLT_LostHeader
,
vsl_id
,
"%s"
,
string
);
WSL
(
to
->
vsl
,
SLT_LostHeader
,
-
1
,
"%s"
,
string
);
to
->
hd
[
field
].
b
=
NULL
;
to
->
hd
[
field
].
b
=
NULL
;
to
->
hd
[
field
].
e
=
NULL
;
to
->
hd
[
field
].
e
=
NULL
;
to
->
hdf
[
field
]
=
0
;
to
->
hdf
[
field
]
=
0
;
...
@@ -974,11 +971,10 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
...
@@ -974,11 +971,10 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
}
}
void
void
http_PutProtocol
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
to
,
http_PutProtocol
(
const
struct
http
*
to
,
const
char
*
protocol
)
const
char
*
protocol
)
{
{
http_PutField
(
w
,
vsl_id
,
to
,
HTTP_HDR_PROTO
,
protocol
);
http_PutField
(
to
,
HTTP_HDR_PROTO
,
protocol
);
if
(
to
->
hd
[
HTTP_HDR_PROTO
].
b
==
NULL
)
if
(
to
->
hd
[
HTTP_HDR_PROTO
].
b
==
NULL
)
http_SetH
(
to
,
HTTP_HDR_PROTO
,
"HTTP/1.1"
);
http_SetH
(
to
,
HTTP_HDR_PROTO
,
"HTTP/1.1"
);
Tcheck
(
to
->
hd
[
HTTP_HDR_PROTO
]);
Tcheck
(
to
->
hd
[
HTTP_HDR_PROTO
]);
...
@@ -993,19 +989,17 @@ http_PutStatus(struct http *to, uint16_t status)
...
@@ -993,19 +989,17 @@ http_PutStatus(struct http *to, uint16_t status)
}
}
void
void
http_PutResponse
(
struct
worker
*
w
,
unsigned
vsl_id
,
const
struct
http
*
to
,
http_PutResponse
(
const
struct
http
*
to
,
const
char
*
response
)
const
char
*
response
)
{
{
http_PutField
(
w
,
vsl_id
,
to
,
HTTP_HDR_RESPONSE
,
response
);
http_PutField
(
to
,
HTTP_HDR_RESPONSE
,
response
);
if
(
to
->
hd
[
HTTP_HDR_RESPONSE
].
b
==
NULL
)
if
(
to
->
hd
[
HTTP_HDR_RESPONSE
].
b
==
NULL
)
http_SetH
(
to
,
HTTP_HDR_RESPONSE
,
"Lost Response"
);
http_SetH
(
to
,
HTTP_HDR_RESPONSE
,
"Lost Response"
);
Tcheck
(
to
->
hd
[
HTTP_HDR_RESPONSE
]);
Tcheck
(
to
->
hd
[
HTTP_HDR_RESPONSE
]);
}
}
void
void
http_PrintfHeader
(
struct
worker
*
w
,
unsigned
vsl_id
,
struct
http
*
to
,
http_PrintfHeader
(
struct
http
*
to
,
const
char
*
fmt
,
...)
const
char
*
fmt
,
...)
{
{
va_list
ap
;
va_list
ap
;
unsigned
l
,
n
;
unsigned
l
,
n
;
...
@@ -1017,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
...
@@ -1017,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
va_end
(
ap
);
va_end
(
ap
);
if
(
n
+
1
>=
l
||
to
->
nhd
>=
to
->
shd
)
{
if
(
n
+
1
>=
l
||
to
->
nhd
>=
to
->
shd
)
{
VSC_C_main
->
losthdr
++
;
VSC_C_main
->
losthdr
++
;
WSL
(
w
->
vsl
,
SLT_LostHeader
,
vsl_id
,
"%s"
,
to
->
ws
->
f
);
WSL
(
to
->
vsl
,
SLT_LostHeader
,
-
1
,
"%s"
,
to
->
ws
->
f
);
WS_Release
(
to
->
ws
,
0
);
WS_Release
(
to
->
ws
,
0
);
}
else
{
}
else
{
to
->
hd
[
to
->
nhd
].
b
=
to
->
ws
->
f
;
to
->
hd
[
to
->
nhd
].
b
=
to
->
ws
->
f
;
...
...
bin/varnishd/cache/cache_response.c
View file @
e9e3e2e8
...
@@ -90,13 +90,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
...
@@ -90,13 +90,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
if
(
low
>
high
)
if
(
low
>
high
)
return
;
return
;
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
"Content-Range: bytes %jd-%jd/%jd"
,
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
req
->
obj
->
len
);
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
req
->
obj
->
len
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
assert
(
req
->
res_mode
&
RES_LEN
);
assert
(
req
->
res_mode
&
RES_LEN
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
"Content-Length: %jd"
,
"Content-Length: %jd"
,
(
intmax_t
)(
1
+
high
-
low
));
(
intmax_t
)(
1
+
high
-
low
));
http_SetResp
(
req
->
resp
,
"HTTP/1.1"
,
206
,
"Partial Content"
);
http_SetResp
(
req
->
resp
,
"HTTP/1.1"
,
206
,
"Partial Content"
);
*
plow
=
low
;
*
plow
=
low
;
...
@@ -123,29 +122,25 @@ RES_BuildHttp(const struct sess *sp)
...
@@ -123,29 +122,25 @@ RES_BuildHttp(const struct sess *sp)
http_Unset
(
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
,
req
->
resp
,
http_SetHeader
(
req
->
resp
,
"Accept-Ranges: bytes"
);
"Accept-Ranges: bytes"
);
}
}
if
(
req
->
res_mode
&
RES_CHUNKED
)
if
(
req
->
res_mode
&
RES_CHUNKED
)
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_SetHeader
(
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
,
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
"Date: %s"
,
time_str
);
"Date: %s"
,
time_str
);
if
(
req
->
xid
!=
req
->
obj
->
xid
)
if
(
req
->
xid
!=
req
->
obj
->
xid
)
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
"X-Varnish: %u %u"
,
req
->
xid
,
req
->
obj
->
xid
);
"X-Varnish: %u %u"
,
req
->
xid
,
req
->
obj
->
xid
);
else
else
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
http_PrintfHeader
(
req
->
resp
,
"X-Varnish: %u"
,
req
->
xid
);
"X-Varnish: %u"
,
req
->
xid
);
http_PrintfHeader
(
req
->
resp
,
"Age: %.0f"
,
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Age: %.0f"
,
req
->
obj
->
exp
.
age
+
req
->
t_resp
-
req
->
obj
->
exp
.
age
+
req
->
t_resp
-
req
->
obj
->
exp
.
entered
);
req
->
obj
->
exp
.
entered
);
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Via: 1.1 varnish"
);
http_SetHeader
(
req
->
resp
,
"Via: 1.1 varnish"
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
req
->
resp
,
"Connection: %s"
,
http_PrintfHeader
(
req
->
resp
,
"Connection: %s"
,
req
->
doclose
?
"close"
:
"keep-alive"
);
req
->
doclose
?
"close"
:
"keep-alive"
);
}
}
...
@@ -337,7 +332,7 @@ RES_StreamStart(struct sess *sp)
...
@@ -337,7 +332,7 @@ RES_StreamStart(struct sess *sp)
if
(
!
(
req
->
res_mode
&
RES_CHUNKED
)
&&
if
(
!
(
req
->
res_mode
&
RES_CHUNKED
)
&&
sp
->
wrk
->
busyobj
->
h_content_length
!=
NULL
)
sp
->
wrk
->
busyobj
->
h_content_length
!=
NULL
)
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
resp
,
http_PrintfHeader
(
sp
->
req
->
resp
,
"Content-Length: %s"
,
sp
->
wrk
->
busyobj
->
h_content_length
);
"Content-Length: %s"
,
sp
->
wrk
->
busyobj
->
h_content_length
);
sp
->
wrk
->
acct_tmp
.
hdrbytes
+=
sp
->
wrk
->
acct_tmp
.
hdrbytes
+=
...
...
bin/varnishd/cache/cache_vrt.c
View file @
e9e3e2e8
...
@@ -231,7 +231,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
...
@@ -231,7 +231,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
WSP
(
sp
,
SLT_LostHeader
,
"%s"
,
hdr
+
1
);
WSP
(
sp
,
SLT_LostHeader
,
"%s"
,
hdr
+
1
);
}
else
{
}
else
{
http_Unset
(
hp
,
hdr
);
http_Unset
(
hp
,
hdr
);
http_SetHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
hp
,
b
);
http_SetHeader
(
hp
,
b
);
}
}
}
}
va_end
(
ap
);
va_end
(
ap
);
...
@@ -417,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...)
...
@@ -417,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...)
va_end
(
ap
);
va_end
(
ap
);
SMS_Finish
(
sp
->
req
->
obj
);
SMS_Finish
(
sp
->
req
->
obj
);
http_Unset
(
sp
->
req
->
obj
->
http
,
H_Content_Length
);
http_Unset
(
sp
->
req
->
obj
->
http
,
H_Content_Length
);
http_PrintfHeader
(
sp
->
wrk
,
sp
->
vsl_id
,
sp
->
req
->
obj
->
http
,
http_PrintfHeader
(
sp
->
req
->
obj
->
http
,
"Content-Length: %zd"
,
sp
->
req
->
obj
->
len
);
"Content-Length: %zd"
,
sp
->
req
->
obj
->
len
);
}
}
...
...
bin/varnishd/flint.lnt
View file @
e9e3e2e8
-d__flexelint_v9__=1
-d__flexelint_v9__=1
-printf(3, VSL)
-printf(3, VSL)
-printf(
4
, http_PrintfHeader)
-printf(
2
, http_PrintfHeader)
-printf(4, WSL)
-printf(4, WSL)
-printf(3, WSLB)
-printf(3, WSLB)
-printf(2, VSB_printf)
-printf(2, VSB_printf)
...
...
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