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
7d22d7d0
Commit
7d22d7d0
authored
Aug 19, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the cheesy sleep-loop with a proper cond-var.
parent
2bbdf01b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
13 deletions
+26
-13
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_busyobj.c
bin/varnishd/cache/cache_busyobj.c
+2
-0
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+23
-13
No files found.
bin/varnishd/cache/cache.h
View file @
7d22d7d0
...
...
@@ -500,6 +500,7 @@ struct busyobj {
unsigned
magic
;
#define BUSYOBJ_MAGIC 0x23b95567
struct
lock
mtx
;
pthread_cond_t
cond
;
char
*
end
;
enum
fetch_step
step
;
...
...
bin/varnishd/cache/cache_busyobj.c
View file @
7d22d7d0
...
...
@@ -69,6 +69,7 @@ vbo_New(void)
bo
->
magic
=
BUSYOBJ_MAGIC
;
bo
->
end
=
(
char
*
)
bo
+
sz
;
Lck_New
(
&
bo
->
mtx
,
lck_busyobj
);
AZ
(
pthread_cond_init
(
&
bo
->
cond
,
NULL
));
return
(
bo
);
}
...
...
@@ -82,6 +83,7 @@ VBO_Free(struct busyobj **bop)
*
bop
=
NULL
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
AZ
(
bo
->
refcount
);
AZ
(
pthread_cond_destroy
(
&
bo
->
cond
));
Lck_Delete
(
&
bo
->
mtx
);
MPL_Free
(
vbopool
,
bo
);
}
...
...
bin/varnishd/cache/cache_fetch.c
View file @
7d22d7d0
...
...
@@ -47,8 +47,12 @@
static
void
vbf_release_req
(
struct
busyobj
*
bo
)
{
if
(
bo
->
req
!=
NULL
)
bo
->
req
=
NULL
;
if
(
bo
->
req
==
NULL
)
return
;
Lck_Lock
(
&
bo
->
mtx
);
bo
->
req
=
NULL
;
AZ
(
pthread_cond_signal
(
&
bo
->
cond
));
Lck_Unlock
(
&
bo
->
mtx
);
}
/*--------------------------------------------------------------------
...
...
@@ -391,7 +395,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
* Ready to fetch the body
*/
assert
(
bo
->
refcount
>=
2
);
/* one for each thread */
assert
(
bo
->
refcount
>=
1
);
if
(
obj
->
objcore
->
objhead
!=
NULL
)
{
EXP_Insert
(
obj
);
...
...
@@ -477,27 +481,31 @@ static void
vbf_fetch_thread
(
struct
worker
*
wrk
,
void
*
priv
)
{
struct
busyobj
*
bo
;
enum
fetch_step
stp
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
bo
,
priv
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
->
req
,
REQ_MAGIC
);
THR_SetBusyobj
(
bo
);
bo
->
ste
p
=
F_STP_MKBEREQ
;
st
p
=
F_STP_MKBEREQ
;
while
(
bo
->
step
!=
F_STP_DONE
)
{
switch
(
bo
->
step
)
{
while
(
stp
!=
F_STP_DONE
)
{
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
bo
->
step
=
stp
;
switch
(
stp
)
{
#define FETCH_STEP(l, U, arg) \
case F_STP_##U: \
bo->step = vbf_stp_##l arg; \
VSLb(bo->vsl, SLT_Debug, \
"%s -> %s", #l, vbf_step_name(bo->step)); \
stp = vbf_stp_##l arg; \
break;
#include "tbl/steps.h"
#undef FETCH_STEP
default:
WRONG
(
"Illegal fetch_step"
);
}
if
(
stp
!=
F_STP_DONE
)
VSLb
(
bo
->
vsl
,
SLT_Debug
,
"%s -> %s"
,
vbf_step_name
(
bo
->
step
),
vbf_step_name
(
stp
));
}
assert
(
WRW_IsReleased
(
wrk
));
THR_SetBusyobj
(
NULL
);
...
...
@@ -521,7 +529,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, int pass)
oc
->
busyobj
=
bo
;
assert
(
bo
->
refcount
>=
1
);
CHECK_OBJ_NOTNULL
(
bo
->
vcl
,
VCL_CONF_MAGIC
);
bo
->
do_pass
=
pass
;
...
...
@@ -540,9 +547,12 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, int pass)
if
(
Pool_Task
(
wrk
->
pool
,
&
bo
->
fetch_task
,
POOL_QUEUE_FRONT
))
vbf_fetch_thread
(
wrk
,
bo
);
while
(
bo
->
req
!=
NULL
)
{
printf
(
"XXX
\n
"
);
(
void
)
usleep
(
100000
);
Lck_Lock
(
&
bo
->
mtx
);
while
(
1
)
{
if
(
bo
->
req
==
NULL
)
break
;
(
void
)
Lck_CondWait
(
&
bo
->
cond
,
&
bo
->
mtx
,
NULL
);
}
Lck_Unlock
(
&
bo
->
mtx
);
return
(
bo
);
}
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