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
6109c1d4
Commit
6109c1d4
authored
Jan 12, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass pointer to the timeout variable into the waiter on creation.
parent
d6ef2cdb
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
16 deletions
+27
-16
cache_session.c
bin/varnishd/cache/cache_session.c
+1
-1
cache_waiter.c
bin/varnishd/waiter/cache_waiter.c
+2
-2
cache_waiter_epoll.c
bin/varnishd/waiter/cache_waiter_epoll.c
+7
-3
cache_waiter_kqueue.c
bin/varnishd/waiter/cache_waiter_kqueue.c
+5
-2
cache_waiter_poll.c
bin/varnishd/waiter/cache_waiter_poll.c
+4
-2
cache_waiter_ports.c
bin/varnishd/waiter/cache_waiter_ports.c
+6
-4
waiter.h
bin/varnishd/waiter/waiter.h
+2
-2
No files found.
bin/varnishd/cache/cache_session.c
View file @
6109c1d4
...
@@ -467,7 +467,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no)
...
@@ -467,7 +467,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no)
bprintf
(
nb
,
"sess%u"
,
pool_no
);
bprintf
(
nb
,
"sess%u"
,
pool_no
);
pp
->
mpl_sess
=
MPL_New
(
nb
,
&
cache_param
->
sess_pool
,
pp
->
mpl_sess
=
MPL_New
(
nb
,
&
cache_param
->
sess_pool
,
&
cache_param
->
workspace_session
);
&
cache_param
->
workspace_session
);
pp
->
http1_waiter
=
WAIT_Init
(
ses_handle
);
pp
->
http1_waiter
=
WAIT_Init
(
ses_handle
,
&
cache_param
->
timeout_idle
);
return
(
pp
);
return
(
pp
);
}
}
...
...
bin/varnishd/waiter/cache_waiter.c
View file @
6109c1d4
...
@@ -58,7 +58,7 @@ WAIT_GetName(void)
...
@@ -58,7 +58,7 @@ WAIT_GetName(void)
}
}
struct
waiter
*
struct
waiter
*
WAIT_Init
(
waiter_handle_f
*
func
)
WAIT_Init
(
waiter_handle_f
*
func
,
volatile
double
*
tmo
)
{
{
struct
waiter
*
w
;
struct
waiter
*
w
;
...
@@ -70,7 +70,7 @@ WAIT_Init(waiter_handle_f *func)
...
@@ -70,7 +70,7 @@ WAIT_Init(waiter_handle_f *func)
AN
(
waiter
->
name
);
AN
(
waiter
->
name
);
AN
(
waiter
->
init
);
AN
(
waiter
->
init
);
w
->
impl
=
waiter
;
w
->
impl
=
waiter
;
w
->
priv
=
w
->
impl
->
init
(
func
,
&
w
->
pfd
);
w
->
priv
=
w
->
impl
->
init
(
func
,
&
w
->
pfd
,
tmo
);
AN
(
waiter
->
pass
||
w
->
pfd
>=
0
);
AN
(
waiter
->
pass
||
w
->
pfd
>=
0
);
return
(
w
);
return
(
w
);
}
}
...
...
bin/varnishd/waiter/cache_waiter_epoll.c
View file @
6109c1d4
...
@@ -60,6 +60,7 @@ struct vwe {
...
@@ -60,6 +60,7 @@ struct vwe {
int
epfd
;
int
epfd
;
waiter_handle_f
*
func
;
waiter_handle_f
*
func
;
volatile
double
*
tmo
;
VTAILQ_HEAD
(,
waited
)
sesshead
;
VTAILQ_HEAD
(,
waited
)
sesshead
;
int
pipes
[
2
];
int
pipes
[
2
];
...
@@ -178,7 +179,7 @@ vwe_thread(void *priv)
...
@@ -178,7 +179,7 @@ vwe_thread(void *priv)
continue
;
continue
;
/* check for timeouts */
/* check for timeouts */
deadline
=
now
-
cache_param
->
timeout_idle
;
deadline
=
now
-
*
vwe
->
tmo
;
for
(;;)
{
for
(;;)
{
sp
=
VTAILQ_FIRST
(
&
vwe
->
sesshead
);
sp
=
VTAILQ_FIRST
(
&
vwe
->
sesshead
);
if
(
sp
==
NULL
)
if
(
sp
==
NULL
)
...
@@ -186,7 +187,6 @@ vwe_thread(void *priv)
...
@@ -186,7 +187,6 @@ vwe_thread(void *priv)
if
(
sp
->
deadline
>
deadline
)
if
(
sp
->
deadline
>
deadline
)
break
;
break
;
VTAILQ_REMOVE
(
&
vwe
->
sesshead
,
sp
,
list
);
VTAILQ_REMOVE
(
&
vwe
->
sesshead
,
sp
,
list
);
// XXX: not yet VTCP_linger(sp->fd, 0);
vwe
->
func
(
sp
,
WAITER_TIMEOUT
,
now
);
vwe
->
func
(
sp
,
WAITER_TIMEOUT
,
now
);
}
}
}
}
...
@@ -215,14 +215,17 @@ vwe_timeout_idle_ticker(void *priv)
...
@@ -215,14 +215,17 @@ vwe_timeout_idle_ticker(void *priv)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
*
__match_proto__
(
waiter_init_f
)
static
void
*
__match_proto__
(
waiter_init_f
)
vwe_init
(
waiter_handle_f
*
func
,
int
*
pfd
)
vwe_init
(
waiter_handle_f
*
func
,
int
*
pfd
,
volatile
double
*
tmo
)
{
{
struct
vwe
*
vwe
;
struct
vwe
*
vwe
;
AN
(
func
);
AN
(
func
);
AN
(
pfd
);
AN
(
pfd
);
AN
(
tmo
);
ALLOC_OBJ
(
vwe
,
VWE_MAGIC
);
ALLOC_OBJ
(
vwe
,
VWE_MAGIC
);
AN
(
vwe
);
AN
(
vwe
);
VTAILQ_INIT
(
&
vwe
->
sesshead
);
VTAILQ_INIT
(
&
vwe
->
sesshead
);
AZ
(
pipe
(
vwe
->
pipes
));
AZ
(
pipe
(
vwe
->
pipes
));
AZ
(
pipe
(
vwe
->
timer_pipes
));
AZ
(
pipe
(
vwe
->
timer_pipes
));
...
@@ -232,6 +235,7 @@ vwe_init(waiter_handle_f *func, int *pfd)
...
@@ -232,6 +235,7 @@ vwe_init(waiter_handle_f *func, int *pfd)
AZ
(
VFIL_nonblocking
(
vwe
->
timer_pipes
[
0
]));
AZ
(
VFIL_nonblocking
(
vwe
->
timer_pipes
[
0
]));
vwe
->
func
=
func
;
vwe
->
func
=
func
;
vwe
->
tmo
=
tmo
;
*
pfd
=
vwe
->
pipes
[
1
];
*
pfd
=
vwe
->
pipes
[
1
];
AZ
(
pthread_create
(
&
vwe
->
timer_thread
,
AZ
(
pthread_create
(
&
vwe
->
timer_thread
,
...
...
bin/varnishd/waiter/cache_waiter_kqueue.c
View file @
6109c1d4
...
@@ -53,6 +53,7 @@ struct vwk {
...
@@ -53,6 +53,7 @@ struct vwk {
unsigned
magic
;
unsigned
magic
;
#define VWK_MAGIC 0x1cc2acc2
#define VWK_MAGIC 0x1cc2acc2
waiter_handle_f
*
func
;
waiter_handle_f
*
func
;
volatile
double
*
tmo
;
pthread_t
thread
;
pthread_t
thread
;
int
pipes
[
2
];
int
pipes
[
2
];
int
kq
;
int
kq
;
...
@@ -192,7 +193,7 @@ vwk_thread(void *priv)
...
@@ -192,7 +193,7 @@ vwk_thread(void *priv)
* would not know we meant "the old fd of this number".
* would not know we meant "the old fd of this number".
*/
*/
vwk_kq_flush
(
vwk
);
vwk_kq_flush
(
vwk
);
deadline
=
now
-
cache_param
->
timeout_idle
;
deadline
=
now
-
*
vwk
->
tmo
;
for
(;;)
{
for
(;;)
{
sp
=
VTAILQ_FIRST
(
&
vwk
->
sesshead
);
sp
=
VTAILQ_FIRST
(
&
vwk
->
sesshead
);
if
(
sp
==
NULL
)
if
(
sp
==
NULL
)
...
@@ -210,16 +211,18 @@ vwk_thread(void *priv)
...
@@ -210,16 +211,18 @@ vwk_thread(void *priv)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
*
__match_proto__
(
waiter_init_f
)
static
void
*
__match_proto__
(
waiter_init_f
)
vwk_init
(
waiter_handle_f
*
func
,
int
*
pfd
)
vwk_init
(
waiter_handle_f
*
func
,
int
*
pfd
,
volatile
double
*
tmo
)
{
{
struct
vwk
*
vwk
;
struct
vwk
*
vwk
;
AN
(
func
);
AN
(
func
);
AN
(
pfd
);
AN
(
pfd
);
AN
(
tmo
);
ALLOC_OBJ
(
vwk
,
VWK_MAGIC
);
ALLOC_OBJ
(
vwk
,
VWK_MAGIC
);
AN
(
vwk
);
AN
(
vwk
);
vwk
->
func
=
func
;
vwk
->
func
=
func
;
vwk
->
tmo
=
tmo
;
VTAILQ_INIT
(
&
vwk
->
sesshead
);
VTAILQ_INIT
(
&
vwk
->
sesshead
);
AZ
(
pipe
(
vwk
->
pipes
));
AZ
(
pipe
(
vwk
->
pipes
));
...
...
bin/varnishd/waiter/cache_waiter_poll.c
View file @
6109c1d4
...
@@ -46,6 +46,7 @@ struct vwp {
...
@@ -46,6 +46,7 @@ struct vwp {
unsigned
magic
;
unsigned
magic
;
#define VWP_MAGIC 0x4b2cc735
#define VWP_MAGIC 0x4b2cc735
waiter_handle_f
*
func
;
waiter_handle_f
*
func
;
volatile
double
*
tmo
;
int
pipes
[
2
];
int
pipes
[
2
];
pthread_t
poll_thread
;
pthread_t
poll_thread
;
struct
pollfd
*
pollfd
;
struct
pollfd
*
pollfd
;
...
@@ -144,7 +145,7 @@ vwp_main(void *priv)
...
@@ -144,7 +145,7 @@ vwp_main(void *priv)
v
=
poll
(
vwp
->
pollfd
,
vwp
->
hpoll
+
1
,
100
);
v
=
poll
(
vwp
->
pollfd
,
vwp
->
hpoll
+
1
,
100
);
assert
(
v
>=
0
);
assert
(
v
>=
0
);
now
=
VTIM_real
();
now
=
VTIM_real
();
deadline
=
now
-
cache_param
->
timeout_idle
;
deadline
=
now
-
*
vwp
->
tmo
;
v2
=
v
;
v2
=
v
;
VTAILQ_FOREACH_SAFE
(
sp
,
&
vwp
->
sesshead
,
list
,
sp2
)
{
VTAILQ_FOREACH_SAFE
(
sp
,
&
vwp
->
sesshead
,
list
,
sp2
)
{
if
(
v
!=
0
&&
v2
==
0
)
if
(
v
!=
0
&&
v2
==
0
)
...
@@ -194,7 +195,7 @@ vwp_main(void *priv)
...
@@ -194,7 +195,7 @@ vwp_main(void *priv)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
*
__match_proto__
(
waiter_init_f
)
static
void
*
__match_proto__
(
waiter_init_f
)
vwp_poll_init
(
waiter_handle_f
*
func
,
int
*
pfd
)
vwp_poll_init
(
waiter_handle_f
*
func
,
int
*
pfd
,
volatile
double
*
tmo
)
{
{
struct
vwp
*
vwp
;
struct
vwp
*
vwp
;
...
@@ -206,6 +207,7 @@ vwp_poll_init(waiter_handle_f *func, int *pfd)
...
@@ -206,6 +207,7 @@ vwp_poll_init(waiter_handle_f *func, int *pfd)
AZ
(
pipe
(
vwp
->
pipes
));
AZ
(
pipe
(
vwp
->
pipes
));
vwp
->
func
=
func
;
vwp
->
func
=
func
;
vwp
->
tmo
=
tmo
;
AZ
(
VFIL_nonblocking
(
vwp
->
pipes
[
1
]));
AZ
(
VFIL_nonblocking
(
vwp
->
pipes
[
1
]));
*
pfd
=
vwp
->
pipes
[
1
];
*
pfd
=
vwp
->
pipes
[
1
];
...
...
bin/varnishd/waiter/cache_waiter_ports.c
View file @
6109c1d4
...
@@ -51,6 +51,7 @@ struct vws {
...
@@ -51,6 +51,7 @@ struct vws {
unsigned
magic
;
unsigned
magic
;
#define VWS_MAGIC 0x0b771473
#define VWS_MAGIC 0x0b771473
waiter_handle_f
*
func
;
waiter_handle_f
*
func
;
volatile
double
*
tmo
;
pthread_t
ports_thread
;
pthread_t
ports_thread
;
int
dport
;
int
dport
;
VTAILQ_HEAD
(,
waited
)
sesshead
;
VTAILQ_HEAD
(,
waited
)
sesshead
;
...
@@ -192,7 +193,7 @@ vws_thread(void *priv)
...
@@ -192,7 +193,7 @@ vws_thread(void *priv)
vws_port_ev
(
vws
,
ev
+
ei
,
now
);
vws_port_ev
(
vws
,
ev
+
ei
,
now
);
/* check for timeouts */
/* check for timeouts */
deadline
=
now
-
cache_param
->
timeout_idle
;
deadline
=
now
-
*
vwk
->
tmo
;
/*
/*
* This loop assumes that the oldest sessions are always at the
* This loop assumes that the oldest sessions are always at the
...
@@ -220,8 +221,7 @@ vws_thread(void *priv)
...
@@ -220,8 +221,7 @@ vws_thread(void *priv)
*/
*/
if
(
sp
)
{
if
(
sp
)
{
double
tmo
=
double
tmo
=
(
sp
->
deadline
+
*
vws
->
tmo
)
-
now
;
(
sp
->
deadline
+
cache_param
->
timeout_idle
)
-
now
;
if
(
tmo
<
min_t
)
{
if
(
tmo
<
min_t
)
{
timeout
=
&
min_ts
;
timeout
=
&
min_ts
;
...
@@ -257,15 +257,17 @@ vws_pass(void *priv, struct waited *sp)
...
@@ -257,15 +257,17 @@ vws_pass(void *priv, struct waited *sp)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
*
__match_proto__
(
waiter_init_f
)
static
void
*
__match_proto__
(
waiter_init_f
)
vws_init
(
waiter_handle_f
*
func
,
int
*
pfd
)
vws_init
(
waiter_handle_f
*
func
,
int
*
pfd
,
volatile
double
*
tmo
)
{
{
struct
vws
*
vws
;
struct
vws
*
vws
;
AN
(
func
);
AN
(
func
);
AN
(
pfd
);
AN
(
pfd
);
AN
(
tmo
);
ALLOC_OBJ
(
vws
,
VWS_MAGIC
);
ALLOC_OBJ
(
vws
,
VWS_MAGIC
);
AN
(
vws
);
AN
(
vws
);
vws
->
func
=
func
;
vws
->
func
=
func
;
vws
->
tmo
=
tmo
;
VTAILQ_INIT
(
&
vws
->
sesshead
);
VTAILQ_INIT
(
&
vws
->
sesshead
);
AZ
(
pthread_create
(
&
vws
->
ports_thread
,
NULL
,
vws_thread
,
vws
));
AZ
(
pthread_create
(
&
vws
->
ports_thread
,
NULL
,
vws_thread
,
vws
));
return
(
vws
);
return
(
vws
);
...
...
bin/varnishd/waiter/waiter.h
View file @
6109c1d4
...
@@ -38,7 +38,7 @@ enum wait_event {
...
@@ -38,7 +38,7 @@ enum wait_event {
};
};
typedef
void
waiter_handle_f
(
struct
waited
*
,
enum
wait_event
,
double
now
);
typedef
void
waiter_handle_f
(
struct
waited
*
,
enum
wait_event
,
double
now
);
typedef
void
*
waiter_init_f
(
waiter_handle_f
*
,
int
*
);
typedef
void
*
waiter_init_f
(
waiter_handle_f
*
,
int
*
,
volatile
double
*
);
typedef
int
waiter_pass_f
(
void
*
priv
,
struct
waited
*
);
typedef
int
waiter_pass_f
(
void
*
priv
,
struct
waited
*
);
#define WAITER_DEFAULT "platform dependent"
#define WAITER_DEFAULT "platform dependent"
...
@@ -51,7 +51,7 @@ struct waiter_impl {
...
@@ -51,7 +51,7 @@ struct waiter_impl {
/* cache_waiter.c */
/* cache_waiter.c */
int
WAIT_Enter
(
const
struct
waiter
*
,
struct
waited
*
);
int
WAIT_Enter
(
const
struct
waiter
*
,
struct
waited
*
);
struct
waiter
*
WAIT_Init
(
waiter_handle_f
*
);
struct
waiter
*
WAIT_Init
(
waiter_handle_f
*
,
volatile
double
*
timeout
);
const
char
*
WAIT_GetName
(
void
);
const
char
*
WAIT_GetName
(
void
);
/* mgt_waiter.c */
/* mgt_waiter.c */
...
...
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