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
Hide 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 {
unsigned
maxbytes
;
unsigned
maxhdr
;
struct
ws
*
ws
;
txt
rxbuf
;
char
*
rxbuf_b
;
char
*
rxbuf_e
;
char
*
pipeline_b
;
char
*
pipeline_e
;
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)
do
{
hs
=
HTTP1_Rx
(
htc
);
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
,
"http %sread error: overflow"
,
first
?
"first "
:
""
);
...
...
@@ -174,7 +175,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
return
(
-
1
);
}
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"
,
first
?
"first "
:
""
);
VBE_CloseFd
(
&
bo
->
vbc
,
&
bo
->
acct
);
...
...
@@ -188,7 +190,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
vc
->
between_bytes_timeout
);
}
}
while
(
hs
!=
HTTP1_COMPLETE
);
bo
->
acct
.
beresp_hdrbytes
+=
Tlen
(
htc
->
rxbuf
)
;
bo
->
acct
.
beresp_hdrbytes
+=
htc
->
rxbuf_e
-
htc
->
rxbuf_b
;
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)
req
->
t_first
=
now
;
if
(
isnan
(
req
->
t_req
))
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
);
}
else
if
(
hs
==
HTTP1_ERROR_EOF
)
{
why
=
SC_REM_CLOSE
;
...
...
@@ -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
);
SES_ReleaseReq
(
req
);
assert
(
why
!=
SC_NULL
);
...
...
@@ -240,10 +241,11 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
AZ
(
req
->
vsl
->
wid
);
req
->
t_first
=
req
->
t_req
=
sp
->
t_idle
;
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
);
}
else
{
if
(
Tlen
(
req
->
htc
->
rxbuf
)
)
if
(
req
->
htc
->
rxbuf_e
!=
req
->
htc
->
rxbuf_b
)
wrk
->
stats
->
sess_readahead
++
;
return
(
SESS_DONE_RET_WAIT
);
}
...
...
@@ -286,7 +288,9 @@ http1_dissect(struct worker *wrk, struct req *req)
/* If we could not even parse the request, just close */
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
++
;
r
=
write
(
req
->
sp
->
fd
,
r_400
,
strlen
(
r_400
));
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,
htc
->
maxhdr
=
maxhdr
;
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
htc
->
rxbuf
.
b
=
ws
->
f
;
htc
->
rxbuf
.
e
=
ws
->
f
;
*
htc
->
rxbuf
.
e
=
'\0'
;
htc
->
rxbuf
_
b
=
ws
->
f
;
htc
->
rxbuf
_
e
=
ws
->
f
;
*
htc
->
rxbuf
_
e
=
'\0'
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_e
=
NULL
;
}
...
...
@@ -92,17 +92,17 @@ HTTP1_Reinit(struct http_conn *htc)
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
(
void
)
WS_Reserve
(
htc
->
ws
,
htc
->
maxbytes
);
htc
->
rxbuf
.
b
=
htc
->
ws
->
f
;
htc
->
rxbuf
.
e
=
htc
->
ws
->
f
;
htc
->
rxbuf
_
b
=
htc
->
ws
->
f
;
htc
->
rxbuf
_
e
=
htc
->
ws
->
f
;
if
(
htc
->
pipeline_b
!=
NULL
)
{
l
=
htc
->
pipeline_e
-
htc
->
pipeline_b
;
assert
(
l
>
0
);
memmove
(
htc
->
rxbuf
.
b
,
htc
->
pipeline_b
,
l
);
htc
->
rxbuf
.
e
+=
l
;
memmove
(
htc
->
rxbuf
_
b
,
htc
->
pipeline_b
,
l
);
htc
->
rxbuf
_
e
+=
l
;
htc
->
pipeline_b
=
NULL
;
htc
->
pipeline_e
=
NULL
;
}
*
htc
->
rxbuf
.
e
=
'\0'
;
*
htc
->
rxbuf
_
e
=
'\0'
;
return
(
HTTP1_Complete
(
htc
));
}
...
...
@@ -114,23 +114,21 @@ enum http1_status_e
HTTP1_Complete
(
struct
http_conn
*
htc
)
{
char
*
p
;
txt
*
t
;
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
AZ
(
htc
->
pipeline_b
);
AZ
(
htc
->
pipeline_e
);
t
=
&
htc
->
rxbuf
;
Tcheck
(
*
t
);
assert
(
*
t
->
e
==
'\0'
);
assert
(
htc
->
rxbuf_e
>=
htc
->
rxbuf_b
);
assert
(
*
htc
->
rxbuf_e
==
'\0'
);
/* Skip any leading white space */
for
(
p
=
t
->
b
;
vct_islws
(
*
p
);
p
++
)
for
(
p
=
htc
->
rxbuf_
b
;
vct_islws
(
*
p
);
p
++
)
continue
;
if
(
p
==
t
->
e
)
{
if
(
p
==
htc
->
rxbuf_
e
)
{
/* All white space */
t
->
e
=
t
->
b
;
*
t
->
e
=
'\0'
;
htc
->
rxbuf_e
=
htc
->
rxbuf_
b
;
*
htc
->
rxbuf_
e
=
'\0'
;
return
(
HTTP1_ALL_WHITESPACE
);
}
while
(
1
)
{
...
...
@@ -144,11 +142,11 @@ HTTP1_Complete(struct http_conn *htc)
break
;
}
p
++
;
WS_ReleaseP
(
htc
->
ws
,
t
->
e
);
if
(
p
<
t
->
e
)
{
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf_
e
);
if
(
p
<
htc
->
rxbuf_
e
)
{
htc
->
pipeline_b
=
p
;
htc
->
pipeline_e
=
t
->
e
;
t
->
e
=
p
;
htc
->
pipeline_e
=
htc
->
rxbuf_
e
;
htc
->
rxbuf_
e
=
p
;
}
return
(
HTTP1_COMPLETE
);
}
...
...
@@ -166,22 +164,22 @@ HTTP1_Rx(struct http_conn *htc)
AN
(
htc
->
ws
->
r
);
AZ
(
htc
->
pipeline_b
);
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
)
{
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
.
b
);
WS_ReleaseP
(
htc
->
ws
,
htc
->
rxbuf
_
b
);
return
(
HTTP1_OVERFLOW
);
}
i
=
read
(
htc
->
fd
,
htc
->
rxbuf
.
e
,
i
);
i
=
read
(
htc
->
fd
,
htc
->
rxbuf
_
e
,
i
);
if
(
i
<=
0
)
{
/*
* We wouldn't come here if we had a complete HTTP header
* 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
);
}
htc
->
rxbuf
.
e
+=
i
;
*
htc
->
rxbuf
.
e
=
'\0'
;
htc
->
rxbuf
_
e
+=
i
;
*
htc
->
rxbuf
_
e
=
'\0'
;
return
(
HTTP1_Complete
(
htc
));
}
...
...
@@ -230,24 +228,25 @@ static uint16_t
http1_dissect_hdrs
(
struct
http
*
hp
,
char
*
p
,
const
struct
http_conn
*
htc
)
{
char
*
q
,
*
r
;
txt
t
=
htc
->
rxbuf
;
assert
(
p
>
htc
->
rxbuf_b
);
assert
(
p
<
htc
->
rxbuf_e
);
hp
->
nhd
=
HTTP_HDR_FIRST
;
hp
->
conds
=
0
;
r
=
NULL
;
/* For FlexeLint */
for
(;
p
<
t
.
e
;
p
=
r
)
{
for
(;
p
<
htc
->
rxbuf_
e
;
p
=
r
)
{
/* Find end of next header */
q
=
r
=
p
;
while
(
r
<
t
.
e
)
{
while
(
r
<
htc
->
rxbuf_
e
)
{
if
(
!
vct_iscrlf
(
r
))
{
r
++
;
continue
;
}
q
=
r
;
assert
(
r
<
t
.
e
);
assert
(
r
<
htc
->
rxbuf_
e
);
r
+=
vct_skipcrlf
(
r
);
if
(
r
>=
t
.
e
)
if
(
r
>=
htc
->
rxbuf_
e
)
break
;
/* If line does not continue: got it. */
if
(
!
vct_issp
(
*
r
))
...
...
@@ -316,14 +315,14 @@ http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf)
assert
(
hf
==
HTTP1_Req
||
hf
==
HTTP1_Resp
);
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_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
[
1
]].
b
);
AZ
(
hp
->
hd
[
hf
[
2
]].
b
);
/* Skip leading LWS */
for
(
p
=
htc
->
rxbuf
.
b
;
vct_islws
(
*
p
);
p
++
)
for
(
p
=
htc
->
rxbuf
_
b
;
vct_islws
(
*
p
);
p
++
)
continue
;
hp
->
hd
[
hf
[
0
]].
b
=
p
;
...
...
@@ -536,7 +535,8 @@ HTTP1_DissectResponse(struct http *hp, struct http_conn *htc)
}
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
==
503
);
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