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
49af0c1e
Commit
49af0c1e
authored
Sep 28, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert htc->rxbuf from txt to dual char *
parent
d53f0f7f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
43 deletions
+50
-43
cache.h
bin/varnishd/cache/cache.h
+2
-1
cache_http1_fetch.c
bin/varnishd/cache/cache_http1_fetch.c
+5
-3
cache_http1_fsm.c
bin/varnishd/cache/cache_http1_fsm.c
+9
-5
cache_http1_proto.c
bin/varnishd/cache/cache_http1_proto.c
+34
-34
No files found.
bin/varnishd/cache/cache.h
View file @
49af0c1e
...
@@ -247,7 +247,8 @@ struct http_conn {
...
@@ -247,7 +247,8 @@ struct http_conn {
unsigned
maxbytes
;
unsigned
maxbytes
;
unsigned
maxhdr
;
unsigned
maxhdr
;
struct
ws
*
ws
;
struct
ws
*
ws
;
txt
rxbuf
;
char
*
rxbuf_b
;
char
*
rxbuf_e
;
char
*
pipeline_b
;
char
*
pipeline_b
;
char
*
pipeline_e
;
char
*
pipeline_e
;
ssize_t
content_length
;
ssize_t
content_length
;
...
...
bin/varnishd/cache/cache_http1_fetch.c
View file @
49af0c1e
...
@@ -165,7 +165,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
...
@@ -165,7 +165,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
do
{
do
{
hs
=
HTTP1_Rx
(
htc
);
hs
=
HTTP1_Rx
(
htc
);
if
(
hs
==
HTTP1_OVERFLOW
)
{
if
(
hs
==
HTTP1_OVERFLOW
)
{
bo
->
acct
.
beresp_hdrbytes
+=
Tlen
(
htc
->
rxbuf
);
bo
->
acct
.
beresp_hdrbytes
+=
htc
->
rxbuf_e
-
htc
->
rxbuf_b
;
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"http %sread error: overflow"
,
"http %sread error: overflow"
,
first
?
"first "
:
""
);
first
?
"first "
:
""
);
...
@@ -174,7 +175,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
...
@@ -174,7 +175,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
return
(
-
1
);
return
(
-
1
);
}
}
if
(
hs
==
HTTP1_ERROR_EOF
)
{
if
(
hs
==
HTTP1_ERROR_EOF
)
{
bo
->
acct
.
beresp_hdrbytes
+=
Tlen
(
htc
->
rxbuf
);
bo
->
acct
.
beresp_hdrbytes
+=
htc
->
rxbuf_e
-
htc
->
rxbuf_b
;
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"http %sread error: EOF"
,
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"http %sread error: EOF"
,
first
?
"first "
:
""
);
first
?
"first "
:
""
);
VBE_CloseFd
(
&
bo
->
vbc
,
&
bo
->
acct
);
VBE_CloseFd
(
&
bo
->
vbc
,
&
bo
->
acct
);
...
@@ -188,7 +190,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
...
@@ -188,7 +190,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
vc
->
between_bytes_timeout
);
vc
->
between_bytes_timeout
);
}
}
}
while
(
hs
!=
HTTP1_COMPLETE
);
}
while
(
hs
!=
HTTP1_COMPLETE
);
bo
->
acct
.
beresp_hdrbytes
+=
Tlen
(
htc
->
rxbuf
)
;
bo
->
acct
.
beresp_hdrbytes
+=
htc
->
rxbuf_e
-
htc
->
rxbuf_b
;
hp
=
bo
->
beresp
;
hp
=
bo
->
beresp
;
...
...
bin/varnishd/cache/cache_http1_fsm.c
View file @
49af0c1e
...
@@ -124,7 +124,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -124,7 +124,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
req
->
t_first
=
now
;
req
->
t_first
=
now
;
if
(
isnan
(
req
->
t_req
))
if
(
isnan
(
req
->
t_req
))
req
->
t_req
=
now
;
req
->
t_req
=
now
;
req
->
acct
.
req_hdrbytes
+=
Tlen
(
req
->
htc
->
rxbuf
);
req
->
acct
.
req_hdrbytes
+=
req
->
htc
->
rxbuf_e
-
req
->
htc
->
rxbuf_b
;
return
(
REQ_FSM_MORE
);
return
(
REQ_FSM_MORE
);
}
else
if
(
hs
==
HTTP1_ERROR_EOF
)
{
}
else
if
(
hs
==
HTTP1_ERROR_EOF
)
{
why
=
SC_REM_CLOSE
;
why
=
SC_REM_CLOSE
;
...
@@ -160,7 +161,7 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -160,7 +161,7 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
}
}
}
}
}
}
req
->
acct
.
req_hdrbytes
+=
Tlen
(
req
->
htc
->
rxbuf
)
;
req
->
acct
.
req_hdrbytes
+=
req
->
htc
->
rxbuf_e
-
req
->
htc
->
rxbuf_b
;
CNT_AcctLogCharge
(
wrk
->
stats
,
req
);
CNT_AcctLogCharge
(
wrk
->
stats
,
req
);
SES_ReleaseReq
(
req
);
SES_ReleaseReq
(
req
);
assert
(
why
!=
SC_NULL
);
assert
(
why
!=
SC_NULL
);
...
@@ -240,10 +241,11 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
...
@@ -240,10 +241,11 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
AZ
(
req
->
vsl
->
wid
);
AZ
(
req
->
vsl
->
wid
);
req
->
t_first
=
req
->
t_req
=
sp
->
t_idle
;
req
->
t_first
=
req
->
t_req
=
sp
->
t_idle
;
wrk
->
stats
->
sess_pipeline
++
;
wrk
->
stats
->
sess_pipeline
++
;
req
->
acct
.
req_hdrbytes
+=
Tlen
(
req
->
htc
->
rxbuf
);
req
->
acct
.
req_hdrbytes
+=
req
->
htc
->
rxbuf_e
-
req
->
htc
->
rxbuf_b
;
return
(
SESS_DONE_RET_START
);
return
(
SESS_DONE_RET_START
);
}
else
{
}
else
{
if
(
Tlen
(
req
->
htc
->
rxbuf
)
)
if
(
req
->
htc
->
rxbuf_e
!=
req
->
htc
->
rxbuf_b
)
wrk
->
stats
->
sess_readahead
++
;
wrk
->
stats
->
sess_readahead
++
;
return
(
SESS_DONE_RET_WAIT
);
return
(
SESS_DONE_RET_WAIT
);
}
}
...
@@ -286,7 +288,9 @@ http1_dissect(struct worker *wrk, struct req *req)
...
@@ -286,7 +288,9 @@ http1_dissect(struct worker *wrk, struct req *req)
/* If we could not even parse the request, just close */
/* If we could not even parse the request, just close */
if
(
req
->
err_code
!=
0
)
{
if
(
req
->
err_code
!=
0
)
{
VSLbt
(
req
->
vsl
,
SLT_HttpGarbage
,
req
->
htc
->
rxbuf
);
VSLb
(
req
->
vsl
,
SLT_HttpGarbage
,
"%.*s"
,
(
int
)(
req
->
htc
->
rxbuf_e
-
req
->
htc
->
rxbuf_b
),
req
->
htc
->
rxbuf_b
);
wrk
->
stats
->
client_req_400
++
;
wrk
->
stats
->
client_req_400
++
;
r
=
write
(
req
->
sp
->
fd
,
r_400
,
strlen
(
r_400
));
r
=
write
(
req
->
sp
->
fd
,
r_400
,
strlen
(
r_400
));
if
(
r
>
0
)
if
(
r
>
0
)
...
...
bin/varnishd/cache/cache_http1_proto.c
View file @
49af0c1e
...
@@ -72,9 +72,9 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
...
@@ -72,9 +72,9 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
htc
->
maxhdr
=
maxhdr
;
htc
->
maxhdr
=
maxhdr
;
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
htc
->
rxbuf
.
b
=
ws
->
f
;
htc
->
rxbuf
_
b
=
ws
->
f
;
htc
->
rxbuf
.
e
=
ws
->
f
;
htc
->
rxbuf
_
e
=
ws
->
f
;
*
htc
->
rxbuf
.
e
=
'\0'
;
*
htc
->
rxbuf
_
e
=
'\0'
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_e
=
NULL
;
htc
->
pipeline_e
=
NULL
;
}
}
...
@@ -92,17 +92,17 @@ HTTP1_Reinit(struct http_conn *htc)
...
@@ -92,17 +92,17 @@ HTTP1_Reinit(struct http_conn *htc)
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
htc
->
rxbuf
.
b
=
htc
->
ws
->
f
;
htc
->
rxbuf
_
b
=
htc
->
ws
->
f
;
htc
->
rxbuf
.
e
=
htc
->
ws
->
f
;
htc
->
rxbuf
_
e
=
htc
->
ws
->
f
;
if
(
htc
->
pipeline_b
!=
NULL
)
{
if
(
htc
->
pipeline_b
!=
NULL
)
{
l
=
htc
->
pipeline_e
-
htc
->
pipeline_b
;
l
=
htc
->
pipeline_e
-
htc
->
pipeline_b
;
assert
(
l
>
0
);
assert
(
l
>
0
);
memmove
(
htc
->
rxbuf
.
b
,
htc
->
pipeline_b
,
l
);
memmove
(
htc
->
rxbuf
_
b
,
htc
->
pipeline_b
,
l
);
htc
->
rxbuf
.
e
+=
l
;
htc
->
rxbuf
_
e
+=
l
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_e
=
NULL
;
htc
->
pipeline_e
=
NULL
;
}
}
*
htc
->
rxbuf
.
e
=
'\0'
;
*
htc
->
rxbuf
_
e
=
'\0'
;
return
(
HTTP1_Complete
(
htc
));
return
(
HTTP1_Complete
(
htc
));
}
}
...
@@ -114,23 +114,21 @@ enum http1_status_e
...
@@ -114,23 +114,21 @@ enum http1_status_e
HTTP1_Complete
(
struct
http_conn
*
htc
)
HTTP1_Complete
(
struct
http_conn
*
htc
)
{
{
char
*
p
;
char
*
p
;
txt
*
t
;
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
AZ
(
htc
->
pipeline_b
);
AZ
(
htc
->
pipeline_b
);
AZ
(
htc
->
pipeline_e
);
AZ
(
htc
->
pipeline_e
);
t
=
&
htc
->
rxbuf
;
assert
(
htc
->
rxbuf_e
>=
htc
->
rxbuf_b
);
Tcheck
(
*
t
);
assert
(
*
htc
->
rxbuf_e
==
'\0'
);
assert
(
*
t
->
e
==
'\0'
);
/* Skip any leading white space */
/* Skip any leading white space */
for
(
p
=
t
->
b
;
vct_islws
(
*
p
);
p
++
)
for
(
p
=
htc
->
rxbuf_
b
;
vct_islws
(
*
p
);
p
++
)
continue
;
continue
;
if
(
p
==
t
->
e
)
{
if
(
p
==
htc
->
rxbuf_
e
)
{
/* All white space */
/* All white space */
t
->
e
=
t
->
b
;
htc
->
rxbuf_e
=
htc
->
rxbuf_
b
;
*
t
->
e
=
'\0'
;
*
htc
->
rxbuf_
e
=
'\0'
;
return
(
HTTP1_ALL_WHITESPACE
);
return
(
HTTP1_ALL_WHITESPACE
);
}
}
while
(
1
)
{
while
(
1
)
{
...
@@ -144,11 +142,11 @@ HTTP1_Complete(struct http_conn *htc)
...
@@ -144,11 +142,11 @@ HTTP1_Complete(struct http_conn *htc)
break
;
break
;
}
}
p
++
;
p
++
;
WS_ReleaseP
(
htc
->
ws
,
t
->
e
);
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf_
e
);
if
(
p
<
t
->
e
)
{
if
(
p
<
htc
->
rxbuf_
e
)
{
htc
->
pipeline_b
=
p
;
htc
->
pipeline_b
=
p
;
htc
->
pipeline_e
=
t
->
e
;
htc
->
pipeline_e
=
htc
->
rxbuf_
e
;
t
->
e
=
p
;
htc
->
rxbuf_
e
=
p
;
}
}
return
(
HTTP1_COMPLETE
);
return
(
HTTP1_COMPLETE
);
}
}
...
@@ -166,22 +164,22 @@ HTTP1_Rx(struct http_conn *htc)
...
@@ -166,22 +164,22 @@ HTTP1_Rx(struct http_conn *htc)
AN
(
htc
->
ws
->
r
);
AN
(
htc
->
ws
->
r
);
AZ
(
htc
->
pipeline_b
);
AZ
(
htc
->
pipeline_b
);
AZ
(
htc
->
pipeline_e
);
AZ
(
htc
->
pipeline_e
);
i
=
(
htc
->
ws
->
r
-
htc
->
rxbuf
.
e
)
-
1
;
/* space for NUL */
i
=
(
htc
->
ws
->
r
-
htc
->
rxbuf
_
e
)
-
1
;
/* space for NUL */
if
(
i
<=
0
)
{
if
(
i
<=
0
)
{
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
.
b
);
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
_
b
);
return
(
HTTP1_OVERFLOW
);
return
(
HTTP1_OVERFLOW
);
}
}
i
=
read
(
htc
->
fd
,
htc
->
rxbuf
.
e
,
i
);
i
=
read
(
htc
->
fd
,
htc
->
rxbuf
_
e
,
i
);
if
(
i
<=
0
)
{
if
(
i
<=
0
)
{
/*
/*
* We wouldn't come here if we had a complete HTTP header
* We wouldn't come here if we had a complete HTTP header
* so consequently an EOF can not be OK
* so consequently an EOF can not be OK
*/
*/
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
.
b
);
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
_
b
);
return
(
HTTP1_ERROR_EOF
);
return
(
HTTP1_ERROR_EOF
);
}
}
htc
->
rxbuf
.
e
+=
i
;
htc
->
rxbuf
_
e
+=
i
;
*
htc
->
rxbuf
.
e
=
'\0'
;
*
htc
->
rxbuf
_
e
=
'\0'
;
return
(
HTTP1_Complete
(
htc
));
return
(
HTTP1_Complete
(
htc
));
}
}
...
@@ -230,24 +228,25 @@ static uint16_t
...
@@ -230,24 +228,25 @@ static uint16_t
http1_dissect_hdrs
(
struct
http
*
hp
,
char
*
p
,
const
struct
http_conn
*
htc
)
http1_dissect_hdrs
(
struct
http
*
hp
,
char
*
p
,
const
struct
http_conn
*
htc
)
{
{
char
*
q
,
*
r
;
char
*
q
,
*
r
;
txt
t
=
htc
->
rxbuf
;
assert
(
p
>
htc
->
rxbuf_b
);
assert
(
p
<
htc
->
rxbuf_e
);
hp
->
nhd
=
HTTP_HDR_FIRST
;
hp
->
nhd
=
HTTP_HDR_FIRST
;
hp
->
conds
=
0
;
hp
->
conds
=
0
;
r
=
NULL
;
/* For FlexeLint */
r
=
NULL
;
/* For FlexeLint */
for
(;
p
<
t
.
e
;
p
=
r
)
{
for
(;
p
<
htc
->
rxbuf_
e
;
p
=
r
)
{
/* Find end of next header */
/* Find end of next header */
q
=
r
=
p
;
q
=
r
=
p
;
while
(
r
<
t
.
e
)
{
while
(
r
<
htc
->
rxbuf_
e
)
{
if
(
!
vct_iscrlf
(
r
))
{
if
(
!
vct_iscrlf
(
r
))
{
r
++
;
r
++
;
continue
;
continue
;
}
}
q
=
r
;
q
=
r
;
assert
(
r
<
t
.
e
);
assert
(
r
<
htc
->
rxbuf_
e
);
r
+=
vct_skipcrlf
(
r
);
r
+=
vct_skipcrlf
(
r
);
if
(
r
>=
t
.
e
)
if
(
r
>=
htc
->
rxbuf_
e
)
break
;
break
;
/* If line does not continue: got it. */
/* If line does not continue: got it. */
if
(
!
vct_issp
(
*
r
))
if
(
!
vct_issp
(
*
r
))
...
@@ -316,14 +315,14 @@ http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf)
...
@@ -316,14 +315,14 @@ http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf)
assert
(
hf
==
HTTP1_Req
||
hf
==
HTTP1_Resp
);
assert
(
hf
==
HTTP1_Req
||
hf
==
HTTP1_Resp
);
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
Tcheck
(
htc
->
rxbuf
);
assert
(
htc
->
rxbuf_e
>=
htc
->
rxbuf_b
);
AZ
(
hp
->
hd
[
hf
[
0
]].
b
);
AZ
(
hp
->
hd
[
hf
[
0
]].
b
);
AZ
(
hp
->
hd
[
hf
[
1
]].
b
);
AZ
(
hp
->
hd
[
hf
[
1
]].
b
);
AZ
(
hp
->
hd
[
hf
[
2
]].
b
);
AZ
(
hp
->
hd
[
hf
[
2
]].
b
);
/* Skip leading LWS */
/* Skip leading LWS */
for
(
p
=
htc
->
rxbuf
.
b
;
vct_islws
(
*
p
);
p
++
)
for
(
p
=
htc
->
rxbuf
_
b
;
vct_islws
(
*
p
);
p
++
)
continue
;
continue
;
hp
->
hd
[
hf
[
0
]].
b
=
p
;
hp
->
hd
[
hf
[
0
]].
b
=
p
;
...
@@ -536,7 +535,8 @@ HTTP1_DissectResponse(struct http *hp, struct http_conn *htc)
...
@@ -536,7 +535,8 @@ HTTP1_DissectResponse(struct http *hp, struct http_conn *htc)
}
}
if
(
retval
!=
0
)
{
if
(
retval
!=
0
)
{
VSLbt
(
hp
->
vsl
,
SLT_HttpGarbage
,
htc
->
rxbuf
);
VSLb
(
hp
->
vsl
,
SLT_HttpGarbage
,
"%.*s"
,
(
int
)(
htc
->
rxbuf_e
-
htc
->
rxbuf_b
),
htc
->
rxbuf_b
);
assert
(
retval
>=
100
&&
retval
<=
999
);
assert
(
retval
>=
100
&&
retval
<=
999
);
assert
(
retval
==
503
);
assert
(
retval
==
503
);
hp
->
status
=
retval
;
hp
->
status
=
retval
;
...
...
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