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
4c1e8266
Commit
4c1e8266
authored
Dec 19, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an explict enum to tell a worker what to do
parent
ae3733fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
cache.h
bin/varnishd/cache/cache.h
+9
-0
cache_pool.c
bin/varnishd/cache/cache_pool.c
+15
-9
No files found.
bin/varnishd/cache/cache.h
View file @
4c1e8266
...
...
@@ -289,6 +289,13 @@ struct wrk_accept {
/*--------------------------------------------------------------------*/
enum
e_do_what
{
pool_do_inval
=
0
,
pool_do_sess
,
pool_do_accept
,
pool_do_die
,
};
struct
worker
{
unsigned
magic
;
#define WORKER_MAGIC 0x6391adcf
...
...
@@ -301,6 +308,8 @@ struct worker {
struct
dstat
stats
;
/* Pool stuff */
enum
e_do_what
do_what
;
double
lastused
;
struct
wrw
wrw
;
...
...
bin/varnishd/cache/cache_pool.c
View file @
4c1e8266
...
...
@@ -168,6 +168,7 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
assert
(
sizeof
*
wa2
==
WS_Reserve
(
w2
->
ws
,
sizeof
*
wa2
));
wa2
=
(
void
*
)
w2
->
ws
->
f
;
memcpy
(
wa2
,
wa
,
sizeof
*
wa
);
w2
->
do_what
=
pool_do_accept
;
AZ
(
pthread_cond_signal
(
&
w2
->
cond
));
}
}
...
...
@@ -190,6 +191,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
while
(
1
)
{
Lck_AssertHeld
(
&
pp
->
mtx
);
w
->
do_what
=
pool_do_inval
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
resp
,
HTTP_MAGIC
);
...
...
@@ -201,6 +203,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
/* Process queued requests, if any */
assert
(
pp
->
lqueue
>
0
);
VTAILQ_REMOVE
(
&
pp
->
queue
,
w
->
sp
,
poollist
);
w
->
do_what
=
pool_do_sess
;
pp
->
lqueue
--
;
}
else
if
(
!
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Accept on a socket */
...
...
@@ -215,6 +218,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
continue
;
}
VTAILQ_INSERT_TAIL
(
&
pp
->
socks
,
ps
,
list
);
w
->
do_what
=
pool_do_accept
;
}
else
if
(
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Nothing to do: To sleep, perchance to dream ... */
if
(
isnan
(
w
->
lastused
))
...
...
@@ -225,29 +229,27 @@ Pool_Work_Thread(void *priv, struct worker *w)
(
void
)
Lck_CondWait
(
&
w
->
cond
,
&
pp
->
mtx
,
NULL
);
}
/*
* If we got neither session or accepted a socket, we were
* woken up to die to cull the herd.
*/
if
(
w
->
sp
==
NULL
&&
w
->
ws
->
r
==
NULL
)
if
(
w
->
do_what
==
pool_do_die
)
break
;
Lck_Unlock
(
&
pp
->
mtx
);
if
(
w
->
sp
==
NULL
)
{
if
(
w
->
do_what
==
pool_do_accept
)
{
/* Turn accepted socket into a session */
assert
(
w
->
ws
->
r
!=
NULL
);
AZ
(
w
->
sp
);
AN
(
w
->
ws
->
r
);
w
->
sp
=
SES_New
(
w
,
pp
->
sesspool
);
if
(
w
->
sp
==
NULL
)
VCA_FailSess
(
w
);
else
VCA_SetupSess
(
w
);
WS_Release
(
w
->
ws
,
0
);
w
->
do_what
=
pool_do_sess
;
}
assert
(
w
->
ws
->
r
==
NULL
);
if
(
w
->
sp
!=
NULL
)
{
if
(
w
->
do_what
==
pool_do_sess
)
{
CHECK_OBJ_NOTNULL
(
w
->
sp
,
SESS_MAGIC
);
AZ
(
w
->
ws
->
r
);
stats_clean
=
0
;
w
->
lastused
=
NAN
;
...
...
@@ -270,6 +272,8 @@ Pool_Work_Thread(void *priv, struct worker *w)
if
(
w
->
vcl
!=
NULL
)
VCL_Rel
(
&
w
->
vcl
);
}
}
else
{
WRONG
(
"Invalid w->do_what"
);
}
stats_clean
=
WRK_TrySumStat
(
w
);
Lck_Lock
(
&
pp
->
mtx
);
...
...
@@ -297,6 +301,7 @@ pool_queue(struct pool *pp, struct sess *sp)
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
,
list
);
Lck_Unlock
(
&
pp
->
mtx
);
w
->
sp
=
sp
;
w
->
do_what
=
pool_do_sess
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
return
(
0
);
}
...
...
@@ -469,6 +474,7 @@ pool_herder(void *priv)
VSC_C_main
->
threads_destroyed
++
;
Lck_Unlock
(
&
pool_mtx
);
AZ
(
w
->
sp
);
w
->
do_what
=
pool_do_die
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
}
}
...
...
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