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
59c6ae45
Commit
59c6ae45
authored
Mar 12, 2012
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Join struct vbo and struct busyobj
parent
e725920a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
74 deletions
+66
-74
cache.h
bin/varnishd/cache/cache.h
+11
-5
cache_busyobj.c
bin/varnishd/cache/cache_busyobj.c
+50
-62
cache_center.c
bin/varnishd/cache/cache_center.c
+3
-3
cache_hash.c
bin/varnishd/cache/cache_hash.c
+0
-2
cache_wrk.c
bin/varnishd/cache/cache_wrk.c
+2
-2
No files found.
bin/varnishd/cache/cache.h
View file @
59c6ae45
...
...
@@ -108,7 +108,6 @@ struct poolparam;
struct
sess
;
struct
sesspool
;
struct
vbc
;
struct
vbo
;
struct
vef_priv
;
struct
vrt_backend
;
struct
vsb
;
...
...
@@ -298,7 +297,7 @@ struct worker {
struct
objhead
*
nobjhead
;
struct
objcore
*
nobjcore
;
struct
waitinglist
*
nwaitinglist
;
struct
vbo
*
nv
bo
;
struct
busyobj
*
n
bo
;
void
*
nhashpriv
;
struct
dstat
stats
;
...
...
@@ -459,7 +458,14 @@ enum busyobj_state_e {
struct
busyobj
{
unsigned
magic
;
#define BUSYOBJ_MAGIC 0x23b95567
struct
vbo
*
vbo
;
struct
lock
mtx
;
char
*
end
;
/*
* All fields from refcount and down are zeroed when the busyobj
* is recycled.
*/
unsigned
refcount
;
uint8_t
*
vary
;
unsigned
is_gzip
;
...
...
@@ -479,7 +485,7 @@ struct busyobj {
struct
http_conn
htc
;
enum
body_status
body_status
;
struct
pool_task
task
;
struct
pool_task
fetch_
task
;
struct
vef_priv
*
vef_priv
;
...
...
@@ -721,7 +727,7 @@ void VBO_Init(void);
struct
busyobj
*
VBO_GetBusyObj
(
struct
worker
*
wrk
);
void
VBO_RefBusyObj
(
const
struct
busyobj
*
busyobj
);
void
VBO_DerefBusyObj
(
struct
worker
*
wrk
,
struct
busyobj
**
busyobj
);
void
VBO_Free
(
struct
vbo
**
vbo
);
void
VBO_Free
(
struct
busyobj
**
vbo
);
/* cache_center.c [CNT] */
void
CNT_Session
(
struct
sess
*
sp
);
...
...
bin/varnishd/cache/cache_busyobj.c
View file @
59c6ae45
...
...
@@ -40,15 +40,6 @@
static
struct
mempool
*
vbopool
;
struct
vbo
{
unsigned
magic
;
#define VBO_MAGIC 0xde3d8223
struct
lock
mtx
;
unsigned
refcount
;
char
*
end
;
struct
busyobj
bo
;
};
/*--------------------------------------------------------------------
*/
...
...
@@ -56,7 +47,7 @@ void
VBO_Init
(
void
)
{
vbopool
=
MPL_New
(
"
vbo
"
,
&
cache_param
->
vbo_pool
,
vbopool
=
MPL_New
(
"
busyobj
"
,
&
cache_param
->
vbo_pool
,
&
cache_param
->
workspace_backend
);
AN
(
vbopool
);
}
...
...
@@ -65,88 +56,86 @@ VBO_Init(void)
* BusyObj handling
*/
static
struct
vbo
*
static
struct
busyobj
*
vbo_New
(
void
)
{
struct
vbo
*
v
bo
;
struct
busyobj
*
bo
;
unsigned
sz
;
v
bo
=
MPL_Get
(
vbopool
,
&
sz
);
AN
(
v
bo
);
vbo
->
magic
=
VBO
_MAGIC
;
vbo
->
end
=
(
char
*
)
v
bo
+
sz
;
Lck_New
(
&
v
bo
->
mtx
,
lck_busyobj
);
return
(
v
bo
);
bo
=
MPL_Get
(
vbopool
,
&
sz
);
XXXAN
(
bo
);
bo
->
magic
=
BUSYOBJ
_MAGIC
;
bo
->
end
=
(
char
*
)
bo
+
sz
;
Lck_New
(
&
bo
->
mtx
,
lck_busyobj
);
return
(
bo
);
}
void
VBO_Free
(
struct
vbo
**
v
bop
)
VBO_Free
(
struct
busyobj
**
bop
)
{
struct
vbo
*
v
bo
;
struct
busyobj
*
bo
;
AN
(
v
bop
);
vbo
=
*
v
bop
;
*
v
bop
=
NULL
;
CHECK_OBJ_NOTNULL
(
vbo
,
VBO
_MAGIC
);
AZ
(
v
bo
->
refcount
);
Lck_Delete
(
&
v
bo
->
mtx
);
MPL_Free
(
vbopool
,
v
bo
);
AN
(
bop
);
bo
=
*
bop
;
*
bop
=
NULL
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ
_MAGIC
);
AZ
(
bo
->
refcount
);
Lck_Delete
(
&
bo
->
mtx
);
MPL_Free
(
vbopool
,
bo
);
}
struct
busyobj
*
VBO_GetBusyObj
(
struct
worker
*
wrk
)
{
struct
vbo
*
v
bo
=
NULL
;
struct
busyobj
*
bo
=
NULL
;
uint16_t
nhttp
;
unsigned
sz
;
char
*
p
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
if
(
wrk
->
n
v
bo
!=
NULL
)
{
vbo
=
wrk
->
nv
bo
;
wrk
->
n
v
bo
=
NULL
;
if
(
wrk
->
nbo
!=
NULL
)
{
bo
=
wrk
->
n
bo
;
wrk
->
nbo
=
NULL
;
}
if
(
v
bo
==
NULL
)
v
bo
=
vbo_New
();
if
(
bo
==
NULL
)
bo
=
vbo_New
();
CHECK_OBJ_NOTNULL
(
vbo
,
VBO
_MAGIC
);
AZ
(
v
bo
->
refcount
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ
_MAGIC
);
AZ
(
bo
->
refcount
);
AZ
(
vbo
->
bo
.
magic
);
vbo
->
refcount
=
1
;
vbo
->
bo
.
magic
=
BUSYOBJ_MAGIC
;
vbo
->
bo
.
vbo
=
vbo
;
bo
->
refcount
=
1
;
p
=
(
void
*
)(
v
bo
+
1
);
p
=
(
void
*
)(
bo
+
1
);
p
=
(
void
*
)
PRNDUP
(
p
);
assert
(
p
<
v
bo
->
end
);
assert
(
p
<
bo
->
end
);
nhttp
=
(
uint16_t
)
cache_param
->
http_max_hdr
;
sz
=
HTTP_estimate
(
nhttp
);
vbo
->
bo
.
bereq
=
HTTP_create
(
p
,
nhttp
);
bo
->
bereq
=
HTTP_create
(
p
,
nhttp
);
p
+=
sz
;
p
=
(
void
*
)
PRNDUP
(
p
);
assert
(
p
<
v
bo
->
end
);
assert
(
p
<
bo
->
end
);
vbo
->
bo
.
beresp
=
HTTP_create
(
p
,
nhttp
);
bo
->
beresp
=
HTTP_create
(
p
,
nhttp
);
p
+=
sz
;
p
=
(
void
*
)
PRNDUP
(
p
);
assert
(
p
<
v
bo
->
end
);
assert
(
p
<
bo
->
end
);
sz
=
cache_param
->
vsl_buffer
;
VSL_Setup
(
vbo
->
bo
.
vsl
,
p
,
sz
);
VSL_Setup
(
bo
->
vsl
,
p
,
sz
);
p
+=
sz
;
p
=
(
void
*
)
PRNDUP
(
p
);
assert
(
p
<
v
bo
->
end
);
assert
(
p
<
bo
->
end
);
WS_Init
(
vbo
->
bo
.
ws
,
"bo"
,
p
,
v
bo
->
end
-
p
);
WS_Init
(
bo
->
ws
,
"bo"
,
p
,
bo
->
end
-
p
);
return
(
&
vbo
->
bo
);
return
(
bo
);
}
#if 0
void
VBO_RefBusyObj(const struct busyobj *busyobj)
{
...
...
@@ -160,12 +149,12 @@ VBO_RefBusyObj(const struct busyobj *busyobj)
vbo->refcount++;
Lck_Unlock(&vbo->mtx);
}
#endif
void
VBO_DerefBusyObj
(
struct
worker
*
wrk
,
struct
busyobj
**
pbo
)
{
struct
busyobj
*
bo
;
struct
vbo
*
vbo
;
unsigned
r
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -173,22 +162,21 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
bo
=
*
pbo
;
*
pbo
=
NULL
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
vbo
=
bo
->
vbo
;
CHECK_OBJ_NOTNULL
(
vbo
,
VBO_MAGIC
);
Lck_Lock
(
&
vbo
->
mtx
);
assert
(
vbo
->
refcount
>
0
);
r
=
--
vbo
->
refcount
;
Lck_Unlock
(
&
vbo
->
mtx
);
Lck_Lock
(
&
bo
->
mtx
);
assert
(
bo
->
refcount
>
0
);
r
=
--
bo
->
refcount
;
Lck_Unlock
(
&
bo
->
mtx
);
if
(
r
)
return
;
VSL_Flush
(
vbo
->
bo
.
vsl
,
0
);
/* XXX: Sanity checks & cleanup */
memset
(
&
vbo
->
bo
,
0
,
sizeof
vbo
->
bo
);
VSL_Flush
(
bo
->
vsl
,
0
);
memset
(
&
bo
->
refcount
,
0
,
sizeof
*
bo
-
offsetof
(
struct
busyobj
,
refcount
));
if
(
cache_param
->
bo_cache
&&
wrk
->
n
v
bo
==
NULL
)
wrk
->
n
vbo
=
v
bo
;
if
(
cache_param
->
bo_cache
&&
wrk
->
nbo
==
NULL
)
wrk
->
n
bo
=
bo
;
else
VBO_Free
(
&
v
bo
);
VBO_Free
(
&
bo
);
}
bin/varnishd/cache/cache_center.c
View file @
59c6ae45
...
...
@@ -906,9 +906,9 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
#if 1
FetchBody
(
wrk
,
bo
);
#else
bo
->
task
.
func
=
FetchBody
;
bo
->
task
.
priv
=
bo
;
if
(
Pool_Task
(
wrk
->
pool
,
&
bo
->
task
,
POOL_NO_QUEUE
))
{
bo
->
fetch_
task
.
func
=
FetchBody
;
bo
->
fetch_
task
.
priv
=
bo
;
if
(
Pool_Task
(
wrk
->
pool
,
&
bo
->
fetch_
task
,
POOL_NO_QUEUE
))
{
FetchBody
(
wrk
,
bo
);
}
else
{
while
(
bo
->
state
<
BOS_FAILED
)
...
...
bin/varnishd/cache/cache_hash.c
View file @
59c6ae45
...
...
@@ -131,8 +131,6 @@ HSH_Cleanup(struct worker *wrk)
free
(
wrk
->
nhashpriv
);
wrk
->
nhashpriv
=
NULL
;
}
if
(
wrk
->
nvbo
!=
NULL
)
VBO_Free
(
&
wrk
->
nvbo
);
}
void
...
...
bin/varnishd/cache/cache_wrk.c
View file @
59c6ae45
...
...
@@ -147,8 +147,8 @@ wrk_thread_real(void *priv, unsigned thread_workspace)
if
(
w
->
vcl
!=
NULL
)
VCL_Rel
(
&
w
->
vcl
);
AZ
(
pthread_cond_destroy
(
&
w
->
cond
));
if
(
w
->
n
v
bo
!=
NULL
)
VBO_Free
(
&
w
->
n
v
bo
);
if
(
w
->
nbo
!=
NULL
)
VBO_Free
(
&
w
->
nbo
);
HSH_Cleanup
(
w
);
WRK_SumStat
(
w
);
return
(
NULL
);
...
...
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