Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
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
Hide 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 {
...
@@ -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
{
struct
worker
{
unsigned
magic
;
unsigned
magic
;
#define WORKER_MAGIC 0x6391adcf
#define WORKER_MAGIC 0x6391adcf
...
@@ -301,6 +308,8 @@ struct worker {
...
@@ -301,6 +308,8 @@ struct worker {
struct
dstat
stats
;
struct
dstat
stats
;
/* Pool stuff */
/* Pool stuff */
enum
e_do_what
do_what
;
double
lastused
;
double
lastused
;
struct
wrw
wrw
;
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)
...
@@ -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
));
assert
(
sizeof
*
wa2
==
WS_Reserve
(
w2
->
ws
,
sizeof
*
wa2
));
wa2
=
(
void
*
)
w2
->
ws
->
f
;
wa2
=
(
void
*
)
w2
->
ws
->
f
;
memcpy
(
wa2
,
wa
,
sizeof
*
wa
);
memcpy
(
wa2
,
wa
,
sizeof
*
wa
);
w2
->
do_what
=
pool_do_accept
;
AZ
(
pthread_cond_signal
(
&
w2
->
cond
));
AZ
(
pthread_cond_signal
(
&
w2
->
cond
));
}
}
}
}
...
@@ -190,6 +191,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
...
@@ -190,6 +191,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
while
(
1
)
{
while
(
1
)
{
Lck_AssertHeld
(
&
pp
->
mtx
);
Lck_AssertHeld
(
&
pp
->
mtx
);
w
->
do_what
=
pool_do_inval
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
resp
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
resp
,
HTTP_MAGIC
);
...
@@ -201,6 +203,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
...
@@ -201,6 +203,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
/* Process queued requests, if any */
/* Process queued requests, if any */
assert
(
pp
->
lqueue
>
0
);
assert
(
pp
->
lqueue
>
0
);
VTAILQ_REMOVE
(
&
pp
->
queue
,
w
->
sp
,
poollist
);
VTAILQ_REMOVE
(
&
pp
->
queue
,
w
->
sp
,
poollist
);
w
->
do_what
=
pool_do_sess
;
pp
->
lqueue
--
;
pp
->
lqueue
--
;
}
else
if
(
!
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
}
else
if
(
!
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Accept on a socket */
/* Accept on a socket */
...
@@ -215,6 +218,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
...
@@ -215,6 +218,7 @@ Pool_Work_Thread(void *priv, struct worker *w)
continue
;
continue
;
}
}
VTAILQ_INSERT_TAIL
(
&
pp
->
socks
,
ps
,
list
);
VTAILQ_INSERT_TAIL
(
&
pp
->
socks
,
ps
,
list
);
w
->
do_what
=
pool_do_accept
;
}
else
if
(
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
}
else
if
(
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Nothing to do: To sleep, perchance to dream ... */
/* Nothing to do: To sleep, perchance to dream ... */
if
(
isnan
(
w
->
lastused
))
if
(
isnan
(
w
->
lastused
))
...
@@ -225,29 +229,27 @@ Pool_Work_Thread(void *priv, struct worker *w)
...
@@ -225,29 +229,27 @@ Pool_Work_Thread(void *priv, struct worker *w)
(
void
)
Lck_CondWait
(
&
w
->
cond
,
&
pp
->
mtx
,
NULL
);
(
void
)
Lck_CondWait
(
&
w
->
cond
,
&
pp
->
mtx
,
NULL
);
}
}
/*
if
(
w
->
do_what
==
pool_do_die
)
* 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
)
break
;
break
;
Lck_Unlock
(
&
pp
->
mtx
);
Lck_Unlock
(
&
pp
->
mtx
);
if
(
w
->
sp
==
NULL
)
{
if
(
w
->
do_what
==
pool_do_accept
)
{
/* Turn accepted socket into a session */
/* 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
);
w
->
sp
=
SES_New
(
w
,
pp
->
sesspool
);
if
(
w
->
sp
==
NULL
)
if
(
w
->
sp
==
NULL
)
VCA_FailSess
(
w
);
VCA_FailSess
(
w
);
else
else
VCA_SetupSess
(
w
);
VCA_SetupSess
(
w
);
WS_Release
(
w
->
ws
,
0
);
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
);
CHECK_OBJ_NOTNULL
(
w
->
sp
,
SESS_MAGIC
);
AZ
(
w
->
ws
->
r
);
stats_clean
=
0
;
stats_clean
=
0
;
w
->
lastused
=
NAN
;
w
->
lastused
=
NAN
;
...
@@ -270,6 +272,8 @@ Pool_Work_Thread(void *priv, struct worker *w)
...
@@ -270,6 +272,8 @@ Pool_Work_Thread(void *priv, struct worker *w)
if
(
w
->
vcl
!=
NULL
)
if
(
w
->
vcl
!=
NULL
)
VCL_Rel
(
&
w
->
vcl
);
VCL_Rel
(
&
w
->
vcl
);
}
}
}
else
{
WRONG
(
"Invalid w->do_what"
);
}
}
stats_clean
=
WRK_TrySumStat
(
w
);
stats_clean
=
WRK_TrySumStat
(
w
);
Lck_Lock
(
&
pp
->
mtx
);
Lck_Lock
(
&
pp
->
mtx
);
...
@@ -297,6 +301,7 @@ pool_queue(struct pool *pp, struct sess *sp)
...
@@ -297,6 +301,7 @@ pool_queue(struct pool *pp, struct sess *sp)
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
,
list
);
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
,
list
);
Lck_Unlock
(
&
pp
->
mtx
);
Lck_Unlock
(
&
pp
->
mtx
);
w
->
sp
=
sp
;
w
->
sp
=
sp
;
w
->
do_what
=
pool_do_sess
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
return
(
0
);
return
(
0
);
}
}
...
@@ -469,6 +474,7 @@ pool_herder(void *priv)
...
@@ -469,6 +474,7 @@ pool_herder(void *priv)
VSC_C_main
->
threads_destroyed
++
;
VSC_C_main
->
threads_destroyed
++
;
Lck_Unlock
(
&
pool_mtx
);
Lck_Unlock
(
&
pool_mtx
);
AZ
(
w
->
sp
);
AZ
(
w
->
sp
);
w
->
do_what
=
pool_do_die
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
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