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
c2ebc126
Commit
c2ebc126
authored
Feb 18, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce two new states in backend-fetch state machine: retry and error
parent
543302c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
37 deletions
+67
-37
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+64
-36
steps.h
include/tbl/steps.h
+2
-0
generate.py
lib/libvcc/generate.py
+1
-1
No files found.
bin/varnishd/cache/cache_fetch.c
View file @
c2ebc126
...
...
@@ -41,6 +41,22 @@
#include "vcl.h"
#include "vtim.h"
/*--------------------------------------------------------------------
*/
static
void
make_it_503
(
struct
busyobj
*
bo
)
{
HTTP_Setup
(
bo
->
beresp
,
bo
->
ws
,
bo
->
vsl
,
SLT_BerespMethod
);
http_SetResp
(
bo
->
beresp
,
"HTTP/1.1"
,
503
,
"Backend fetch failed"
);
http_SetHeader
(
bo
->
beresp
,
"Content-Length: 0"
);
http_SetHeader
(
bo
->
beresp
,
"Connection: close"
);
bo
->
exp
.
ttl
=
0
;
bo
->
exp
.
grace
=
0
;
bo
->
exp
.
keep
=
0
;
}
/*--------------------------------------------------------------------
*/
...
...
@@ -103,7 +119,31 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
}
/*--------------------------------------------------------------------
* Copy run bereq by VCL::vcl_backend_fetch{}
* Start a new VSL transaction and try again
*/
static
enum
fetch_step
vbf_stp_retry
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
{
unsigned
owid
,
wid
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
// XXX: BereqEnd + BereqAcct ?
wid
=
VXID_Get
(
&
wrk
->
vxid_pool
);
VSLb
(
bo
->
vsl
,
SLT_Link
,
"bereq %u retry"
,
wid
);
VSLb
(
bo
->
vsl
,
SLT_End
,
"%s"
,
""
);
VSL_Flush
(
bo
->
vsl
,
0
);
owid
=
bo
->
vsl
->
wid
&
VSL_IDENTMASK
;
bo
->
vsl
->
wid
=
wid
|
VSL_BACKENDMARKER
;
VSLb
(
bo
->
vsl
,
SLT_Begin
,
"bereq %u retry"
,
owid
);
return
(
F_STP_STARTFETCH
);
}
/*--------------------------------------------------------------------
* Setup bereq from bereq0, run vcl_backend_fetch
*/
static
enum
fetch_step
...
...
@@ -138,21 +178,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
return
(
F_STP_FETCHHDR
);
}
/*--------------------------------------------------------------------
*/
static
void
make_it_503
(
struct
busyobj
*
bo
)
{
HTTP_Setup
(
bo
->
beresp
,
bo
->
ws
,
bo
->
vsl
,
SLT_BerespMethod
);
http_SetResp
(
bo
->
beresp
,
"HTTP/1.1"
,
503
,
"Backend fetch failed"
);
http_SetHeader
(
bo
->
beresp
,
"Content-Length: 0"
);
http_SetHeader
(
bo
->
beresp
,
"Connection: close"
);
bo
->
exp
.
ttl
=
0
;
bo
->
exp
.
grace
=
0
;
bo
->
exp
.
keep
=
0
;
}
/*--------------------------------------------------------------------
*/
...
...
@@ -161,7 +186,6 @@ static enum fetch_step
vbf_stp_fetchhdr
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
{
int
i
,
do_ims
,
fail
;
unsigned
owid
,
wid
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
...
...
@@ -247,17 +271,9 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
vbc
)
VDI_CloseFd
(
&
bo
->
vbc
);
bo
->
retries
++
;
if
(
bo
->
retries
<=
cache_param
->
max_retries
)
{
// XXX: BereqEnd + BereqAcct ?
wid
=
VXID_Get
(
&
wrk
->
vxid_pool
);
VSLb
(
bo
->
vsl
,
SLT_Link
,
"bereq %u retry"
,
wid
);
VSLb
(
bo
->
vsl
,
SLT_End
,
"%s"
,
""
);
VSL_Flush
(
bo
->
vsl
,
0
);
owid
=
bo
->
vsl
->
wid
&
VSL_IDENTMASK
;
bo
->
vsl
->
wid
=
wid
|
VSL_BACKENDMARKER
;
VSLb
(
bo
->
vsl
,
SLT_Begin
,
"bereq %u retry"
,
owid
);
return
(
F_STP_STARTFETCH
);
}
if
(
bo
->
retries
<=
cache_param
->
max_retries
)
return
(
F_STP_RETRY
);
VSLb
(
bo
->
vsl
,
SLT_VCL_Error
,
"Too many retries, delivering 503"
);
make_it_503
(
bo
);
...
...
@@ -548,13 +564,6 @@ VSLb(bo->vsl, SLT_Debug, "YYY REF %d %d",
return
(
F_STP_DONE
);
}
static
enum
fetch_step
vbf_stp_done
(
void
)
{
WRONG
(
"Just plain wrong"
);
return
(
F_STP_DONE
);
}
/*--------------------------------------------------------------------
*/
...
...
@@ -659,8 +668,28 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
}
/*--------------------------------------------------------------------
* Create synth object
*/
static
enum
fetch_step
vbf_stp_error
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
{
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
WRONG
(
""
);
return
(
F_STP_DONE
);
}
/*--------------------------------------------------------------------
*/
static
enum
fetch_step
vbf_stp_done
(
void
)
{
WRONG
(
"Just plain wrong"
);
return
(
F_STP_DONE
);
}
static
const
char
*
vbf_step_name
(
enum
fetch_step
stp
)
{
...
...
@@ -675,7 +704,6 @@ vbf_step_name(enum fetch_step stp)
}
}
static
void
vbf_fetch_thread
(
struct
worker
*
wrk
,
void
*
priv
)
{
...
...
include/tbl/steps.h
View file @
c2ebc126
...
...
@@ -50,10 +50,12 @@ REQ_STEP(error, ERROR, (wrk, req))
#ifdef FETCH_STEP
FETCH_STEP
(
mkbereq
,
MKBEREQ
,
(
wrk
,
bo
))
FETCH_STEP
(
retry
,
RETRY
,
(
wrk
,
bo
))
FETCH_STEP
(
startfetch
,
STARTFETCH
,
(
wrk
,
bo
))
FETCH_STEP
(
fetchhdr
,
FETCHHDR
,
(
wrk
,
bo
))
FETCH_STEP
(
condfetch
,
CONDFETCH
,
(
wrk
,
bo
))
FETCH_STEP
(
fetch
,
FETCH
,
(
wrk
,
bo
))
FETCH_STEP
(
error
,
ERROR
,
(
wrk
,
bo
))
FETCH_STEP
(
done
,
DONE
,
())
#endif
...
...
lib/libvcc/generate.py
View file @
c2ebc126
...
...
@@ -120,7 +120,7 @@ returns =(
),
###############################################################
# Backend-fetch
# Backend-fetch
(
'backend_fetch'
,
"B"
,
...
...
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