[glib] tests/unix: Don't error immediately on timeout
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] tests/unix: Don't error immediately on timeout
- Date: Tue, 23 Jul 2013 18:43:52 +0000 (UTC)
commit baf7f1e23e4c924049e75fe11ea029846c03706d
Author: Colin Walters <walters verbum org>
Date: Mon Jul 22 19:31:35 2013 +0100
tests/unix: Don't error immediately on timeout
On a heavily loaded system, it's possible that both our normal
condition *and* the timeout occurred. In that case we can just ignore
the timeout.
While I did add a "sig_timeout" boolean, we don't need to add any
assertions around whether or not it was reached - the assertions
covering the non-timeout case are sufficient. The sig_timeout boolean
is mainly for later debugging.
https://bugzilla.gnome.org/show_bug.cgi?id=700460
glib/tests/unix.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/glib/tests/unix.c b/glib/tests/unix.c
index f6a56ca..4731019 100644
--- a/glib/tests/unix.c
+++ b/glib/tests/unix.c
@@ -65,6 +65,7 @@ test_error (void)
}
static gboolean sig_received = FALSE;
+static gboolean sig_timeout = FALSE;
static int sig_counter = 0;
static gboolean
@@ -78,11 +79,11 @@ on_sig_received (gpointer user_data)
}
static gboolean
-sig_not_received (gpointer data)
+on_sig_timeout (gpointer data)
{
GMainLoop *loop = data;
- (void) loop;
- g_error ("Timed out waiting for signal");
+ g_main_loop_quit (loop);
+ sig_timeout = TRUE;
return G_SOURCE_REMOVE;
}
@@ -118,7 +119,7 @@ test_signal (int signum)
g_unix_signal_add (signum, on_sig_received, mainloop);
kill (getpid (), signum);
g_assert (!sig_received);
- id = g_timeout_add (5000, sig_not_received, mainloop);
+ id = g_timeout_add (5000, on_sig_timeout, mainloop);
g_main_loop_run (mainloop);
g_assert (sig_received);
sig_received = FALSE;
@@ -133,7 +134,7 @@ test_signal (int signum)
sig_counter = 0;
g_unix_signal_add (signum, on_sig_received_2, mainloop);
g_unix_signal_add (signum, on_sig_received_2, mainloop);
- id = g_timeout_add (500, sig_not_received, mainloop);
+ id = g_timeout_add (5000, on_sig_timeout, mainloop);
kill (getpid (), signum);
g_main_loop_run (mainloop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]