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
a016850f
Unverified
Commit
a016850f
authored
Aug 04, 2020
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename binheap / binary_heap -> vbh
with the public api functions called VBH_
parent
c676ca46
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
154 additions
and
154 deletions
+154
-154
cache_backend_probe.c
bin/varnishd/cache/cache_backend_probe.c
+17
-17
cache_expire.c
bin/varnishd/cache/cache_expire.c
+18
-18
flint.lnt
bin/varnishd/flint.lnt
+1
-1
cache_waiter.c
bin/varnishd/waiter/cache_waiter.c
+12
-12
waiter_priv.h
bin/varnishd/waiter/waiter_priv.h
+2
-2
Makefile.am
include/Makefile.am
+1
-1
vbh.h
include/vbh.h
+10
-10
Makefile.am
lib/libvarnish/Makefile.am
+5
-5
flint.lnt
lib/libvarnish/flint.lnt
+1
-1
vbh.c
lib/libvarnish/vbh.c
+67
-67
vev.c
lib/libvarnish/vev.c
+19
-19
lsan.suppr
tools/lsan.suppr
+1
-1
No files found.
bin/varnishd/cache/cache_backend_probe.c
View file @
a016850f
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
#include "cache_varnishd.h"
#include "cache_varnishd.h"
#include "
binary_heap
.h"
#include "
vbh
.h"
#include "vcli_serve.h"
#include "vcli_serve.h"
#include "vsa.h"
#include "vsa.h"
#include "vtcp.h"
#include "vtcp.h"
...
@@ -89,7 +89,7 @@ struct vbp_target {
...
@@ -89,7 +89,7 @@ struct vbp_target {
static
struct
lock
vbp_mtx
;
static
struct
lock
vbp_mtx
;
static
pthread_cond_t
vbp_cond
;
static
pthread_cond_t
vbp_cond
;
static
struct
binheap
*
vbp_heap
;
static
struct
vbh
*
vbp_heap
;
static
const
unsigned
char
vbp_proxy_local
[]
=
{
static
const
unsigned
char
vbp_proxy_local
[]
=
{
0x0d
,
0x0a
,
0x0d
,
0x0a
,
0x00
,
0x0d
,
0x0a
,
0x51
,
0x0d
,
0x0a
,
0x0d
,
0x0a
,
0x00
,
0x0d
,
0x0a
,
0x51
,
...
@@ -417,8 +417,8 @@ static void
...
@@ -417,8 +417,8 @@ static void
vbp_heap_insert
(
struct
vbp_target
*
vt
)
vbp_heap_insert
(
struct
vbp_target
*
vt
)
{
{
// Lck_AssertHeld(&vbp_mtx);
// Lck_AssertHeld(&vbp_mtx);
binheap
_insert
(
vbp_heap
,
vt
);
VBH
_insert
(
vbp_heap
,
vt
);
if
(
binheap
_root
(
vbp_heap
)
==
vt
)
if
(
VBH
_root
(
vbp_heap
)
==
vt
)
AZ
(
pthread_cond_signal
(
&
vbp_cond
));
AZ
(
pthread_cond_signal
(
&
vbp_cond
));
}
}
...
@@ -444,13 +444,13 @@ vbp_task(struct worker *wrk, void *priv)
...
@@ -444,13 +444,13 @@ vbp_task(struct worker *wrk, void *priv)
Lck_Lock
(
&
vbp_mtx
);
Lck_Lock
(
&
vbp_mtx
);
if
(
vt
->
running
<
0
)
{
if
(
vt
->
running
<
0
)
{
assert
(
vt
->
heap_idx
==
BINHEAP
_NOIDX
);
assert
(
vt
->
heap_idx
==
VBH
_NOIDX
);
vbp_delete
(
vt
);
vbp_delete
(
vt
);
}
else
{
}
else
{
vt
->
running
=
0
;
vt
->
running
=
0
;
if
(
vt
->
heap_idx
!=
BINHEAP
_NOIDX
)
{
if
(
vt
->
heap_idx
!=
VBH
_NOIDX
)
{
vt
->
due
=
VTIM_real
()
+
vt
->
interval
;
vt
->
due
=
VTIM_real
()
+
vt
->
interval
;
binheap
_delete
(
vbp_heap
,
vt
->
heap_idx
);
VBH
_delete
(
vbp_heap
,
vt
->
heap_idx
);
vbp_heap_insert
(
vt
);
vbp_heap_insert
(
vt
);
}
}
}
}
...
@@ -472,7 +472,7 @@ vbp_thread(struct worker *wrk, void *priv)
...
@@ -472,7 +472,7 @@ vbp_thread(struct worker *wrk, void *priv)
Lck_Lock
(
&
vbp_mtx
);
Lck_Lock
(
&
vbp_mtx
);
while
(
1
)
{
while
(
1
)
{
now
=
VTIM_real
();
now
=
VTIM_real
();
vt
=
binheap
_root
(
vbp_heap
);
vt
=
VBH
_root
(
vbp_heap
);
if
(
vt
==
NULL
)
{
if
(
vt
==
NULL
)
{
nxt
=
8
.
192
+
now
;
nxt
=
8
.
192
+
now
;
(
void
)
Lck_CondWait
(
&
vbp_cond
,
&
vbp_mtx
,
nxt
);
(
void
)
Lck_CondWait
(
&
vbp_cond
,
&
vbp_mtx
,
nxt
);
...
@@ -481,7 +481,7 @@ vbp_thread(struct worker *wrk, void *priv)
...
@@ -481,7 +481,7 @@ vbp_thread(struct worker *wrk, void *priv)
vt
=
NULL
;
vt
=
NULL
;
(
void
)
Lck_CondWait
(
&
vbp_cond
,
&
vbp_mtx
,
nxt
);
(
void
)
Lck_CondWait
(
&
vbp_cond
,
&
vbp_mtx
,
nxt
);
}
else
{
}
else
{
binheap
_delete
(
vbp_heap
,
vt
->
heap_idx
);
VBH
_delete
(
vbp_heap
,
vt
->
heap_idx
);
vt
->
due
=
now
+
vt
->
interval
;
vt
->
due
=
now
+
vt
->
interval
;
if
(
!
vt
->
running
)
{
if
(
!
vt
->
running
)
{
vt
->
running
=
1
;
vt
->
running
=
1
;
...
@@ -493,7 +493,7 @@ vbp_thread(struct worker *wrk, void *priv)
...
@@ -493,7 +493,7 @@ vbp_thread(struct worker *wrk, void *priv)
if
(
r
)
if
(
r
)
vt
->
running
=
0
;
vt
->
running
=
0
;
}
}
binheap
_insert
(
vbp_heap
,
vt
);
VBH
_insert
(
vbp_heap
,
vt
);
}
}
}
}
NEEDLESS
(
Lck_Unlock
(
&
vbp_mtx
));
NEEDLESS
(
Lck_Unlock
(
&
vbp_mtx
));
...
@@ -654,12 +654,12 @@ VBP_Control(const struct backend *be, int enable)
...
@@ -654,12 +654,12 @@ VBP_Control(const struct backend *be, int enable)
Lck_Lock
(
&
vbp_mtx
);
Lck_Lock
(
&
vbp_mtx
);
if
(
enable
)
{
if
(
enable
)
{
assert
(
vt
->
heap_idx
==
BINHEAP
_NOIDX
);
assert
(
vt
->
heap_idx
==
VBH
_NOIDX
);
vt
->
due
=
VTIM_real
();
vt
->
due
=
VTIM_real
();
vbp_heap_insert
(
vt
);
vbp_heap_insert
(
vt
);
}
else
{
}
else
{
assert
(
vt
->
heap_idx
!=
BINHEAP
_NOIDX
);
assert
(
vt
->
heap_idx
!=
VBH
_NOIDX
);
binheap
_delete
(
vbp_heap
,
vt
->
heap_idx
);
VBH
_delete
(
vbp_heap
,
vt
->
heap_idx
);
}
}
Lck_Unlock
(
&
vbp_mtx
);
Lck_Unlock
(
&
vbp_mtx
);
}
}
...
@@ -713,14 +713,14 @@ VBP_Remove(struct backend *be)
...
@@ -713,14 +713,14 @@ VBP_Remove(struct backend *be)
}
}
Lck_Unlock
(
&
vbp_mtx
);
Lck_Unlock
(
&
vbp_mtx
);
if
(
vt
!=
NULL
)
{
if
(
vt
!=
NULL
)
{
assert
(
vt
->
heap_idx
==
BINHEAP
_NOIDX
);
assert
(
vt
->
heap_idx
==
VBH
_NOIDX
);
vbp_delete
(
vt
);
vbp_delete
(
vt
);
}
}
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
static
int
v_matchproto_
(
binheap
_cmp_t
)
static
int
v_matchproto_
(
vbh
_cmp_t
)
vbp_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
vbp_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
{
{
const
struct
vbp_target
*
aa
,
*
bb
;
const
struct
vbp_target
*
aa
,
*
bb
;
...
@@ -739,7 +739,7 @@ vbp_cmp(void *priv, const void *a, const void *b)
...
@@ -739,7 +739,7 @@ vbp_cmp(void *priv, const void *a, const void *b)
return
(
aa
->
due
<
bb
->
due
);
return
(
aa
->
due
<
bb
->
due
);
}
}
static
void
v_matchproto_
(
binheap
_update_t
)
static
void
v_matchproto_
(
vbh
_update_t
)
vbp_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
vbp_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
{
{
struct
vbp_target
*
vt
;
struct
vbp_target
*
vt
;
...
@@ -757,7 +757,7 @@ VBP_Init(void)
...
@@ -757,7 +757,7 @@ VBP_Init(void)
pthread_t
thr
;
pthread_t
thr
;
Lck_New
(
&
vbp_mtx
,
lck_probe
);
Lck_New
(
&
vbp_mtx
,
lck_probe
);
vbp_heap
=
binheap
_new
(
NULL
,
vbp_cmp
,
vbp_update
);
vbp_heap
=
VBH
_new
(
NULL
,
vbp_cmp
,
vbp_update
);
AN
(
vbp_heap
);
AN
(
vbp_heap
);
AZ
(
pthread_cond_init
(
&
vbp_cond
,
NULL
));
AZ
(
pthread_cond_init
(
&
vbp_cond
,
NULL
));
WRK_BgThread
(
&
thr
,
"backend-poller"
,
vbp_thread
,
NULL
);
WRK_BgThread
(
&
thr
,
"backend-poller"
,
vbp_thread
,
NULL
);
...
...
bin/varnishd/cache/cache_expire.c
View file @
a016850f
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
#include "cache_varnishd.h"
#include "cache_varnishd.h"
#include "cache_objhead.h"
#include "cache_objhead.h"
#include "
binary_heap
.h"
#include "
vbh
.h"
#include "vtim.h"
#include "vtim.h"
struct
exp_priv
{
struct
exp_priv
{
...
@@ -53,7 +53,7 @@ struct exp_priv {
...
@@ -53,7 +53,7 @@ struct exp_priv {
/* owned by exp thread */
/* owned by exp thread */
struct
worker
*
wrk
;
struct
worker
*
wrk
;
struct
vsl_log
vsl
;
struct
vsl_log
vsl
;
struct
binheap
*
heap
;
struct
vbh
*
heap
;
pthread_t
thread
;
pthread_t
thread
;
};
};
...
@@ -272,10 +272,10 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags)
...
@@ -272,10 +272,10 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags)
if
(
flags
&
OC_EF_REMOVE
)
{
if
(
flags
&
OC_EF_REMOVE
)
{
if
(
!
(
flags
&
OC_EF_INSERT
))
{
if
(
!
(
flags
&
OC_EF_INSERT
))
{
assert
(
oc
->
timer_idx
!=
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
!=
VBH
_NOIDX
);
binheap
_delete
(
ep
->
heap
,
oc
->
timer_idx
);
VBH
_delete
(
ep
->
heap
,
oc
->
timer_idx
);
}
}
assert
(
oc
->
timer_idx
==
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
==
VBH
_NOIDX
);
assert
(
oc
->
refcnt
>
0
);
assert
(
oc
->
refcnt
>
0
);
AZ
(
oc
->
exp_flags
);
AZ
(
oc
->
exp_flags
);
ObjSendEvent
(
ep
->
wrk
,
oc
,
OEV_EXPIRE
);
ObjSendEvent
(
ep
->
wrk
,
oc
,
OEV_EXPIRE
);
...
@@ -298,13 +298,13 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags)
...
@@ -298,13 +298,13 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags)
*/
*/
if
(
flags
&
OC_EF_INSERT
)
{
if
(
flags
&
OC_EF_INSERT
)
{
assert
(
oc
->
timer_idx
==
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
==
VBH
_NOIDX
);
binheap
_insert
(
exphdl
->
heap
,
oc
);
VBH
_insert
(
exphdl
->
heap
,
oc
);
assert
(
oc
->
timer_idx
!=
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
!=
VBH
_NOIDX
);
}
else
if
(
flags
&
OC_EF_MOVE
)
{
}
else
if
(
flags
&
OC_EF_MOVE
)
{
assert
(
oc
->
timer_idx
!=
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
!=
VBH
_NOIDX
);
binheap
_reorder
(
exphdl
->
heap
,
oc
->
timer_idx
);
VBH
_reorder
(
exphdl
->
heap
,
oc
->
timer_idx
);
assert
(
oc
->
timer_idx
!=
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
!=
VBH
_NOIDX
);
}
else
{
}
else
{
WRONG
(
"Objcore state wrong in inbox"
);
WRONG
(
"Objcore state wrong in inbox"
);
}
}
...
@@ -321,7 +321,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
...
@@ -321,7 +321,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
CHECK_OBJ_NOTNULL
(
ep
,
EXP_PRIV_MAGIC
);
CHECK_OBJ_NOTNULL
(
ep
,
EXP_PRIV_MAGIC
);
oc
=
binheap
_root
(
ep
->
heap
);
oc
=
VBH
_root
(
ep
->
heap
);
if
(
oc
==
NULL
)
if
(
oc
==
NULL
)
return
(
now
+
355
.
/
113
.);
return
(
now
+
355
.
/
113
.);
VSLb
(
&
ep
->
vsl
,
SLT_ExpKill
,
"EXP_expire p=%p e=%.6f f=0x%x"
,
oc
,
VSLb
(
&
ep
->
vsl
,
SLT_ExpKill
,
"EXP_expire p=%p e=%.6f f=0x%x"
,
oc
,
...
@@ -348,9 +348,9 @@ exp_expire(struct exp_priv *ep, vtim_real now)
...
@@ -348,9 +348,9 @@ exp_expire(struct exp_priv *ep, vtim_real now)
HSH_Kill
(
oc
);
HSH_Kill
(
oc
);
/* Remove from binheap */
/* Remove from binheap */
assert
(
oc
->
timer_idx
!=
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
!=
VBH
_NOIDX
);
binheap
_delete
(
ep
->
heap
,
oc
->
timer_idx
);
VBH
_delete
(
ep
->
heap
,
oc
->
timer_idx
);
assert
(
oc
->
timer_idx
==
BINHEAP
_NOIDX
);
assert
(
oc
->
timer_idx
==
VBH
_NOIDX
);
CHECK_OBJ_NOTNULL
(
oc
->
objhead
,
OBJHEAD_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
->
objhead
,
OBJHEAD_MAGIC
);
VSLb
(
&
ep
->
vsl
,
SLT_ExpKill
,
"EXP_Expired x=%u t=%.0f"
,
VSLb
(
&
ep
->
vsl
,
SLT_ExpKill
,
"EXP_Expired x=%u t=%.0f"
,
...
@@ -366,7 +366,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
...
@@ -366,7 +366,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
* object expires, accounting also for graceability, it is killed.
* object expires, accounting also for graceability, it is killed.
*/
*/
static
int
v_matchproto_
(
binheap
_cmp_t
)
static
int
v_matchproto_
(
vbh
_cmp_t
)
object_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
object_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
{
{
const
struct
objcore
*
aa
,
*
bb
;
const
struct
objcore
*
aa
,
*
bb
;
...
@@ -377,7 +377,7 @@ object_cmp(void *priv, const void *a, const void *b)
...
@@ -377,7 +377,7 @@ object_cmp(void *priv, const void *a, const void *b)
return
(
aa
->
timer_when
<
bb
->
timer_when
);
return
(
aa
->
timer_when
<
bb
->
timer_when
);
}
}
static
void
v_matchproto_
(
binheap
_update_t
)
static
void
v_matchproto_
(
vbh
_update_t
)
object_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
object_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
{
{
struct
objcore
*
oc
;
struct
objcore
*
oc
;
...
@@ -398,7 +398,7 @@ exp_thread(struct worker *wrk, void *priv)
...
@@ -398,7 +398,7 @@ exp_thread(struct worker *wrk, void *priv)
CAST_OBJ_NOTNULL
(
ep
,
priv
,
EXP_PRIV_MAGIC
);
CAST_OBJ_NOTNULL
(
ep
,
priv
,
EXP_PRIV_MAGIC
);
ep
->
wrk
=
wrk
;
ep
->
wrk
=
wrk
;
VSL_Setup
(
&
ep
->
vsl
,
NULL
,
0
);
VSL_Setup
(
&
ep
->
vsl
,
NULL
,
0
);
ep
->
heap
=
binheap
_new
(
NULL
,
object_cmp
,
object_update
);
ep
->
heap
=
VBH
_new
(
NULL
,
object_cmp
,
object_update
);
AN
(
ep
->
heap
);
AN
(
ep
->
heap
);
while
(
exp_shutdown
==
0
)
{
while
(
exp_shutdown
==
0
)
{
...
...
bin/varnishd/flint.lnt
View file @
a016850f
...
@@ -151,7 +151,7 @@
...
@@ -151,7 +151,7 @@
-e441 // for clause irregularity: loop variable '___' not found in 2nd for expression
-e441 // for clause irregularity: loop variable '___' not found in 2nd for expression
// from libvarnish
// from libvarnish
--emacro((835),
BINHEAP
_NOIDX)
--emacro((835),
VBH
_NOIDX)
--emacro((835),O_CLOEXEC)
--emacro((835),O_CLOEXEC)
// Review all below this line ///////////////////////////////////////////////
// Review all below this line ///////////////////////////////////////////////
...
...
bin/varnishd/waiter/cache_waiter.c
View file @
a016850f
...
@@ -36,13 +36,13 @@
...
@@ -36,13 +36,13 @@
#include <stdlib.h>
#include <stdlib.h>
#include "
binary_heap
.h"
#include "
vbh
.h"
#include "waiter/waiter.h"
#include "waiter/waiter.h"
#include "waiter/waiter_priv.h"
#include "waiter/waiter_priv.h"
#include "waiter/mgt_waiter.h"
#include "waiter/mgt_waiter.h"
static
int
v_matchproto_
(
binheap
_cmp_t
)
static
int
v_matchproto_
(
vbh
_cmp_t
)
waited_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
waited_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
{
{
const
struct
waiter
*
ww
;
const
struct
waiter
*
ww
;
...
@@ -55,7 +55,7 @@ waited_cmp(void *priv, const void *a, const void *b)
...
@@ -55,7 +55,7 @@ waited_cmp(void *priv, const void *a, const void *b)
return
(
Wait_When
(
aa
)
<
Wait_When
(
bb
));
return
(
Wait_When
(
aa
)
<
Wait_When
(
bb
));
}
}
static
void
v_matchproto_
(
binheap
_update_t
)
static
void
v_matchproto_
(
vbh
_update_t
)
waited_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
waited_update
(
void
*
priv
,
void
*
p
,
unsigned
u
)
{
{
struct
waited
*
pp
;
struct
waited
*
pp
;
...
@@ -74,7 +74,7 @@ Wait_Call(const struct waiter *w, struct waited *wp,
...
@@ -74,7 +74,7 @@ Wait_Call(const struct waiter *w, struct waited *wp,
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
AN
(
wp
->
func
);
AN
(
wp
->
func
);
assert
(
wp
->
idx
==
BINHEAP
_NOIDX
);
assert
(
wp
->
idx
==
VBH
_NOIDX
);
wp
->
func
(
wp
,
ev
,
now
);
wp
->
func
(
wp
,
ev
,
now
);
}
}
...
@@ -85,8 +85,8 @@ Wait_HeapInsert(const struct waiter *w, struct waited *wp)
...
@@ -85,8 +85,8 @@ Wait_HeapInsert(const struct waiter *w, struct waited *wp)
{
{
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
assert
(
wp
->
idx
==
BINHEAP
_NOIDX
);
assert
(
wp
->
idx
==
VBH
_NOIDX
);
binheap
_insert
(
w
->
heap
,
wp
);
VBH
_insert
(
w
->
heap
,
wp
);
}
}
/*
/*
...
@@ -102,9 +102,9 @@ Wait_HeapDelete(const struct waiter *w, const struct waited *wp)
...
@@ -102,9 +102,9 @@ Wait_HeapDelete(const struct waiter *w, const struct waited *wp)
{
{
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WAITER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
if
(
wp
->
idx
==
BINHEAP
_NOIDX
)
if
(
wp
->
idx
==
VBH
_NOIDX
)
return
(
0
);
return
(
0
);
binheap
_delete
(
w
->
heap
,
wp
->
idx
);
VBH
_delete
(
w
->
heap
,
wp
->
idx
);
return
(
1
);
return
(
1
);
}
}
...
@@ -113,7 +113,7 @@ Wait_HeapDue(const struct waiter *w, struct waited **wpp)
...
@@ -113,7 +113,7 @@ Wait_HeapDue(const struct waiter *w, struct waited **wpp)
{
{
struct
waited
*
wp
;
struct
waited
*
wp
;
wp
=
binheap
_root
(
w
->
heap
);
wp
=
VBH
_root
(
w
->
heap
);
CHECK_OBJ_ORNULL
(
wp
,
WAITED_MAGIC
);
CHECK_OBJ_ORNULL
(
wp
,
WAITED_MAGIC
);
if
(
wp
==
NULL
)
{
if
(
wp
==
NULL
)
{
if
(
wpp
!=
NULL
)
if
(
wpp
!=
NULL
)
...
@@ -135,7 +135,7 @@ Wait_Enter(const struct waiter *w, struct waited *wp)
...
@@ -135,7 +135,7 @@ Wait_Enter(const struct waiter *w, struct waited *wp)
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
assert
(
wp
->
fd
>
0
);
// stdin never comes here
assert
(
wp
->
fd
>
0
);
// stdin never comes here
AN
(
wp
->
func
);
AN
(
wp
->
func
);
wp
->
idx
=
BINHEAP
_NOIDX
;
wp
->
idx
=
VBH
_NOIDX
;
return
(
w
->
impl
->
enter
(
w
->
priv
,
wp
));
return
(
w
->
impl
->
enter
(
w
->
priv
,
wp
));
}
}
...
@@ -168,7 +168,7 @@ Waiter_New(void)
...
@@ -168,7 +168,7 @@ Waiter_New(void)
w
->
priv
=
(
void
*
)(
w
+
1
);
w
->
priv
=
(
void
*
)(
w
+
1
);
w
->
impl
=
waiter
;
w
->
impl
=
waiter
;
VTAILQ_INIT
(
&
w
->
waithead
);
VTAILQ_INIT
(
&
w
->
waithead
);
w
->
heap
=
binheap
_new
(
w
,
waited_cmp
,
waited_update
);
w
->
heap
=
VBH
_new
(
w
,
waited_cmp
,
waited_update
);
waiter
->
init
(
w
);
waiter
->
init
(
w
);
...
@@ -182,7 +182,7 @@ Waiter_Destroy(struct waiter **wp)
...
@@ -182,7 +182,7 @@ Waiter_Destroy(struct waiter **wp)
TAKE_OBJ_NOTNULL
(
w
,
wp
,
WAITER_MAGIC
);
TAKE_OBJ_NOTNULL
(
w
,
wp
,
WAITER_MAGIC
);
AZ
(
binheap
_root
(
w
->
heap
));
AZ
(
VBH
_root
(
w
->
heap
));
AN
(
w
->
impl
->
fini
);
AN
(
w
->
impl
->
fini
);
w
->
impl
->
fini
(
w
);
w
->
impl
->
fini
(
w
);
FREE_OBJ
(
w
);
FREE_OBJ
(
w
);
...
...
bin/varnishd/waiter/waiter_priv.h
View file @
a016850f
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
*/
*/
struct
waited
;
struct
waited
;
struct
binheap
;
struct
vbh
;
struct
waiter
{
struct
waiter
{
unsigned
magic
;
unsigned
magic
;
...
@@ -42,7 +42,7 @@ struct waiter {
...
@@ -42,7 +42,7 @@ struct waiter {
VTAILQ_HEAD
(,
waited
)
waithead
;
VTAILQ_HEAD
(,
waited
)
waithead
;
void
*
priv
;
void
*
priv
;
struct
binheap
*
heap
;
struct
vbh
*
heap
;
};
};
typedef
void
waiter_init_f
(
struct
waiter
*
);
typedef
void
waiter_init_f
(
struct
waiter
*
);
...
...
include/Makefile.am
View file @
a016850f
...
@@ -58,7 +58,7 @@ nobase_pkginclude_HEADERS = \
...
@@ -58,7 +58,7 @@ nobase_pkginclude_HEADERS = \
# Headers for use with vmods
# Headers for use with vmods
nobase_pkginclude_HEADERS
+=
\
nobase_pkginclude_HEADERS
+=
\
binary_heap
.h
\
vbh
.h
\
miniobj.h
\
miniobj.h
\
vas.h
\
vas.h
\
vav.h
\
vav.h
\
...
...
include/
binary_heap
.h
→
include/
vbh
.h
View file @
a016850f
...
@@ -35,16 +35,16 @@
...
@@ -35,16 +35,16 @@
/* Public Interface --------------------------------------------------*/
/* Public Interface --------------------------------------------------*/
struct
binheap
;
struct
vbh
;
typedef
int
binheap
_cmp_t
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
);
typedef
int
vbh
_cmp_t
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
);
/*
/*
* Comparison function.
* Comparison function.
* Should return true if item 'a' should be closer to the root
* Should return true if item 'a' should be closer to the root
* than item 'b'
* than item 'b'
*/
*/
typedef
void
binheap
_update_t
(
void
*
priv
,
void
*
a
,
unsigned
newidx
);
typedef
void
vbh
_update_t
(
void
*
priv
,
void
*
a
,
unsigned
newidx
);
/*
/*
* Update function (optional)
* Update function (optional)
* When items move in the tree, this function gets called to
* When items move in the tree, this function gets called to
...
@@ -52,36 +52,36 @@ typedef void binheap_update_t(void *priv, void *a, unsigned newidx);
...
@@ -52,36 +52,36 @@ typedef void binheap_update_t(void *priv, void *a, unsigned newidx);
* Only needed if deleting non-root items.
* Only needed if deleting non-root items.
*/
*/
struct
binheap
*
binheap_new
(
void
*
priv
,
binheap_cmp_t
,
binheap
_update_t
);
struct
vbh
*
VBH_new
(
void
*
priv
,
vbh_cmp_t
,
vbh
_update_t
);
/*
/*
* Create Binary tree
* Create Binary tree
* 'priv' is passed to cmp and update functions.
* 'priv' is passed to cmp and update functions.
*/
*/
void
binheap_destroy
(
struct
binheap
**
);
void
VBH_destroy
(
struct
vbh
**
);
/*
/*
* Destroy an empty Binary tree
* Destroy an empty Binary tree
*/
*/
void
binheap_insert
(
struct
binheap
*
,
void
*
);
void
VBH_insert
(
struct
vbh
*
,
void
*
);
/*
/*
* Insert an item
* Insert an item
*/
*/
void
binheap_reorder
(
const
struct
binheap
*
,
unsigned
idx
);
void
VBH_reorder
(
const
struct
vbh
*
,
unsigned
idx
);
/*
/*
* Move an order after changing its key value.
* Move an order after changing its key value.
*/
*/
void
binheap_delete
(
struct
binheap
*
,
unsigned
idx
);
void
VBH_delete
(
struct
vbh
*
,
unsigned
idx
);
/*
/*
* Delete an item
* Delete an item
* The root item has 'idx' zero
* The root item has 'idx' zero
*/
*/
void
*
binheap_root
(
const
struct
binheap
*
);
void
*
VBH_root
(
const
struct
vbh
*
);
/*
/*
* Return the root item
* Return the root item
*/
*/
#define
BINHEAP
_NOIDX 0
#define
VBH
_NOIDX 0
lib/libvarnish/Makefile.am
View file @
a016850f
...
@@ -15,7 +15,7 @@ libvarnish_la_CFLAGS = \
...
@@ -15,7 +15,7 @@ libvarnish_la_CFLAGS = \
$(AM_CFLAGS)
$(AM_CFLAGS)
libvarnish_la_SOURCES
=
\
libvarnish_la_SOURCES
=
\
binary_heap
.c
\
vbh
.c
\
vas.c
\
vas.c
\
vav.c
\
vav.c
\
vcli_proto.c
\
vcli_proto.c
\
...
@@ -44,13 +44,13 @@ libvarnish_la_SOURCES = \
...
@@ -44,13 +44,13 @@ libvarnish_la_SOURCES = \
vtim.c
\
vtim.c
\
vus.c
vus.c
TESTS
=
vjsn_test vnum_c_test
binheap
vsb_test
TESTS
=
vjsn_test vnum_c_test
vbh_test
vsb_test
noinst_PROGRAMS
=
${
TESTS
}
noinst_PROGRAMS
=
${
TESTS
}
binheap_SOURCES
=
binary_heap
.c
vbh_test_SOURCES
=
vbh
.c
binheap
_CFLAGS
=
$(AM_CFLAGS)
-DTEST_DRIVER
vbh_test
_CFLAGS
=
$(AM_CFLAGS)
-DTEST_DRIVER
binheap
_LDADD
=
$(AM_LDFLAGS)
libvarnish.la
vbh_test
_LDADD
=
$(AM_LDFLAGS)
libvarnish.la
vnum_c_test_SOURCES
=
vnum.c
vnum_c_test_SOURCES
=
vnum.c
vnum_c_test_CFLAGS
=
$(AM_CFLAGS)
-DNUM_C_TEST
vnum_c_test_CFLAGS
=
$(AM_CFLAGS)
-DNUM_C_TEST
...
...
lib/libvarnish/flint.lnt
View file @
a016850f
...
@@ -8,5 +8,5 @@
...
@@ -8,5 +8,5 @@
-dVARNISH_STATE_DIR="foo"
-dVARNISH_STATE_DIR="foo"
--emacro((835),
BINHEAP
_NOIDX)
--emacro((835),
VBH
_NOIDX)
--emacro((835),O_CLOEXEC)
--emacro((835),O_CLOEXEC)
lib/libvarnish/
binary_heap
.c
→
lib/libvarnish/
vbh
.c
View file @
a016850f
This diff is collapsed.
Click to expand it.
lib/libvarnish/vev.c
View file @
a016850f
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#include "miniobj.h"
#include "miniobj.h"
#include "vas.h"
#include "vas.h"
#include "
binary_heap
.h"
#include "
vbh
.h"
#include "vev.h"
#include "vev.h"
#include "vtim.h"
#include "vtim.h"
...
@@ -71,7 +71,7 @@ struct vev_root {
...
@@ -71,7 +71,7 @@ struct vev_root {
struct
vev
**
pev
;
struct
vev
**
pev
;
unsigned
npfd
;
unsigned
npfd
;
unsigned
lpfd
;
unsigned
lpfd
;
struct
binheap
*
binheap
;
struct
vbh
*
binheap
;
unsigned
psig
;
unsigned
psig
;
pthread_t
thread
;
pthread_t
thread
;
#ifdef DEBUG_EVENTS
#ifdef DEBUG_EVENTS
...
@@ -93,7 +93,7 @@ struct vev_root {
...
@@ -93,7 +93,7 @@ struct vev_root {
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
v_matchproto_
(
binheap
_update_t
)
static
void
v_matchproto_
(
vbh
_update_t
)
vev_bh_update
(
void
*
priv
,
void
*
a
,
unsigned
u
)
vev_bh_update
(
void
*
priv
,
void
*
a
,
unsigned
u
)
{
{
struct
vev_root
*
evb
;
struct
vev_root
*
evb
;
...
@@ -103,7 +103,7 @@ vev_bh_update(void *priv, void *a, unsigned u)
...
@@ -103,7 +103,7 @@ vev_bh_update(void *priv, void *a, unsigned u)
CAST_OBJ_NOTNULL
(
e
,
a
,
VEV_MAGIC
);
CAST_OBJ_NOTNULL
(
e
,
a
,
VEV_MAGIC
);
assert
(
u
<
evb
->
lpfd
);
assert
(
u
<
evb
->
lpfd
);
e
->
__binheap_idx
=
u
;
e
->
__binheap_idx
=
u
;
if
(
u
!=
BINHEAP
_NOIDX
)
{
if
(
u
!=
VBH
_NOIDX
)
{
evb
->
pev
[
u
]
=
e
;
evb
->
pev
[
u
]
=
e
;
evb
->
pfd
[
u
].
fd
=
e
->
fd
;
evb
->
pfd
[
u
].
fd
=
e
->
fd
;
evb
->
pfd
[
u
].
events
=
evb
->
pfd
[
u
].
events
=
...
@@ -111,7 +111,7 @@ vev_bh_update(void *priv, void *a, unsigned u)
...
@@ -111,7 +111,7 @@ vev_bh_update(void *priv, void *a, unsigned u)
}
}
}
}
static
int
v_matchproto_
(
binheap
_cmp_t
)
static
int
v_matchproto_
(
vbh
_cmp_t
)
vev_bh_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
vev_bh_cmp
(
void
*
priv
,
const
void
*
a
,
const
void
*
b
)
{
{
struct
vev_root
*
evb
;
struct
vev_root
*
evb
;
...
@@ -196,13 +196,13 @@ VEV_New(void)
...
@@ -196,13 +196,13 @@ VEV_New(void)
evb
=
calloc
(
1
,
sizeof
*
evb
);
evb
=
calloc
(
1
,
sizeof
*
evb
);
if
(
evb
==
NULL
)
if
(
evb
==
NULL
)
return
(
evb
);
return
(
evb
);
evb
->
lpfd
=
BINHEAP
_NOIDX
+
1
;
evb
->
lpfd
=
VBH
_NOIDX
+
1
;
if
(
vev_get_pfd
(
evb
))
{
if
(
vev_get_pfd
(
evb
))
{
free
(
evb
);
free
(
evb
);
return
(
NULL
);
return
(
NULL
);
}
}
evb
->
magic
=
VEV_BASE_MAGIC
;
evb
->
magic
=
VEV_BASE_MAGIC
;
evb
->
binheap
=
binheap
_new
(
evb
,
vev_bh_cmp
,
vev_bh_update
);
evb
->
binheap
=
VBH
_new
(
evb
,
vev_bh_cmp
,
vev_bh_update
);
evb
->
thread
=
pthread_self
();
evb
->
thread
=
pthread_self
();
#ifdef DEBUG_EVENTS
#ifdef DEBUG_EVENTS
evb
->
debug
=
fopen
(
"/tmp/_.events"
,
"w"
);
evb
->
debug
=
fopen
(
"/tmp/_.events"
,
"w"
);
...
@@ -278,7 +278,7 @@ VEV_Start(struct vev_root *evb, struct vev *e)
...
@@ -278,7 +278,7 @@ VEV_Start(struct vev_root *evb, struct vev *e)
es
=
NULL
;
es
=
NULL
;
}
}
e
->
magic
=
VEV_MAGIC
;
/* before
binheap
_insert() */
e
->
magic
=
VEV_MAGIC
;
/* before
VBH
_insert() */
if
(
e
->
timeout
!=
0
.
0
)
if
(
e
->
timeout
!=
0
.
0
)
e
->
__when
+=
VTIM_mono
()
+
e
->
timeout
;
e
->
__when
+=
VTIM_mono
()
+
e
->
timeout
;
...
@@ -286,8 +286,8 @@ VEV_Start(struct vev_root *evb, struct vev *e)
...
@@ -286,8 +286,8 @@ VEV_Start(struct vev_root *evb, struct vev *e)
e
->
__when
=
9e99
;
e
->
__when
=
9e99
;
evb
->
lpfd
++
;
evb
->
lpfd
++
;
binheap
_insert
(
evb
->
binheap
,
e
);
VBH
_insert
(
evb
->
binheap
,
e
);
assert
(
e
->
__binheap_idx
!=
BINHEAP
_NOIDX
);
assert
(
e
->
__binheap_idx
!=
VBH
_NOIDX
);
e
->
__vevb
=
evb
;
e
->
__vevb
=
evb
;
e
->
__privflags
=
0
;
e
->
__privflags
=
0
;
...
@@ -314,10 +314,10 @@ VEV_Stop(struct vev_root *evb, struct vev *e)
...
@@ -314,10 +314,10 @@ VEV_Stop(struct vev_root *evb, struct vev *e)
assert
(
evb
->
thread
==
pthread_self
());
assert
(
evb
->
thread
==
pthread_self
());
assert
(
evb
->
pev
[
e
->
__binheap_idx
]
==
e
);
assert
(
evb
->
pev
[
e
->
__binheap_idx
]
==
e
);
assert
(
e
->
__binheap_idx
!=
BINHEAP
_NOIDX
);
assert
(
e
->
__binheap_idx
!=
VBH
_NOIDX
);
e
->
fd
=
-
1
;
e
->
fd
=
-
1
;
binheap
_delete
(
evb
->
binheap
,
e
->
__binheap_idx
);
VBH
_delete
(
evb
->
binheap
,
e
->
__binheap_idx
);
assert
(
e
->
__binheap_idx
==
BINHEAP
_NOIDX
);
assert
(
e
->
__binheap_idx
==
VBH
_NOIDX
);
evb
->
lpfd
--
;
evb
->
lpfd
--
;
if
(
e
->
sig
>
0
)
{
if
(
e
->
sig
>
0
)
{
...
@@ -365,8 +365,8 @@ vev_sched_timeout(struct vev_root *evb, struct vev *e, vtim_mono t)
...
@@ -365,8 +365,8 @@ vev_sched_timeout(struct vev_root *evb, struct vev *e, vtim_mono t)
free
(
e
);
free
(
e
);
}
else
{
}
else
{
e
->
__when
=
t
+
e
->
timeout
;
e
->
__when
=
t
+
e
->
timeout
;
binheap
_delete
(
evb
->
binheap
,
e
->
__binheap_idx
);
VBH
_delete
(
evb
->
binheap
,
e
->
__binheap_idx
);
binheap
_insert
(
evb
->
binheap
,
e
);
VBH
_insert
(
evb
->
binheap
,
e
);
}
}
return
(
1
);
return
(
1
);
}
}
...
@@ -413,10 +413,10 @@ VEV_Once(struct vev_root *evb)
...
@@ -413,10 +413,10 @@ VEV_Once(struct vev_root *evb)
return
(
vev_sched_signal
(
evb
));
return
(
vev_sched_signal
(
evb
));
tmo
=
INFTIM
;
tmo
=
INFTIM
;
e
=
binheap
_root
(
evb
->
binheap
);
e
=
VBH
_root
(
evb
->
binheap
);
if
(
e
!=
NULL
)
{
if
(
e
!=
NULL
)
{
CHECK_OBJ
(
e
,
VEV_MAGIC
);
CHECK_OBJ
(
e
,
VEV_MAGIC
);
assert
(
e
->
__binheap_idx
==
BINHEAP
_NOIDX
+
1
);
assert
(
e
->
__binheap_idx
==
VBH
_NOIDX
+
1
);
t
=
VTIM_mono
();
t
=
VTIM_mono
();
if
(
e
->
__when
<=
t
)
if
(
e
->
__when
<=
t
)
return
(
vev_sched_timeout
(
evb
,
e
,
t
));
return
(
vev_sched_timeout
(
evb
,
e
,
t
));
...
@@ -426,7 +426,7 @@ VEV_Once(struct vev_root *evb)
...
@@ -426,7 +426,7 @@ VEV_Once(struct vev_root *evb)
tmo
=
1
;
tmo
=
1
;
}
}
if
(
tmo
==
INFTIM
&&
evb
->
lpfd
==
BINHEAP
_NOIDX
+
1
)
if
(
tmo
==
INFTIM
&&
evb
->
lpfd
==
VBH
_NOIDX
+
1
)
return
(
0
);
return
(
0
);
i
=
poll
(
evb
->
pfd
+
1
,
evb
->
lpfd
-
1
,
tmo
);
i
=
poll
(
evb
->
pfd
+
1
,
evb
->
lpfd
-
1
,
tmo
);
...
@@ -452,7 +452,7 @@ VEV_Once(struct vev_root *evb)
...
@@ -452,7 +452,7 @@ VEV_Once(struct vev_root *evb)
DBG
(
evb
,
"EVENTS %d
\n
"
,
i
);
DBG
(
evb
,
"EVENTS %d
\n
"
,
i
);
while
(
i
>
0
)
{
while
(
i
>
0
)
{
for
(
u
=
BINHEAP
_NOIDX
+
1
;
u
<
evb
->
lpfd
;
u
++
)
{
for
(
u
=
VBH
_NOIDX
+
1
;
u
<
evb
->
lpfd
;
u
++
)
{
e
=
evb
->
pev
[
u
];
e
=
evb
->
pev
[
u
];
if
(
e
->
fd_events
==
0
)
if
(
e
->
fd_events
==
0
)
continue
;
continue
;
...
...
tools/lsan.suppr
View file @
a016850f
...
@@ -9,7 +9,7 @@ leak:vcc_
...
@@ -9,7 +9,7 @@ leak:vcc_
leak:VSL_Setup
leak:VSL_Setup
leak:WRK_BgThread
leak:WRK_BgThread
#
#
leak:
binheap
_new
leak:
VBH
_new
# ev
# ev
leak:mct_callback
leak:mct_callback
#
#
...
...
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