Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julian Bouzas
WirePlumber
Commits
d3d977cb
Commit
d3d977cb
authored
Dec 27, 2019
by
Julian Bouzas
Browse files
config-policy: add timeout when waiting on conditional variables
parent
c56209fa
Pipeline
#92272
passed with stage
in 2 minutes and 6 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/modules/config-policy.c
View file @
d3d977cb
...
...
@@ -71,6 +71,8 @@ loop_thread_start (void *d)
static
void
config_policy_setup
(
TestConfigPolicyFixture
*
self
,
gconstpointer
user_data
)
{
gint64
end_time
;
/* Data */
g_mutex_init
(
&
self
->
mutex
);
g_cond_init
(
&
self
->
cond
);
...
...
@@ -81,8 +83,13 @@ config_policy_setup (TestConfigPolicyFixture *self, gconstpointer user_data)
/* Wait for everything to be created */
g_mutex_lock
(
&
self
->
mutex
);
end_time
=
g_get_monotonic_time
()
+
3
*
G_TIME_SPAN_SECOND
;
while
(
!
self
->
created
)
g_cond_wait
(
&
self
->
cond
,
&
self
->
mutex
);
if
(
!
g_cond_wait_until
(
&
self
->
cond
,
&
self
->
mutex
,
end_time
))
{
/* Abort when timeout has passed */
g_warning
(
"Aborting due to timeout when waiting for connection"
);
abort
();
}
g_mutex_unlock
(
&
self
->
mutex
);
}
...
...
tests/modules/config-policy/context.c
View file @
d3d977cb
...
...
@@ -39,11 +39,17 @@ G_DEFINE_TYPE (WpConfigPolicyContext, wp_config_policy_context, G_TYPE_OBJECT);
static
WpBaseEndpoint
*
wait_for_endpoint
(
WpConfigPolicyContext
*
self
,
WpBaseEndpointLink
**
link
)
{
gint64
end_time
;
g_mutex_lock
(
&
self
->
mutex
);
/* Wait for endpoint to be set */
end_time
=
g_get_monotonic_time
()
+
3
*
G_TIME_SPAN_SECOND
;
while
(
!
self
->
endpoint
)
g_cond_wait
(
&
self
->
cond
,
&
self
->
mutex
);
if
(
!
g_cond_wait_until
(
&
self
->
cond
,
&
self
->
mutex
,
end_time
))
{
/* Abort when timeout has passed */
g_warning
(
"Aborting due to timeout when waiting for endpoint"
);
abort
();
}
/* Set endpoint to a local value and clear global value */
WpBaseEndpoint
*
endpoint
=
g_object_ref
(
self
->
endpoint
);
...
...
Write
Preview
Supports
Markdown
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