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
4d0bf7ab
Commit
4d0bf7ab
authored
May 01, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give the director methods VMOD friendly arguments
parent
1d06da56
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
85 deletions
+92
-85
cache_backend.c
bin/varnishd/cache/cache_backend.c
+37
-32
cache_director.c
bin/varnishd/cache/cache_director.c
+32
-22
cache_director.h
bin/varnishd/cache/cache_director.h
+5
-13
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+13
-13
cache_varnishd.h
bin/varnishd/cache/cache_varnishd.h
+4
-4
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+1
-1
No files found.
bin/varnishd/cache/cache_backend.c
View file @
4d0bf7ab
...
@@ -154,14 +154,15 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo,
...
@@ -154,14 +154,15 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo,
}
}
static
void
v_matchproto_
(
vdi_finish_f
)
static
void
v_matchproto_
(
vdi_finish_f
)
vbe_dir_finish
(
const
struct
director
*
d
,
struct
worker
*
wrk
,
vbe_dir_finish
(
VRT_CTX
,
VCL_BACKEND
d
)
struct
busyobj
*
bo
)
{
{
struct
backend
*
bp
;
struct
backend
*
bp
;
struct
busyobj
*
bo
;
struct
pfd
*
pfd
;
struct
pfd
*
pfd
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
)
;
bo
=
ctx
->
bo
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
...
@@ -183,7 +184,7 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
...
@@ -183,7 +184,7 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
VRT_BACKEND_string
(
bp
->
director
));
VRT_BACKEND_string
(
bp
->
director
));
Lck_Lock
(
&
bp
->
mtx
);
Lck_Lock
(
&
bp
->
mtx
);
VSC_C_main
->
backend_recycle
++
;
VSC_C_main
->
backend_recycle
++
;
VTP_Recycle
(
wrk
,
&
pfd
);
VTP_Recycle
(
bo
->
wrk
,
&
pfd
);
}
}
assert
(
bp
->
n_conn
>
0
);
assert
(
bp
->
n_conn
>
0
);
bp
->
n_conn
--
;
bp
->
n_conn
--
;
...
@@ -196,17 +197,21 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
...
@@ -196,17 +197,21 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
}
}
static
int
v_matchproto_
(
vdi_gethdrs_f
)
static
int
v_matchproto_
(
vdi_gethdrs_f
)
vbe_dir_gethdrs
(
const
struct
director
*
d
,
struct
worker
*
wrk
,
vbe_dir_gethdrs
(
VRT_CTX
,
VCL_BACKEND
d
)
struct
busyobj
*
bo
)
{
{
int
i
,
extrachance
=
1
;
int
i
,
extrachance
=
1
;
struct
backend
*
bp
;
struct
backend
*
bp
;
struct
pfd
*
pfd
;
struct
pfd
*
pfd
;
struct
busyobj
*
bo
;
struct
worker
*
wrk
;
char
abuf
[
VTCP_ADDRBUFSIZE
],
pbuf
[
VTCP_PORTBUFSIZE
];
char
abuf
[
VTCP_ADDRBUFSIZE
],
pbuf
[
VTCP_PORTBUFSIZE
];
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
)
;
bo
=
ctx
->
bo
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
wrk
=
ctx
->
bo
->
wrk
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
/*
/*
...
@@ -254,7 +259,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
...
@@ -254,7 +259,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
* that the backend closed it before we got the bereq to it.
* that the backend closed it before we got the bereq to it.
* In that case do a single automatic retry if req.body allows.
* In that case do a single automatic retry if req.body allows.
*/
*/
vbe_dir_finish
(
d
,
wrk
,
bo
);
vbe_dir_finish
(
ctx
,
d
);
AZ
(
bo
->
htc
);
AZ
(
bo
->
htc
);
if
(
i
<
0
||
extrachance
==
0
)
if
(
i
<
0
||
extrachance
==
0
)
break
;
break
;
...
@@ -267,25 +272,24 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
...
@@ -267,25 +272,24 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
return
(
-
1
);
return
(
-
1
);
}
}
static
const
struct
suckaddr
*
v_matchproto_
(
vdi_getip_f
)
static
VCL_IP
v_matchproto_
(
vdi_getip_f
)
vbe_dir_getip
(
const
struct
director
*
d
,
struct
worker
*
wrk
,
vbe_dir_getip
(
VRT_CTX
,
VCL_BACKEND
d
)
struct
busyobj
*
bo
)
{
{
struct
pfd
*
pfd
;
struct
pfd
*
pfd
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
->
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
->
htc
,
HTTP_CONN_MAGIC
);
pfd
=
ctx
->
bo
->
htc
->
priv
;
pfd
=
bo
->
htc
->
priv
;
return
(
VTP_getip
(
pfd
));
return
(
VTP_getip
(
pfd
));
}
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
enum
sess_close
static
enum
sess_close
v_matchproto_
(
vdi_http1pipe_f
)
vbe_dir_http1pipe
(
const
struct
director
*
d
,
struct
req
*
req
,
struct
busyobj
*
bo
)
vbe_dir_http1pipe
(
VRT_CTX
,
VCL_BACKEND
d
)
{
{
int
i
;
int
i
;
enum
sess_close
retval
;
enum
sess_close
retval
;
...
@@ -294,37 +298,38 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
...
@@ -294,37 +298,38 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
struct
pfd
*
pfd
;
struct
pfd
*
pfd
;
char
abuf
[
VTCP_ADDRBUFSIZE
],
pbuf
[
VTCP_PORTBUFSIZE
];
char
abuf
[
VTCP_ADDRBUFSIZE
],
pbuf
[
VTCP_PORTBUFSIZE
];
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
memset
(
&
v1a
,
0
,
sizeof
v1a
);
memset
(
&
v1a
,
0
,
sizeof
v1a
);
/* This is hackish... */
/* This is hackish... */
v1a
.
req
=
req
->
acct
.
req_hdrbytes
;
v1a
.
req
=
ctx
->
req
->
acct
.
req_hdrbytes
;
req
->
acct
.
req_hdrbytes
=
0
;
ctx
->
req
->
acct
.
req_hdrbytes
=
0
;
req
->
res_mode
=
RES_PIPE
;
ctx
->
req
->
res_mode
=
RES_PIPE
;
pfd
=
vbe_dir_getfd
(
req
->
wrk
,
bp
,
bo
,
0
);
pfd
=
vbe_dir_getfd
(
ctx
->
req
->
wrk
,
bp
,
ctx
->
bo
,
0
);
if
(
pfd
==
NULL
)
{
if
(
pfd
==
NULL
)
{
retval
=
SC_TX_ERROR
;
retval
=
SC_TX_ERROR
;
}
else
{
}
else
{
CHECK_OBJ_NOTNULL
(
bo
->
htc
,
HTTP_CONN_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
->
htc
,
HTTP_CONN_MAGIC
);
PFD_RemoteName
(
pfd
,
abuf
,
sizeof
abuf
,
pbuf
,
sizeof
pbuf
);
PFD_RemoteName
(
pfd
,
abuf
,
sizeof
abuf
,
pbuf
,
sizeof
pbuf
);
i
=
V1F_SendReq
(
req
->
wrk
,
bo
,
&
v1a
.
bereq
,
&
v1a
.
out
,
1
,
abuf
,
i
=
V1F_SendReq
(
ctx
->
req
->
wrk
,
ctx
->
bo
,
pbuf
);
&
v1a
.
bereq
,
&
v1a
.
out
,
1
,
abuf
,
pbuf
);
VSLb_ts_req
(
req
,
"Pipe"
,
W_TIM_real
(
req
->
wrk
));
VSLb_ts_req
(
ctx
->
req
,
"Pipe"
,
W_TIM_real
(
ctx
->
req
->
wrk
));
if
(
i
==
0
)
if
(
i
==
0
)
V1P_Process
(
req
,
*
PFD_Fd
(
pfd
),
&
v1a
);
V1P_Process
(
ctx
->
req
,
*
PFD_Fd
(
pfd
),
&
v1a
);
VSLb_ts_req
(
req
,
"PipeSess"
,
W_TIM_real
(
req
->
wrk
));
VSLb_ts_req
(
ctx
->
req
,
"PipeSess"
,
W_TIM_real
(
ctx
->
req
->
wrk
));
bo
->
htc
->
doclose
=
SC_TX_PIPE
;
ctx
->
bo
->
htc
->
doclose
=
SC_TX_PIPE
;
vbe_dir_finish
(
d
,
req
->
wrk
,
bo
);
vbe_dir_finish
(
ctx
,
d
);
retval
=
SC_TX_PIPE
;
retval
=
SC_TX_PIPE
;
}
}
V1P_Charge
(
req
,
&
v1a
,
bp
->
vsc
);
V1P_Charge
(
ctx
->
req
,
&
v1a
,
bp
->
vsc
);
return
(
retval
);
return
(
retval
);
}
}
...
...
bin/varnishd/cache/cache_director.c
View file @
4d0bf7ab
...
@@ -77,23 +77,21 @@ VDI_Ahealth(const struct director *d)
...
@@ -77,23 +77,21 @@ VDI_Ahealth(const struct director *d)
/* Resolve director --------------------------------------------------*/
/* Resolve director --------------------------------------------------*/
static
VCL_BACKEND
static
VCL_BACKEND
VDI_Resolve
(
struct
busyobj
*
bo
)
VDI_Resolve
(
VRT_CTX
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
const
struct
director
*
d2
;
const
struct
director
*
d2
;
struct
vrt_ctx
ctx
;
struct
busyobj
*
bo
;
bo
=
ctx
->
bo
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_ORNULL
(
bo
->
director_req
,
DIRECTOR_MAGIC
);
CHECK_OBJ_ORNULL
(
bo
->
director_req
,
DIRECTOR_MAGIC
);
INIT_OBJ
(
&
ctx
,
VRT_CTX_MAGIC
);
VCL_Bo2Ctx
(
&
ctx
,
bo
);
for
(
d
=
bo
->
director_req
;
d
!=
NULL
&&
for
(
d
=
bo
->
director_req
;
d
!=
NULL
&&
d
->
methods
->
resolve
!=
NULL
;
d
=
d2
)
{
d
->
methods
->
resolve
!=
NULL
;
d
=
d2
)
{
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
AN
(
d
->
vdir
);
AN
(
d
->
vdir
);
d2
=
d
->
methods
->
resolve
(
&
ctx
,
d
);
d2
=
d
->
methods
->
resolve
(
ctx
,
d
);
if
(
d2
==
NULL
)
if
(
d2
==
NULL
)
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"Director %s returned no backend"
,
d
->
vcl_name
);
"Director %s returned no backend"
,
d
->
vcl_name
);
...
@@ -109,20 +107,22 @@ VDI_Resolve(struct busyobj *bo)
...
@@ -109,20 +107,22 @@ VDI_Resolve(struct busyobj *bo)
/* Get a set of response headers -------------------------------------*/
/* Get a set of response headers -------------------------------------*/
int
int
VDI_GetHdr
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
VDI_GetHdr
(
struct
busyobj
*
bo
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
struct
vrt_ctx
ctx
[
1
];
int
i
=
-
1
;
int
i
=
-
1
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
INIT_OBJ
(
ctx
,
VRT_CTX_MAGIC
);
VCL_Bo2Ctx
(
ctx
,
bo
);
d
=
VDI_Resolve
(
bo
);
d
=
VDI_Resolve
(
ctx
);
if
(
d
!=
NULL
)
{
if
(
d
!=
NULL
)
{
bo
->
director_resp
=
d
;
bo
->
director_resp
=
d
;
AN
(
d
->
methods
->
gethdrs
);
AN
(
d
->
methods
->
gethdrs
);
bo
->
director_state
=
DIR_S_HDRS
;
bo
->
director_state
=
DIR_S_HDRS
;
i
=
d
->
methods
->
gethdrs
(
d
,
wrk
,
bo
);
i
=
d
->
methods
->
gethdrs
(
ctx
,
d
);
}
}
if
(
i
)
if
(
i
)
bo
->
director_state
=
DIR_S_NULL
;
bo
->
director_state
=
DIR_S_NULL
;
...
@@ -132,12 +132,14 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo)
...
@@ -132,12 +132,14 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo)
/* Setup body fetch --------------------------------------------------*/
/* Setup body fetch --------------------------------------------------*/
int
int
VDI_GetBody
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
VDI_GetBody
(
struct
busyobj
*
bo
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
struct
vrt_ctx
ctx
[
1
];
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
INIT_OBJ
(
ctx
,
VRT_CTX_MAGIC
);
VCL_Bo2Ctx
(
ctx
,
bo
);
d
=
bo
->
director_resp
;
d
=
bo
->
director_resp
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
...
@@ -147,18 +149,20 @@ VDI_GetBody(struct worker *wrk, struct busyobj *bo)
...
@@ -147,18 +149,20 @@ VDI_GetBody(struct worker *wrk, struct busyobj *bo)
bo
->
director_state
=
DIR_S_BODY
;
bo
->
director_state
=
DIR_S_BODY
;
if
(
d
->
methods
->
getbody
==
NULL
)
if
(
d
->
methods
->
getbody
==
NULL
)
return
(
0
);
return
(
0
);
return
(
d
->
methods
->
getbody
(
d
,
wrk
,
bo
));
return
(
d
->
methods
->
getbody
(
ctx
,
d
));
}
}
/* Get IP number (if any ) -------------------------------------------*/
/* Get IP number (if any ) -------------------------------------------*/
const
struct
suckaddr
*
VCL_IP
VDI_GetIP
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
VDI_GetIP
(
struct
busyobj
*
bo
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
struct
vrt_ctx
ctx
[
1
];
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
INIT_OBJ
(
ctx
,
VRT_CTX_MAGIC
);
VCL_Bo2Ctx
(
ctx
,
bo
);
d
=
bo
->
director_resp
;
d
=
bo
->
director_resp
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
...
@@ -167,18 +171,20 @@ VDI_GetIP(struct worker *wrk, struct busyobj *bo)
...
@@ -167,18 +171,20 @@ VDI_GetIP(struct worker *wrk, struct busyobj *bo)
AZ
(
d
->
methods
->
resolve
);
AZ
(
d
->
methods
->
resolve
);
if
(
d
->
methods
->
getip
==
NULL
)
if
(
d
->
methods
->
getip
==
NULL
)
return
(
NULL
);
return
(
NULL
);
return
(
d
->
methods
->
getip
(
d
,
wrk
,
bo
));
return
(
d
->
methods
->
getip
(
ctx
,
d
));
}
}
/* Finish fetch ------------------------------------------------------*/
/* Finish fetch ------------------------------------------------------*/
void
void
VDI_Finish
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
VDI_Finish
(
struct
busyobj
*
bo
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
struct
vrt_ctx
ctx
[
1
];
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
INIT_OBJ
(
ctx
,
VRT_CTX_MAGIC
);
VCL_Bo2Ctx
(
ctx
,
bo
);
d
=
bo
->
director_resp
;
d
=
bo
->
director_resp
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
...
@@ -187,7 +193,7 @@ VDI_Finish(struct worker *wrk, struct busyobj *bo)
...
@@ -187,7 +193,7 @@ VDI_Finish(struct worker *wrk, struct busyobj *bo)
AN
(
d
->
methods
->
finish
);
AN
(
d
->
methods
->
finish
);
assert
(
bo
->
director_state
!=
DIR_S_NULL
);
assert
(
bo
->
director_state
!=
DIR_S_NULL
);
d
->
methods
->
finish
(
d
,
wrk
,
bo
);
d
->
methods
->
finish
(
ctx
,
d
);
bo
->
director_state
=
DIR_S_NULL
;
bo
->
director_state
=
DIR_S_NULL
;
}
}
...
@@ -197,17 +203,21 @@ enum sess_close
...
@@ -197,17 +203,21 @@ enum sess_close
VDI_Http1Pipe
(
struct
req
*
req
,
struct
busyobj
*
bo
)
VDI_Http1Pipe
(
struct
req
*
req
,
struct
busyobj
*
bo
)
{
{
const
struct
director
*
d
;
const
struct
director
*
d
;
struct
vrt_ctx
ctx
[
1
];
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
INIT_OBJ
(
ctx
,
VRT_CTX_MAGIC
);
VCL_Req2Ctx
(
ctx
,
req
);
VCL_Bo2Ctx
(
ctx
,
bo
);
d
=
VDI_Resolve
(
bo
);
d
=
VDI_Resolve
(
ctx
);
if
(
d
==
NULL
||
d
->
methods
->
http1pipe
==
NULL
)
{
if
(
d
==
NULL
||
d
->
methods
->
http1pipe
==
NULL
)
{
VSLb
(
bo
->
vsl
,
SLT_VCL_Error
,
"Backend does not support pipe"
);
VSLb
(
bo
->
vsl
,
SLT_VCL_Error
,
"Backend does not support pipe"
);
return
(
SC_TX_ERROR
);
return
(
SC_TX_ERROR
);
}
}
bo
->
director_resp
=
d
;
bo
->
director_resp
=
d
;
return
(
d
->
methods
->
http1pipe
(
d
,
req
,
bo
));
return
(
d
->
methods
->
http1pipe
(
ctx
,
d
));
}
}
/* Check health --------------------------------------------------------
/* Check health --------------------------------------------------------
...
...
bin/varnishd/cache/cache_director.h
View file @
4d0bf7ab
...
@@ -41,22 +41,14 @@ struct vcldir;
...
@@ -41,22 +41,14 @@ struct vcldir;
typedef
VCL_BOOL
vdi_healthy_f
(
VRT_CTX
,
VCL_BACKEND
,
VCL_TIME
*
);
typedef
VCL_BOOL
vdi_healthy_f
(
VRT_CTX
,
VCL_BACKEND
,
VCL_TIME
*
);
typedef
VCL_BACKEND
vdi_resolve_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
VCL_BACKEND
vdi_resolve_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
int
vdi_gethdrs_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
int
vdi_gethdrs_f
(
VCL_BACKEND
,
struct
worker
*
,
struct
busyobj
*
);
typedef
int
vdi_getbody_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
int
vdi_getbody_f
(
VCL_BACKEND
,
struct
worker
*
,
struct
busyobj
*
);
typedef
VCL_IP
vdi_getip_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
const
struct
suckaddr
*
vdi_getip_f
(
VCL_BACKEND
,
typedef
void
vdi_finish_f
(
VRT_CTX
,
VCL_BACKEND
);
struct
worker
*
,
struct
busyobj
*
);
typedef
enum
sess_close
vdi_http1pipe_f
(
VRT_CTX
,
VCL_BACKEND
);
typedef
void
vdi_finish_f
(
VCL_BACKEND
,
struct
worker
*
,
struct
busyobj
*
);
typedef
enum
sess_close
vdi_http1pipe_f
(
VCL_BACKEND
,
struct
req
*
,
struct
busyobj
*
);
typedef
void
vdi_event_f
(
VCL_BACKEND
,
enum
vcl_event_e
);
typedef
void
vdi_event_f
(
VCL_BACKEND
,
enum
vcl_event_e
);
typedef
void
vdi_destroy_f
(
VCL_BACKEND
);
typedef
void
vdi_destroy_f
(
VCL_BACKEND
);
typedef
void
vdi_panic_f
(
VCL_BACKEND
,
struct
vsb
*
);
typedef
void
vdi_panic_f
(
VCL_BACKEND
,
struct
vsb
*
);
typedef
void
vdi_list_f
(
VCL_BACKEND
,
struct
vsb
*
,
int
,
int
);
typedef
void
vdi_list_f
(
VCL_BACKEND
,
struct
vsb
*
,
int
,
int
);
struct
director_methods
{
struct
director_methods
{
...
...
bin/varnishd/cache/cache_fetch.c
View file @
4d0bf7ab
...
@@ -290,7 +290,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -290,7 +290,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
bo
->
vfc
->
resp
=
bo
->
beresp
;
bo
->
vfc
->
resp
=
bo
->
beresp
;
bo
->
vfc
->
req
=
bo
->
bereq
;
bo
->
vfc
->
req
=
bo
->
bereq
;
i
=
VDI_GetHdr
(
wrk
,
bo
);
i
=
VDI_GetHdr
(
bo
);
now
=
W_TIM_real
(
wrk
);
now
=
W_TIM_real
(
wrk
);
VSLb_ts_busyobj
(
bo
,
"Beresp"
,
now
);
VSLb_ts_busyobj
(
bo
,
"Beresp"
,
now
);
...
@@ -304,7 +304,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -304,7 +304,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
bo
->
htc
->
doclose
=
SC_RX_BODY
;
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Body cannot be fetched"
);
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Body cannot be fetched"
);
assert
(
bo
->
director_state
==
DIR_S_NULL
);
assert
(
bo
->
director_state
==
DIR_S_NULL
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
...
@@ -375,7 +375,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -375,7 +375,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
VSLb
(
bo
->
vsl
,
SLT_Error
,
VSLb
(
bo
->
vsl
,
SLT_Error
,
"304 response but not conditional fetch"
);
"304 response but not conditional fetch"
);
bo
->
htc
->
doclose
=
SC_RX_BAD
;
bo
->
htc
->
doclose
=
SC_RX_BAD
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
}
}
}
}
...
@@ -384,7 +384,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -384,7 +384,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
if
(
wrk
->
handling
==
VCL_RET_ABANDON
||
wrk
->
handling
==
VCL_RET_FAIL
)
{
if
(
wrk
->
handling
==
VCL_RET_ABANDON
||
wrk
->
handling
==
VCL_RET_FAIL
)
{
bo
->
htc
->
doclose
=
SC_RESP_CLOSE
;
bo
->
htc
->
doclose
=
SC_RESP_CLOSE
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_FAIL
);
return
(
F_STP_FAIL
);
}
}
...
@@ -392,7 +392,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -392,7 +392,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
htc
->
body_status
!=
BS_NONE
)
if
(
bo
->
htc
->
body_status
!=
BS_NONE
)
bo
->
htc
->
doclose
=
SC_RESP_CLOSE
;
bo
->
htc
->
doclose
=
SC_RESP_CLOSE
;
if
(
bo
->
director_state
!=
DIR_S_NULL
)
if
(
bo
->
director_state
!=
DIR_S_NULL
)
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
if
(
bo
->
retries
++
<
cache_param
->
max_retries
)
if
(
bo
->
retries
++
<
cache_param
->
max_retries
)
return
(
F_STP_RETRY
);
return
(
F_STP_RETRY
);
...
@@ -483,7 +483,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
...
@@ -483,7 +483,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
(
void
)
VFP_Error
(
vfc
,
"Fetch pipeline failed to process"
);
(
void
)
VFP_Error
(
vfc
,
"Fetch pipeline failed to process"
);
bo
->
htc
->
doclose
=
SC_RX_BODY
;
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VFP_Close
(
vfc
);
VFP_Close
(
vfc
);
VDI_Finish
(
wrk
,
bo
);
VDI_Finish
(
bo
);
if
(
!
bo
->
do_stream
)
{
if
(
!
bo
->
do_stream
)
{
assert
(
bo
->
fetch_objcore
->
boc
->
state
<
BOS_STREAM
);
assert
(
bo
->
fetch_objcore
->
boc
->
state
<
BOS_STREAM
);
// XXX: doclose = ?
// XXX: doclose = ?
...
@@ -612,7 +612,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
...
@@ -612,7 +612,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
filter_list
==
NULL
||
if
(
bo
->
filter_list
==
NULL
||
VCL_StackVFP
(
bo
->
vfc
,
bo
->
vcl
,
bo
->
filter_list
))
{
VCL_StackVFP
(
bo
->
vfc
,
bo
->
vcl
,
bo
->
filter_list
))
{
(
bo
)
->
htc
->
doclose
=
SC_OVERLOAD
;
(
bo
)
->
htc
->
doclose
=
SC_OVERLOAD
;
VDI_Finish
(
(
bo
)
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
}
}
...
@@ -624,7 +624,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
...
@@ -624,7 +624,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if
(
VFP_Open
(
bo
->
vfc
))
{
if
(
VFP_Open
(
bo
->
vfc
))
{
(
void
)
VFP_Error
(
bo
->
vfc
,
"Fetch pipeline failed to open"
);
(
void
)
VFP_Error
(
bo
->
vfc
,
"Fetch pipeline failed to open"
);
bo
->
htc
->
doclose
=
SC_RX_BODY
;
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
}
}
...
@@ -632,7 +632,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
...
@@ -632,7 +632,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
(
void
)
VFP_Error
(
bo
->
vfc
,
"Could not get storage"
);
(
void
)
VFP_Error
(
bo
->
vfc
,
"Could not get storage"
);
bo
->
htc
->
doclose
=
SC_RX_BODY
;
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VFP_Close
(
bo
->
vfc
);
VFP_Close
(
bo
->
vfc
);
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
}
}
...
@@ -648,12 +648,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
...
@@ -648,12 +648,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
ObjSetFlag
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OF_IMSCAND
,
1
);
ObjSetFlag
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OF_IMSCAND
,
1
);
if
(
bo
->
htc
->
body_status
!=
BS_NONE
&&
if
(
bo
->
htc
->
body_status
!=
BS_NONE
&&
VDI_GetBody
(
bo
->
wrk
,
bo
)
!=
0
)
{
VDI_GetBody
(
bo
)
!=
0
)
{
(
void
)
VFP_Error
(
bo
->
vfc
,
(
void
)
VFP_Error
(
bo
->
vfc
,
"GetBody failed - workspace_backend overflow?"
);
"GetBody failed - workspace_backend overflow?"
);
VFP_Close
(
bo
->
vfc
);
VFP_Close
(
bo
->
vfc
);
bo
->
htc
->
doclose
=
SC_OVERLOAD
;
bo
->
htc
->
doclose
=
SC_OVERLOAD
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
return
(
F_STP_ERROR
);
return
(
F_STP_ERROR
);
}
}
...
@@ -698,7 +698,7 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo)
...
@@ -698,7 +698,7 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo)
/* Recycle the backend connection before setting BOS_FINISHED to
/* Recycle the backend connection before setting BOS_FINISHED to
give predictable backend reuse behavior for varnishtest */
give predictable backend reuse behavior for varnishtest */
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
ObjSetState
(
wrk
,
bo
->
fetch_objcore
,
BOS_FINISHED
);
ObjSetState
(
wrk
,
bo
->
fetch_objcore
,
BOS_FINISHED
);
VSLb_ts_busyobj
(
bo
,
"BerespBody"
,
W_TIM_real
(
wrk
));
VSLb_ts_busyobj
(
bo
,
"BerespBody"
,
W_TIM_real
(
wrk
));
...
@@ -763,7 +763,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -763,7 +763,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
stale_oc
->
flags
&
OC_F_FAILED
)
if
(
bo
->
stale_oc
->
flags
&
OC_F_FAILED
)
(
void
)
VFP_Error
(
bo
->
vfc
,
"Template object failed"
);
(
void
)
VFP_Error
(
bo
->
vfc
,
"Template object failed"
);
if
(
bo
->
vfc
->
failed
)
{
if
(
bo
->
vfc
->
failed
)
{
VDI_Finish
(
bo
->
wrk
,
bo
);
VDI_Finish
(
bo
);
wrk
->
stats
->
fetch_failed
++
;
wrk
->
stats
->
fetch_failed
++
;
return
(
F_STP_FAIL
);
return
(
F_STP_FAIL
);
}
}
...
...
bin/varnishd/cache/cache_varnishd.h
View file @
4d0bf7ab
...
@@ -116,10 +116,10 @@ struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
...
@@ -116,10 +116,10 @@ struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
void
VBO_ReleaseBusyObj
(
struct
worker
*
wrk
,
struct
busyobj
**
busyobj
);
void
VBO_ReleaseBusyObj
(
struct
worker
*
wrk
,
struct
busyobj
**
busyobj
);
/* cache_director.c */
/* cache_director.c */
int
VDI_GetHdr
(
struct
worker
*
,
struct
busyobj
*
);
int
VDI_GetHdr
(
struct
busyobj
*
);
int
VDI_GetBody
(
struct
worker
*
,
struct
busyobj
*
);
int
VDI_GetBody
(
struct
busyobj
*
);
const
struct
suckaddr
*
VDI_GetIP
(
struct
worker
*
,
struct
busyobj
*
);
VCL_IP
VDI_GetIP
(
struct
busyobj
*
);
void
VDI_Finish
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
);
void
VDI_Finish
(
struct
busyobj
*
bo
);
enum
sess_close
VDI_Http1Pipe
(
struct
req
*
,
struct
busyobj
*
);
enum
sess_close
VDI_Http1Pipe
(
struct
req
*
,
struct
busyobj
*
);
void
VDI_Panic
(
const
struct
director
*
,
struct
vsb
*
,
const
char
*
nm
);
void
VDI_Panic
(
const
struct
director
*
,
struct
vsb
*
,
const
char
*
nm
);
void
VDI_Event
(
const
struct
director
*
d
,
enum
vcl_event_e
ev
);
void
VDI_Event
(
const
struct
director
*
d
,
enum
vcl_event_e
ev
);
...
...
bin/varnishd/cache/cache_vrt_var.c
View file @
4d0bf7ab
...
@@ -337,7 +337,7 @@ VRT_r_beresp_backend_ip(VRT_CTX)
...
@@ -337,7 +337,7 @@ VRT_r_beresp_backend_ip(VRT_CTX)
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
return
(
VDI_GetIP
(
ctx
->
bo
->
wrk
,
ctx
->
bo
));
return
(
VDI_GetIP
(
ctx
->
bo
));
}
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
...
...
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