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
9fec4441
Commit
9fec4441
authored
Mar 23, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give SES_Rx() a timeout argument, and take that bit of complexity
out of http1_wait()
parent
8e216d58
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
23 deletions
+27
-23
cache.h
bin/varnishd/cache/cache.h
+5
-4
cache_session.c
bin/varnishd/cache/cache_session.c
+15
-2
cache_http1_fetch.c
bin/varnishd/http1/cache_http1_fetch.c
+1
-1
cache_http1_fsm.c
bin/varnishd/http1/cache_http1_fsm.c
+6
-16
No files found.
bin/varnishd/cache/cache.h
View file @
9fec4441
...
...
@@ -985,17 +985,18 @@ task_func_t SES_Proto_Sess;
task_func_t
SES_Proto_Req
;
enum
htc_status_e
{
HTC_S_EMPTY
=
-
3
,
HTC_S_EMPTY
=
-
4
,
HTC_S_TIMEOUT
=
-
3
,
HTC_S_OVERFLOW
=
-
2
,
HTC_S_EOF
=
-
1
,
HTC_S_OK
=
0
,
HTC_S_EOF
=
-
1
,
HTC_S_OK
=
0
,
HTC_S_COMPLETE
=
1
};
void
SES_RxInit
(
struct
http_conn
*
htc
,
struct
ws
*
ws
,
unsigned
maxbytes
,
unsigned
maxhdr
);
void
SES_RxReInit
(
struct
http_conn
*
htc
);
enum
htc_status_e
SES_Rx
(
struct
http_conn
*
htc
);
enum
htc_status_e
SES_Rx
(
struct
http_conn
*
htc
,
double
tmo
);
#define SESS_ATTR(UP, low, typ, len) \
int SES_Get_##low(const struct sess *sp, typ *dst); \
...
...
bin/varnishd/cache/cache_session.c
View file @
9fec4441
...
...
@@ -41,6 +41,7 @@
#include "config.h"
#include <errno.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -205,9 +206,10 @@ SES_RxReInit(struct http_conn *htc)
*/
enum
htc_status_e
SES_Rx
(
struct
http_conn
*
htc
)
SES_Rx
(
struct
http_conn
*
htc
,
double
tmo
)
{
int
i
;
int
i
,
j
;
struct
pollfd
pfd
[
1
];
CHECK_OBJ_NOTNULL
(
htc
,
HTTP_CONN_MAGIC
);
AN
(
htc
->
ws
->
r
);
...
...
@@ -216,6 +218,17 @@ SES_Rx(struct http_conn *htc)
i
=
(
htc
->
ws
->
r
-
htc
->
rxbuf_e
)
-
1
;
/* space for NUL */
if
(
i
<=
0
)
return
(
HTC_S_OVERFLOW
);
if
(
tmo
>
0
.
0
)
{
pfd
[
0
].
fd
=
htc
->
fd
;
pfd
[
0
].
events
=
POLLIN
;
pfd
[
0
].
revents
=
0
;
j
=
(
int
)
floor
(
tmo
*
1e3
);
if
(
j
==
0
)
j
++
;
j
=
poll
(
pfd
,
1
,
j
);
if
(
j
==
0
)
return
(
HTC_S_TIMEOUT
);
}
i
=
read
(
htc
->
fd
,
htc
->
rxbuf_e
,
i
);
if
(
i
<=
0
)
return
(
HTC_S_EOF
);
...
...
bin/varnishd/http1/cache_http1_fetch.c
View file @
9fec4441
...
...
@@ -153,7 +153,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
first
=
1
;
do
{
hs
=
SES_Rx
(
htc
);
hs
=
SES_Rx
(
htc
,
0
);
if
(
hs
==
HTC_S_OK
)
hs
=
HTTP1_Complete
(
htc
);
if
(
hs
==
HTC_S_OVERFLOW
)
{
...
...
bin/varnishd/http1/cache_http1_fsm.c
View file @
9fec4441
...
...
@@ -34,7 +34,6 @@
#include "config.h"
#include <errno.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -52,8 +51,7 @@
static
enum
req_fsm_nxt
http1_wait
(
struct
sess
*
sp
,
struct
worker
*
wrk
,
struct
req
*
req
)
{
int
j
,
tmo
;
struct
pollfd
pfd
[
1
];
int
tmo
;
double
now
,
when
;
enum
sess_close
why
=
SC_NULL
;
enum
htc_status_e
hs
;
...
...
@@ -71,19 +69,11 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
assert
(
isnan
(
req
->
t_prev
));
assert
(
isnan
(
req
->
t_req
));
tmo
=
(
int
)(
1e3
*
cache_param
->
timeout_linger
);
tmo
=
(
int
)
floor
(
1e3
*
cache_param
->
timeout_linger
);
while
(
1
)
{
pfd
[
0
].
fd
=
sp
->
fd
;
pfd
[
0
].
events
=
POLLIN
;
pfd
[
0
].
revents
=
0
;
j
=
poll
(
pfd
,
1
,
tmo
);
assert
(
j
>=
0
);
hs
=
SES_Rx
(
req
->
htc
,
tmo
*
1e3
);
now
=
VTIM_real
();
if
(
j
!=
0
)
hs
=
SES_Rx
(
req
->
htc
);
else
hs
=
HTC_S_OK
;
// XXX HTC_S_TIMEOUT ?
if
(
hs
==
HTC_S_OK
)
if
(
hs
==
HTC_S_OK
||
hs
==
HTC_S_TIMEOUT
)
hs
=
HTTP1_Complete
(
req
->
htc
);
if
(
hs
==
HTC_S_COMPLETE
)
{
/* Got it, run with it */
...
...
@@ -110,7 +100,7 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
break
;
}
when
=
sp
->
t_idle
+
cache_param
->
timeout_linger
;
tmo
=
(
int
)(
1e3
*
(
when
-
now
));
tmo
=
(
int
)
floor
(
1e3
*
(
when
-
now
));
if
(
when
<
now
||
tmo
==
0
)
{
wrk
->
stats
->
sess_herd
++
;
SES_ReleaseReq
(
req
);
...
...
@@ -126,7 +116,7 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
/* Record first byte received time stamp */
req
->
t_first
=
now
;
when
=
req
->
t_first
+
cache_param
->
timeout_req
;
tmo
=
(
int
)(
1e3
*
(
when
-
now
));
tmo
=
(
int
)
floor
(
1e3
*
(
when
-
now
));
if
(
when
<
now
||
tmo
==
0
)
{
why
=
SC_RX_TIMEOUT
;
break
;
...
...
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