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
e830d6dd
Commit
e830d6dd
authored
Jun 28, 2021
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
varnishtest: Barrier polish
Make the type-specific fields stand out without the help of comments.
parent
e0c5201f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
vtc_barrier.c
bin/varnishtest/vtc_barrier.c
+9
-7
No files found.
bin/varnishtest/vtc_barrier.c
View file @
e830d6dd
...
...
@@ -61,10 +61,12 @@ struct barrier {
int
waiters
;
int
expected
;
int
cyclic
;
int
cycle
;
/* BARRIER_COND only */
enum
barrier_e
type
;
pthread_t
thread
;
/* BARRIER_SOCK only */
union
{
int
cond_cycle
;
pthread_t
sock_thread
;
};
};
static
VTAILQ_HEAD
(,
barrier
)
barriers
=
VTAILQ_HEAD_INITIALIZER
(
barriers
);
...
...
@@ -254,7 +256,7 @@ barrier_sock(struct barrier *b, const char *av, struct vtclog *vl)
/* NB. We can use the BARRIER_COND's pthread_cond_t to wait until the
* socket is ready for convenience.
*/
AZ
(
pthread_create
(
&
b
->
thread
,
NULL
,
barrier_sock_thread
,
b
));
AZ
(
pthread_create
(
&
b
->
sock_
thread
,
NULL
,
barrier_sock_thread
,
b
));
AZ
(
pthread_cond_wait
(
&
b
->
cond
,
&
b
->
mtx
));
AZ
(
pthread_mutex_unlock
(
&
b
->
mtx
));
}
...
...
@@ -307,7 +309,7 @@ barrier_cond_sync(struct barrier *b, struct vtclog *vl)
else
b
->
waiters
=
++
w
;
c
=
b
->
cycle
;
c
=
b
->
c
ond_c
ycle
;
AZ
(
pthread_mutex_unlock
(
&
b
->
mtx
));
if
(
w
<
0
)
...
...
@@ -318,7 +320,7 @@ barrier_cond_sync(struct barrier *b, struct vtclog *vl)
AZ
(
pthread_mutex_lock
(
&
b
->
mtx
));
if
(
w
==
b
->
expected
)
{
vtc_log
(
vl
,
4
,
"Barrier(%s) wake %u"
,
b
->
name
,
b
->
expected
);
b
->
cycle
++
;
b
->
c
ond_c
ycle
++
;
if
(
b
->
cyclic
)
b
->
waiters
=
0
;
AZ
(
pthread_cond_broadcast
(
&
b
->
cond
));
...
...
@@ -330,7 +332,7 @@ barrier_cond_sync(struct barrier *b, struct vtclog *vl)
r
=
pthread_cond_timedwait
(
&
b
->
cond
,
&
b
->
mtx
,
&
ts
);
assert
(
r
==
0
||
r
==
ETIMEDOUT
);
}
while
(
!
vtc_stop
&&
!
vtc_error
&&
r
==
ETIMEDOUT
&&
c
==
b
->
cycle
);
c
==
b
->
c
ond_c
ycle
);
}
AZ
(
pthread_mutex_unlock
(
&
b
->
mtx
));
}
...
...
@@ -455,7 +457,7 @@ cmd_barrier(CMD_ARGS)
case
BARRIER_COND
:
break
;
case
BARRIER_SOCK
:
AZ
(
pthread_join
(
b
->
thread
,
NULL
));
AZ
(
pthread_join
(
b
->
sock_
thread
,
NULL
));
break
;
default:
WRONG
(
"Wrong barrier type"
);
...
...
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