[libsoup/autobahn-integration-new: 2/2] autobahn-test.c: Implement timeout in main loop
- From: Diego Pino <dpino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/autobahn-integration-new: 2/2] autobahn-test.c: Implement timeout in main loop
- Date: Fri, 12 Mar 2021 03:04:27 +0000 (UTC)
commit 63d38ac992779d7585b90121900fb53891a0d597
Author: Diego Pino Garcia <dpino igalia com>
Date: Thu Mar 11 07:30:18 2021 +0000
autobahn-test.c: Implement timeout in main loop
tests/autobahn/autobahn-test.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/tests/autobahn/autobahn-test.c b/tests/autobahn/autobahn-test.c
index 81e4bb35..2c6ecfaa 100644
--- a/tests/autobahn/autobahn-test.c
+++ b/tests/autobahn/autobahn-test.c
@@ -116,8 +116,17 @@ connect_and_run (SoupSession *session, char *path, ConnectionFunc method, gpoint
g_test_message ("Connecting to %s", uri);
soup_session_websocket_connect_async (session, message, NULL, NULL, G_PRIORITY_DEFAULT, NULL,
on_connect, ctx);
- while (!ctx->done)
- g_main_context_iteration (async_context, TRUE);
+ time_t now = time(NULL);
+ const int timeout = 30;
+ const time_t threshold = now + timeout;
+ while (!ctx->done) {
+ g_main_context_iteration (async_context, TRUE);
+ now = time(NULL);
+ if (now > threshold) {
+ debug_printf (1, "Test timeout: %s\n", uri);
+ ctx->done = TRUE;
+ }
+ }
g_object_unref (message);
g_free (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]