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
41608b69
Commit
41608b69
authored
Dec 26, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always call struct worker variables "wrk" to ease grep'ing
parent
2955f0ba
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
155 deletions
+157
-155
cache_acceptor.c
bin/varnishd/cache/cache_acceptor.c
+10
-10
cache_cli.c
bin/varnishd/cache/cache_cli.c
+1
-0
cache_pool.c
bin/varnishd/cache/cache_pool.c
+80
-80
cache_response.c
bin/varnishd/cache/cache_response.c
+16
-16
cache_shmlog.c
bin/varnishd/cache/cache_shmlog.c
+38
-38
cache_wrk.c
bin/varnishd/cache/cache_wrk.c
+6
-6
hash_critbit.c
bin/varnishd/hash/hash_critbit.c
+6
-5
No files found.
bin/varnishd/cache/cache_acceptor.c
View file @
41608b69
...
...
@@ -220,15 +220,15 @@ VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa)
*/
void
VCA_FailSess
(
struct
worker
*
w
)
VCA_FailSess
(
struct
worker
*
w
rk
)
{
struct
wrk_accept
*
wa
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
wa
,
(
void
*
)
w
->
ws
->
f
,
WRK_ACCEPT_MAGIC
);
AZ
(
w
->
sp
);
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
wa
,
(
void
*
)
w
rk
->
ws
->
f
,
WRK_ACCEPT_MAGIC
);
AZ
(
w
rk
->
sp
);
AZ
(
close
(
wa
->
acceptsock
));
w
->
stats
.
sess_drop
++
;
w
rk
->
stats
.
sess_drop
++
;
vca_pace_bad
();
}
...
...
@@ -237,14 +237,14 @@ VCA_FailSess(struct worker *w)
*/
void
VCA_SetupSess
(
struct
worker
*
w
)
VCA_SetupSess
(
struct
worker
*
w
rk
)
{
struct
sess
*
sp
;
struct
wrk_accept
*
wa
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
wa
,
(
void
*
)
w
->
ws
->
f
,
WRK_ACCEPT_MAGIC
);
sp
=
w
->
sp
;
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
wa
,
(
void
*
)
w
rk
->
ws
->
f
,
WRK_ACCEPT_MAGIC
);
sp
=
w
rk
->
sp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
sp
->
fd
=
wa
->
acceptsock
;
sp
->
vsl_id
=
wa
->
acceptsock
|
VSL_CLIENTMARKER
;
...
...
@@ -258,7 +258,7 @@ VCA_SetupSess(struct worker *w)
memcpy
(
&
sp
->
sockaddr
,
&
wa
->
acceptaddr
,
wa
->
acceptaddrlen
);
sp
->
sockaddrlen
=
wa
->
acceptaddrlen
;
vca_pace_good
();
w
->
stats
.
sess_conn
++
;
w
rk
->
stats
.
sess_conn
++
;
if
(
need_test
)
sock_test
(
sp
->
fd
);
...
...
bin/varnishd/cache/cache_cli.c
View file @
41608b69
...
...
@@ -127,6 +127,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
SZOF
(
struct
http_conn
);
SZOF
(
struct
acct
);
SZOF
(
struct
worker
);
SZOF
(
struct
wrk_accept
);
SZOF
(
struct
storage
);
SZOF
(
struct
object
);
SZOF
(
struct
objcore
);
...
...
bin/varnishd/cache/cache_pool.c
View file @
41608b69
...
...
@@ -129,20 +129,20 @@ static pthread_t thr_pool_herder;
*/
static
int
pool_accept
(
struct
pool
*
pp
,
struct
worker
*
w
,
const
struct
poolsock
*
ps
)
pool_accept
(
struct
pool
*
pp
,
struct
worker
*
w
rk
,
const
struct
poolsock
*
ps
)
{
struct
worker
*
w2
;
struct
worker
*
w
rk
2
;
struct
wrk_accept
*
wa
,
*
wa2
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
ps
,
POOLSOCK_MAGIC
);
CHECK_OBJ_NOTNULL
(
ps
->
lsock
,
LISTEN_SOCK_MAGIC
);
Lck_AssertHeld
(
&
pp
->
mtx
);
Lck_Unlock
(
&
pp
->
mtx
);
assert
(
sizeof
*
wa
==
WS_Reserve
(
w
->
ws
,
sizeof
*
wa
));
wa
=
(
void
*
)
w
->
ws
->
f
;
assert
(
sizeof
*
wa
==
WS_Reserve
(
w
rk
->
ws
,
sizeof
*
wa
));
wa
=
(
void
*
)
w
rk
->
ws
->
f
;
while
(
1
)
{
memset
(
wa
,
0
,
sizeof
*
wa
);
wa
->
magic
=
WRK_ACCEPT_MAGIC
;
...
...
@@ -153,23 +153,23 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
return
(
-
1
);
}
if
(
VCA_Accept
(
ps
->
lsock
,
wa
)
<
0
)
{
w
->
stats
.
sess_fail
++
;
w
rk
->
stats
.
sess_fail
++
;
/* We're going to pace in vca anyway... */
(
void
)
WRK_TrySumStat
(
w
);
(
void
)
WRK_TrySumStat
(
w
rk
);
continue
;
}
Lck_Lock
(
&
pp
->
mtx
);
if
(
VTAILQ_EMPTY
(
&
pp
->
idle
))
return
(
0
);
w2
=
VTAILQ_FIRST
(
&
pp
->
idle
);
VTAILQ_REMOVE
(
&
pp
->
idle
,
w2
,
list
);
w
rk
2
=
VTAILQ_FIRST
(
&
pp
->
idle
);
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
rk
2
,
list
);
Lck_Unlock
(
&
pp
->
mtx
);
assert
(
sizeof
*
wa2
==
WS_Reserve
(
w2
->
ws
,
sizeof
*
wa2
));
wa2
=
(
void
*
)
w2
->
ws
->
f
;
assert
(
sizeof
*
wa2
==
WS_Reserve
(
w
rk
2
->
ws
,
sizeof
*
wa2
));
wa2
=
(
void
*
)
w
rk
2
->
ws
->
f
;
memcpy
(
wa2
,
wa
,
sizeof
*
wa
);
w2
->
do_what
=
pool_do_accept
;
AZ
(
pthread_cond_signal
(
&
w2
->
cond
));
w
rk
2
->
do_what
=
pool_do_accept
;
AZ
(
pthread_cond_signal
(
&
w
rk
2
->
cond
));
}
}
...
...
@@ -178,111 +178,111 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
*/
void
Pool_Work_Thread
(
void
*
priv
,
struct
worker
*
w
)
Pool_Work_Thread
(
void
*
priv
,
struct
worker
*
w
rk
)
{
struct
pool
*
pp
;
int
stats_clean
,
i
;
struct
poolsock
*
ps
;
CAST_OBJ_NOTNULL
(
pp
,
priv
,
POOL_MAGIC
);
w
->
pool
=
pp
;
w
rk
->
pool
=
pp
;
Lck_Lock
(
&
pp
->
mtx
);
stats_clean
=
1
;
while
(
1
)
{
Lck_AssertHeld
(
&
pp
->
mtx
);
w
->
do_what
=
pool_do_inval
;
w
rk
->
do_what
=
pool_do_inval
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
WS_Reset
(
w
->
ws
,
NULL
);
WS_Reset
(
w
rk
->
ws
,
NULL
);
w
->
sp
=
VTAILQ_FIRST
(
&
pp
->
queue
);
if
(
w
->
sp
!=
NULL
)
{
w
rk
->
sp
=
VTAILQ_FIRST
(
&
pp
->
queue
);
if
(
w
rk
->
sp
!=
NULL
)
{
/* Process queued requests, if any */
assert
(
pp
->
lqueue
>
0
);
VTAILQ_REMOVE
(
&
pp
->
queue
,
w
->
sp
,
poollist
);
w
->
do_what
=
pool_do_sess
;
VTAILQ_REMOVE
(
&
pp
->
queue
,
w
rk
->
sp
,
poollist
);
w
rk
->
do_what
=
pool_do_sess
;
pp
->
lqueue
--
;
}
else
if
(
!
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Accept on a socket */
ps
=
VTAILQ_FIRST
(
&
pp
->
socks
);
VTAILQ_REMOVE
(
&
pp
->
socks
,
ps
,
list
);
i
=
pool_accept
(
pp
,
w
,
ps
);
i
=
pool_accept
(
pp
,
w
rk
,
ps
);
Lck_AssertHeld
(
&
pp
->
mtx
);
if
(
i
<
0
)
{
/* Socket Shutdown */
FREE_OBJ
(
ps
);
WS_Release
(
w
->
ws
,
0
);
WS_Release
(
w
rk
->
ws
,
0
);
continue
;
}
VTAILQ_INSERT_TAIL
(
&
pp
->
socks
,
ps
,
list
);
w
->
do_what
=
pool_do_accept
;
w
rk
->
do_what
=
pool_do_accept
;
}
else
if
(
VTAILQ_EMPTY
(
&
pp
->
socks
))
{
/* Nothing to do: To sleep, perchance to dream ... */
if
(
isnan
(
w
->
lastused
))
w
->
lastused
=
VTIM_real
();
VTAILQ_INSERT_HEAD
(
&
pp
->
idle
,
w
,
list
);
if
(
isnan
(
w
rk
->
lastused
))
w
rk
->
lastused
=
VTIM_real
();
VTAILQ_INSERT_HEAD
(
&
pp
->
idle
,
w
rk
,
list
);
if
(
!
stats_clean
)
WRK_SumStat
(
w
);
(
void
)
Lck_CondWait
(
&
w
->
cond
,
&
pp
->
mtx
,
NULL
);
WRK_SumStat
(
w
rk
);
(
void
)
Lck_CondWait
(
&
w
rk
->
cond
,
&
pp
->
mtx
,
NULL
);
}
if
(
w
->
do_what
==
pool_do_die
)
if
(
w
rk
->
do_what
==
pool_do_die
)
break
;
Lck_Unlock
(
&
pp
->
mtx
);
if
(
w
->
do_what
==
pool_do_accept
)
{
if
(
w
rk
->
do_what
==
pool_do_accept
)
{
/* Turn accepted socket into a session */
AZ
(
w
->
sp
);
AN
(
w
->
ws
->
r
);
w
->
sp
=
SES_New
(
pp
->
sesspool
);
if
(
w
->
sp
==
NULL
)
{
VCA_FailSess
(
w
);
w
->
do_what
=
pool_do_nothing
;
AZ
(
w
rk
->
sp
);
AN
(
w
rk
->
ws
->
r
);
w
rk
->
sp
=
SES_New
(
pp
->
sesspool
);
if
(
w
rk
->
sp
==
NULL
)
{
VCA_FailSess
(
w
rk
);
w
rk
->
do_what
=
pool_do_nothing
;
}
else
{
VCA_SetupSess
(
w
);
w
->
sp
->
step
=
STP_FIRST
;
w
->
do_what
=
pool_do_sess
;
VCA_SetupSess
(
w
rk
);
w
rk
->
sp
->
step
=
STP_FIRST
;
w
rk
->
do_what
=
pool_do_sess
;
}
WS_Release
(
w
->
ws
,
0
);
WS_Release
(
w
rk
->
ws
,
0
);
}
if
(
w
->
do_what
==
pool_do_sess
)
{
CHECK_OBJ_NOTNULL
(
w
->
sp
,
SESS_MAGIC
);
AZ
(
w
->
ws
->
r
);
if
(
w
rk
->
do_what
==
pool_do_sess
)
{
CHECK_OBJ_NOTNULL
(
w
rk
->
sp
,
SESS_MAGIC
);
AZ
(
w
rk
->
ws
->
r
);
stats_clean
=
0
;
w
->
lastused
=
NAN
;
w
->
storage_hint
=
NULL
;
w
rk
->
lastused
=
NAN
;
w
rk
->
storage_hint
=
NULL
;
AZ
(
w
->
sp
->
wrk
);
THR_SetSession
(
w
->
sp
);
w
->
sp
->
wrk
=
w
;
CNT_Session
(
w
->
sp
);
AZ
(
w
rk
->
sp
->
wrk
);
THR_SetSession
(
w
rk
->
sp
);
w
rk
->
sp
->
wrk
=
wrk
;
CNT_Session
(
w
rk
->
sp
);
THR_SetSession
(
NULL
);
w
->
sp
=
NULL
;
w
rk
->
sp
=
NULL
;
WS_Assert
(
w
->
ws
);
AZ
(
w
->
busyobj
);
AZ
(
w
->
wrw
.
wfd
);
AZ
(
w
->
storage_hint
);
assert
(
w
->
wlp
==
w
->
wlb
);
WS_Assert
(
w
rk
->
ws
);
AZ
(
w
rk
->
busyobj
);
AZ
(
w
rk
->
wrw
.
wfd
);
AZ
(
w
rk
->
storage_hint
);
assert
(
w
rk
->
wlp
==
wrk
->
wlb
);
if
(
cache_param
->
diag_bitmap
&
0x00040000
)
{
if
(
w
->
vcl
!=
NULL
)
VCL_Rel
(
&
w
->
vcl
);
if
(
w
rk
->
vcl
!=
NULL
)
VCL_Rel
(
&
w
rk
->
vcl
);
}
}
else
if
(
w
->
do_what
==
pool_do_nothing
)
{
}
else
if
(
w
rk
->
do_what
==
pool_do_nothing
)
{
/* we already did */
}
else
{
WRONG
(
"Invalid w->do_what"
);
WRONG
(
"Invalid w
rk
->do_what"
);
}
stats_clean
=
WRK_TrySumStat
(
w
);
stats_clean
=
WRK_TrySumStat
(
w
rk
);
Lck_Lock
(
&
pp
->
mtx
);
}
Lck_Unlock
(
&
pp
->
mtx
);
w
->
pool
=
NULL
;
w
rk
->
pool
=
NULL
;
}
/*--------------------------------------------------------------------
...
...
@@ -294,18 +294,18 @@ Pool_Work_Thread(void *priv, struct worker *w)
static
int
pool_queue
(
struct
pool
*
pp
,
struct
sess
*
sp
)
{
struct
worker
*
w
;
struct
worker
*
w
rk
;
Lck_Lock
(
&
pp
->
mtx
);
/* If there are idle threads, we tickle the first one into action */
w
=
VTAILQ_FIRST
(
&
pp
->
idle
);
if
(
w
!=
NULL
)
{
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
,
list
);
w
rk
=
VTAILQ_FIRST
(
&
pp
->
idle
);
if
(
w
rk
!=
NULL
)
{
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
rk
,
list
);
Lck_Unlock
(
&
pp
->
mtx
);
w
->
sp
=
sp
;
w
->
do_what
=
pool_do_sess
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
w
rk
->
sp
=
sp
;
w
rk
->
do_what
=
pool_do_sess
;
AZ
(
pthread_cond_signal
(
&
w
rk
->
cond
));
return
(
0
);
}
...
...
@@ -397,7 +397,7 @@ pool_herder(void *priv)
pthread_attr_t
tp_attr
;
struct
timespec
ts
;
double
t_idle
;
struct
worker
*
w
;
struct
worker
*
w
rk
;
int
i
;
CAST_OBJ_NOTNULL
(
pp
,
priv
,
POOL_MAGIC
);
...
...
@@ -442,25 +442,25 @@ pool_herder(void *priv)
VSC_C_main
->
sess_queued
+=
pp
->
nqueued
;
VSC_C_main
->
sess_dropped
+=
pp
->
ndropped
;
pp
->
nqueued
=
pp
->
ndropped
=
0
;
w
=
VTAILQ_LAST
(
&
pp
->
idle
,
workerhead
);
if
(
w
!=
NULL
&&
(
w
->
lastused
<
t_idle
||
w
rk
=
VTAILQ_LAST
(
&
pp
->
idle
,
workerhead
);
if
(
w
rk
!=
NULL
&&
(
w
rk
->
lastused
<
t_idle
||
pp
->
nthr
>
cache_param
->
wthread_max
))
{
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
,
list
);
VTAILQ_REMOVE
(
&
pp
->
idle
,
w
rk
,
list
);
}
else
w
=
NULL
;
w
rk
=
NULL
;
Lck_Unlock
(
&
pp
->
mtx
);
/* And give it a kiss on the cheek... */
if
(
w
!=
NULL
)
{
if
(
w
rk
!=
NULL
)
{
pp
->
nthr
--
;
Lck_Lock
(
&
pool_mtx
);
VSC_C_main
->
threads
--
;
VSC_C_main
->
threads_destroyed
++
;
Lck_Unlock
(
&
pool_mtx
);
AZ
(
w
->
sp
);
w
->
do_what
=
pool_do_die
;
AZ
(
pthread_cond_signal
(
&
w
->
cond
));
AZ
(
w
rk
->
sp
);
w
rk
->
do_what
=
pool_do_die
;
AZ
(
pthread_cond_signal
(
&
w
rk
->
cond
));
}
}
NEEDLESS_RETURN
(
NULL
);
...
...
bin/varnishd/cache/cache_response.c
View file @
41608b69
...
...
@@ -359,52 +359,52 @@ RES_StreamStart(struct sess *sp)
}
void
RES_StreamPoll
(
struct
worker
*
w
)
RES_StreamPoll
(
struct
worker
*
w
rk
)
{
struct
stream_ctx
*
sctx
;
struct
storage
*
st
;
ssize_t
l
,
l2
;
void
*
ptr
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
busyobj
->
fetch_obj
,
OBJECT_MAGIC
);
sctx
=
w
->
sctx
;
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
->
busyobj
->
fetch_obj
,
OBJECT_MAGIC
);
sctx
=
w
rk
->
sctx
;
CHECK_OBJ_NOTNULL
(
sctx
,
STREAM_CTX_MAGIC
);
if
(
w
->
busyobj
->
fetch_obj
->
len
==
sctx
->
stream_next
)
if
(
w
rk
->
busyobj
->
fetch_obj
->
len
==
sctx
->
stream_next
)
return
;
assert
(
w
->
busyobj
->
fetch_obj
->
len
>
sctx
->
stream_next
);
assert
(
w
rk
->
busyobj
->
fetch_obj
->
len
>
sctx
->
stream_next
);
l
=
sctx
->
stream_front
;
VTAILQ_FOREACH
(
st
,
&
w
->
busyobj
->
fetch_obj
->
store
,
list
)
{
VTAILQ_FOREACH
(
st
,
&
w
rk
->
busyobj
->
fetch_obj
->
store
,
list
)
{
if
(
st
->
len
+
l
<=
sctx
->
stream_next
)
{
l
+=
st
->
len
;
continue
;
}
l2
=
st
->
len
+
l
-
sctx
->
stream_next
;
ptr
=
st
->
ptr
+
(
sctx
->
stream_next
-
l
);
if
(
w
->
res_mode
&
RES_GUNZIP
)
{
(
void
)
VGZ_WrwGunzip
(
w
,
sctx
->
vgz
,
ptr
,
l2
,
if
(
w
rk
->
res_mode
&
RES_GUNZIP
)
{
(
void
)
VGZ_WrwGunzip
(
w
rk
,
sctx
->
vgz
,
ptr
,
l2
,
sctx
->
obuf
,
sctx
->
obuf_len
,
&
sctx
->
obuf_ptr
);
}
else
{
(
void
)
WRW_Write
(
w
,
ptr
,
l2
);
(
void
)
WRW_Write
(
w
rk
,
ptr
,
l2
);
}
l
+=
st
->
len
;
sctx
->
stream_next
+=
l2
;
}
if
(
!
(
w
->
res_mode
&
RES_GUNZIP
))
(
void
)
WRW_Flush
(
w
);
if
(
!
(
w
rk
->
res_mode
&
RES_GUNZIP
))
(
void
)
WRW_Flush
(
w
rk
);
if
(
w
->
busyobj
->
fetch_obj
->
objcore
==
NULL
||
(
w
->
busyobj
->
fetch_obj
->
objcore
->
flags
&
OC_F_PASS
))
{
if
(
w
rk
->
busyobj
->
fetch_obj
->
objcore
==
NULL
||
(
w
rk
->
busyobj
->
fetch_obj
->
objcore
->
flags
&
OC_F_PASS
))
{
/*
* This is a pass object, release storage as soon as we
* have delivered it.
*/
while
(
1
)
{
st
=
VTAILQ_FIRST
(
&
w
->
busyobj
->
fetch_obj
->
store
);
st
=
VTAILQ_FIRST
(
&
w
rk
->
busyobj
->
fetch_obj
->
store
);
if
(
st
==
NULL
||
sctx
->
stream_front
+
st
->
len
>
sctx
->
stream_next
)
break
;
VTAILQ_REMOVE
(
&
w
->
busyobj
->
fetch_obj
->
store
,
st
,
list
);
VTAILQ_REMOVE
(
&
w
rk
->
busyobj
->
fetch_obj
->
store
,
st
,
list
);
sctx
->
stream_front
+=
st
->
len
;
STV_free
(
st
);
}
...
...
bin/varnishd/cache/cache_shmlog.c
View file @
41608b69
...
...
@@ -35,7 +35,7 @@
#include "cache.h"
#include "common/heritage.h"
#include "cache_backend.h" // For w->vbc
#include "cache_backend.h" // For w
rk
->vbc
#include "vmb.h"
#include "vtim.h"
...
...
@@ -180,30 +180,30 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...)
/*--------------------------------------------------------------------*/
void
WSL_Flush
(
struct
worker
*
w
,
int
overflow
)
WSL_Flush
(
struct
worker
*
w
rk
,
int
overflow
)
{
uint32_t
*
p
;
unsigned
l
;
l
=
pdiff
(
w
->
wlb
,
w
->
wlp
);
l
=
pdiff
(
w
rk
->
wlb
,
wrk
->
wlp
);
if
(
l
==
0
)
return
;
assert
(
l
>=
8
);
p
=
vsl_get
(
l
-
8
,
w
->
wlr
,
overflow
);
p
=
vsl_get
(
l
-
8
,
w
rk
->
wlr
,
overflow
);
memcpy
(
p
+
1
,
w
->
wlb
+
1
,
l
-
4
);
memcpy
(
p
+
1
,
w
rk
->
wlb
+
1
,
l
-
4
);
VWMB
();
p
[
0
]
=
w
->
wlb
[
0
];
w
->
wlp
=
w
->
wlb
;
w
->
wlr
=
0
;
p
[
0
]
=
w
rk
->
wlb
[
0
];
w
rk
->
wlp
=
wrk
->
wlb
;
w
rk
->
wlr
=
0
;
}
/*--------------------------------------------------------------------*/
void
WSLR
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
int
id
,
txt
t
)
WSLR
(
struct
worker
*
w
rk
,
enum
VSL_tag_e
tag
,
int
id
,
txt
t
)
{
unsigned
l
,
mlen
;
...
...
@@ -217,25 +217,25 @@ WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t)
t
.
e
=
t
.
b
+
l
;
}
assert
(
w
->
wlp
<
w
->
wle
);
assert
(
w
rk
->
wlp
<
wrk
->
wle
);
/* Wrap if necessary */
if
(
VSL_END
(
w
->
wlp
,
l
)
>=
w
->
wle
)
WSL_Flush
(
w
,
1
);
assert
(
VSL_END
(
w
->
wlp
,
l
)
<
w
->
wle
);
memcpy
(
VSL_DATA
(
w
->
wlp
),
t
.
b
,
l
);
vsl_hdr
(
tag
,
w
->
wlp
,
l
,
id
);
w
->
wlp
=
VSL_END
(
w
->
wlp
,
l
);
assert
(
w
->
wlp
<
w
->
wle
);
w
->
wlr
++
;
if
(
VSL_END
(
w
rk
->
wlp
,
l
)
>=
wrk
->
wle
)
WSL_Flush
(
w
rk
,
1
);
assert
(
VSL_END
(
w
rk
->
wlp
,
l
)
<
wrk
->
wle
);
memcpy
(
VSL_DATA
(
w
rk
->
wlp
),
t
.
b
,
l
);
vsl_hdr
(
tag
,
w
rk
->
wlp
,
l
,
id
);
w
rk
->
wlp
=
VSL_END
(
wrk
->
wlp
,
l
);
assert
(
w
rk
->
wlp
<
wrk
->
wle
);
w
rk
->
wlr
++
;
if
(
cache_param
->
diag_bitmap
&
0x10000
)
WSL_Flush
(
w
,
0
);
WSL_Flush
(
w
rk
,
0
);
}
/*--------------------------------------------------------------------*/
static
void
wsl
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
va_list
ap
)
wsl
(
struct
worker
*
w
rk
,
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
va_list
ap
)
{
char
*
p
;
unsigned
n
,
mlen
;
...
...
@@ -247,38 +247,38 @@ wsl(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
if
(
strchr
(
fmt
,
'%'
)
==
NULL
)
{
t
.
b
=
TRUST_ME
(
fmt
);
t
.
e
=
strchr
(
t
.
b
,
'\0'
);
WSLR
(
w
,
tag
,
id
,
t
);
WSLR
(
w
rk
,
tag
,
id
,
t
);
}
else
{
assert
(
w
->
wlp
<
w
->
wle
);
assert
(
w
rk
->
wlp
<
wrk
->
wle
);
/* Wrap if we cannot fit a full size record */
if
(
VSL_END
(
w
->
wlp
,
mlen
)
>=
w
->
wle
)
WSL_Flush
(
w
,
1
);
if
(
VSL_END
(
w
rk
->
wlp
,
mlen
)
>=
wrk
->
wle
)
WSL_Flush
(
w
rk
,
1
);
p
=
VSL_DATA
(
w
->
wlp
);
p
=
VSL_DATA
(
w
rk
->
wlp
);
n
=
vsnprintf
(
p
,
mlen
,
fmt
,
ap
);
if
(
n
>
mlen
)
n
=
mlen
;
/* we truncate long fields */
vsl_hdr
(
tag
,
w
->
wlp
,
n
,
id
);
w
->
wlp
=
VSL_END
(
w
->
wlp
,
n
);
assert
(
w
->
wlp
<
w
->
wle
);
w
->
wlr
++
;
vsl_hdr
(
tag
,
w
rk
->
wlp
,
n
,
id
);
w
rk
->
wlp
=
VSL_END
(
wrk
->
wlp
,
n
);
assert
(
w
rk
->
wlp
<
wrk
->
wle
);
w
rk
->
wlr
++
;
}
if
(
cache_param
->
diag_bitmap
&
0x10000
)
WSL_Flush
(
w
,
0
);
WSL_Flush
(
w
rk
,
0
);
}
/*--------------------------------------------------------------------*/
void
WSL
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
...)
WSL
(
struct
worker
*
w
rk
,
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
...)
{
va_list
ap
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
AN
(
fmt
);
va_start
(
ap
,
fmt
);
wsl
(
w
,
tag
,
id
,
fmt
,
ap
);
wsl
(
w
rk
,
tag
,
id
,
fmt
,
ap
);
va_end
(
ap
);
}
...
...
@@ -286,16 +286,16 @@ WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...)
/*--------------------------------------------------------------------*/
void
WSLB
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
const
char
*
fmt
,
...)
WSLB
(
struct
worker
*
w
rk
,
enum
VSL_tag_e
tag
,
const
char
*
fmt
,
...)
{
va_list
ap
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
busyobj
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
busyobj
->
vbc
,
VBC_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
->
busyobj
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
rk
->
busyobj
->
vbc
,
VBC_MAGIC
);
AN
(
fmt
);
va_start
(
ap
,
fmt
);
wsl
(
w
,
tag
,
w
->
busyobj
->
vbc
->
vsl_id
,
fmt
,
ap
);
wsl
(
w
rk
,
tag
,
wrk
->
busyobj
->
vbc
->
vsl_id
,
fmt
,
ap
);
va_end
(
ap
);
}
...
...
bin/varnishd/cache/cache_wrk.c
View file @
41608b69
...
...
@@ -94,7 +94,7 @@ static void *
wrk_bgthread
(
void
*
arg
)
{
struct
bgthread
*
bt
;
struct
worker
w
w
;
struct
worker
w
rk
;
struct
sess
*
sp
;
uint32_t
logbuf
[
1024
];
/* XXX: size ? */
...
...
@@ -102,11 +102,11 @@ wrk_bgthread(void *arg)
THR_SetName
(
bt
->
name
);
sp
=
SES_Alloc
();
XXXAN
(
sp
);
memset
(
&
w
w
,
0
,
sizeof
ww
);
sp
->
wrk
=
&
w
w
;
w
w
.
magic
=
WORKER_MAGIC
;
w
w
.
wlp
=
ww
.
wlb
=
logbuf
;
w
w
.
wle
=
logbuf
+
(
sizeof
logbuf
)
/
4
;
memset
(
&
w
rk
,
0
,
sizeof
wrk
);
sp
->
wrk
=
&
w
rk
;
w
rk
.
magic
=
WORKER_MAGIC
;
w
rk
.
wlp
=
wrk
.
wlb
=
logbuf
;
w
rk
.
wle
=
logbuf
+
(
sizeof
logbuf
)
/
4
;
(
void
)
bt
->
func
(
sp
,
bt
->
priv
);
...
...
bin/varnishd/hash/hash_critbit.c
View file @
41608b69
...
...
@@ -348,11 +348,11 @@ static void *
hcb_cleaner
(
void
*
priv
)
{
struct
hcb_y
*
y
,
*
y2
;
struct
worker
w
w
;
struct
worker
w
rk
;
struct
objhead
*
oh
,
*
oh2
;
memset
(
&
w
w
,
0
,
sizeof
ww
);
w
w
.
magic
=
WORKER_MAGIC
;
memset
(
&
w
rk
,
0
,
sizeof
wrk
);
w
rk
.
magic
=
WORKER_MAGIC
;
THR_SetName
(
"hcb_cleaner"
);
(
void
)
priv
;
...
...
@@ -363,13 +363,13 @@ hcb_cleaner(void *priv)
}
VTAILQ_FOREACH_SAFE
(
oh
,
&
dead_h
,
hoh_list
,
oh2
)
{
VTAILQ_REMOVE
(
&
dead_h
,
oh
,
hoh_list
);
HSH_DeleteObjHead
(
&
w
w
,
oh
);
HSH_DeleteObjHead
(
&
w
rk
,
oh
);
}
Lck_Lock
(
&
hcb_mtx
);
VSTAILQ_CONCAT
(
&
dead_y
,
&
cool_y
);
VTAILQ_CONCAT
(
&
dead_h
,
&
cool_h
,
hoh_list
);
Lck_Unlock
(
&
hcb_mtx
);
WRK_SumStat
(
&
w
w
);
WRK_SumStat
(
&
w
rk
);
VTIM_sleep
(
cache_param
->
critbit_cooloff
);
}
NEEDLESS_RETURN
(
NULL
);
...
...
@@ -386,6 +386,7 @@ hcb_start(void)
(
void
)
oh
;
CLI_AddFuncs
(
hcb_cmds
);
Lck_New
(
&
hcb_mtx
,
lck_hcb
);
/* XXX: use WRK_BgThread */
AZ
(
pthread_create
(
&
tp
,
NULL
,
hcb_cleaner
,
NULL
));
memset
(
&
hcb_root
,
0
,
sizeof
hcb_root
);
hcb_build_bittbl
();
...
...
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