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
6a04b34e
Commit
6a04b34e
authored
Jan 23, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tell the waiter (if necessary) that we steal a filedescriptor, not
all of them find out on their own.
parent
4d9f776a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
0 deletions
+54
-0
cache_backend_tcp.c
bin/varnishd/cache/cache_backend_tcp.c
+2
-0
cache_waiter.c
bin/varnishd/waiter/cache_waiter.c
+39
-0
cache_waiter_kqueue.c
bin/varnishd/waiter/cache_waiter_kqueue.c
+12
-0
waiter.h
bin/varnishd/waiter/waiter.h
+1
-0
No files found.
bin/varnishd/cache/cache_backend_tcp.c
View file @
6a04b34e
...
...
@@ -384,6 +384,8 @@ VBT_Get(struct tcp_pool *tp, double tmo)
CHECK_OBJ_NOTNULL
(
vbc
,
VBC_MAGIC
);
assert
(
vbc
->
in_waiter
==
VBC_W_INWAIT
);
VSL
(
SLT_Debug
,
0
,
"------> Steal fd %d"
,
vbc
->
fd
);
Wait_Steal
(
tp
->
waiter
,
vbc
->
waited
);
vbc
->
in_waiter
=
VBC_W_STOLEN
;
pfd
.
fd
=
vbc
->
fd
;
pfd
.
events
=
POLLIN
;
...
...
bin/varnishd/waiter/cache_waiter.c
View file @
6a04b34e
...
...
@@ -203,6 +203,36 @@ Wait_Enter(const struct waiter *w, struct waited *wp)
return
(
0
);
}
int
Wait_Steal
(
const
struct
waiter
*
w
,
struct
waited
*
wp
)
{
ssize_t
written
;
uintptr_t
up
;
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
assert
(
wp
->
fd
>
0
);
// stdin never comes here
AZ
(
w
->
dismantle
);
if
(
w
->
impl
->
pass
!=
NULL
)
{
INCOMPL
();
}
assert
(
w
->
pipes
[
1
]
>
0
);
if
(
w
->
impl
->
evict
==
NULL
)
return
(
0
);
up
=
(
uintptr_t
)
wp
;
AZ
(
up
&
1
);
up
|=
1
;
written
=
write
(
w
->
pipes
[
1
],
&
up
,
sizeof
up
);
if
(
written
!=
sizeof
up
&&
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
))
return
(
-
1
);
assert
(
written
==
sizeof
up
);
return
(
0
);
}
static
void
wait_updidle
(
struct
waiter
*
w
,
double
now
)
{
...
...
@@ -226,6 +256,7 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now)
uintptr_t
ss
[
NEV
];
struct
waited
*
wp2
;
int
i
,
j
,
dotimer
=
0
;
int
steal
;
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
...
...
@@ -253,9 +284,17 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now)
AN
(
w
->
dismantle
);
continue
;
}
steal
=
ss
[
j
]
&
1
;
ss
[
j
]
&=
~
1
;
CAST_OBJ_NOTNULL
(
wp2
,
(
void
*
)
ss
[
j
],
WAITED_MAGIC
);
if
(
wp2
==
w
->
pipe_w
)
{
dotimer
=
1
;
}
else
if
(
steal
)
{
assert
(
wp2
->
fd
>=
0
);
VTAILQ_REMOVE
(
&
w
->
waithead
,
wp2
,
list
);
AN
(
w
->
impl
->
evict
);
w
->
impl
->
evict
(
w
,
wp2
);
w
->
func
(
wp2
,
WAITER_ACTION
,
now
);
}
else
{
assert
(
wp2
->
fd
>=
0
);
VTAILQ_INSERT_TAIL
(
&
w
->
waithead
,
wp2
,
list
);
...
...
bin/varnishd/waiter/cache_waiter_kqueue.c
View file @
6a04b34e
...
...
@@ -99,6 +99,17 @@ vwk_inject(const struct waiter *w, struct waited *wp)
vwk_kq_sess
(
vwk
,
wp
,
EV_ADD
|
EV_ONESHOT
);
}
#if 0
static void
vwk_evict(const struct waiter *w, struct waited *wp)
{
struct vwk *vwk;
CAST_OBJ_NOTNULL(vwk, w->priv, VWK_MAGIC);
vwk_kq_sess(vwk, wp, EV_DELETE);
}
#endif
/*--------------------------------------------------------------------*/
static
void
...
...
@@ -193,6 +204,7 @@ const struct waiter_impl waiter_kqueue = {
.
init
=
vwk_init
,
.
fini
=
vwk_fini
,
.
inject
=
vwk_inject
,
// .evict = vwk_evict,
.
size
=
sizeof
(
struct
vwk
),
};
...
...
bin/varnishd/waiter/waiter.h
View file @
6a04b34e
...
...
@@ -58,6 +58,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now);
/* cache_waiter.c */
int
Wait_Enter
(
const
struct
waiter
*
,
struct
waited
*
);
int
Wait_Steal
(
const
struct
waiter
*
,
struct
waited
*
);
struct
waiter
*
Wait_New
(
waiter_handle_f
*
,
volatile
double
*
timeout
);
void
Wait_Destroy
(
struct
waiter
**
);
const
char
*
Wait_GetName
(
void
);
...
...
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