[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 16/64: do handle CTRL-C properly in test_social
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 16/64: do handle CTRL-C properly in test_social |
Date: |
Sat, 30 Dec 2017 20:58:01 +0100 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet.
commit cfd5e9d749ae8d9d07ef77943a9b560b491468fc
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Oct 29 11:25:20 2017 +0100
do handle CTRL-C properly in test_social
---
src/social/test_social.c | 91 +++++++++++++++++++++++++++++++-----------------
1 file changed, 59 insertions(+), 32 deletions(-)
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 8d49e7413..de2299320 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -180,10 +180,28 @@ host_announce2 ();
/**
- * Clean up all resources used.
+ * Terminate the test case (failure).
+ *
+ * @param cls NULL
*/
static void
-cleanup ()
+end_badly (void *cls)
+{
+ end_badly_task = NULL;
+ GNUNET_SCHEDULER_shutdown ();
+ res = 2;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Test FAILED.\n");
+}
+
+
+/**
+ * Terminate the test case (failure).
+ *
+ * @param cls NULL
+ */
+static void
+end_shutdown (void *cls)
{
if (NULL != id)
{
@@ -202,7 +220,11 @@ cleanup ()
GNUNET_PSYC_slicer_destroy (host_slicer);
host_slicer = NULL;
}
-
+ if (NULL != end_badly_task)
+ {
+ GNUNET_SCHEDULER_cancel (end_badly_task);
+ end_badly_task = NULL;
+ }
if (NULL != gst)
{
GNUNET_SOCIAL_guest_leave (gst, NULL, NULL, NULL);
@@ -216,21 +238,6 @@ cleanup ()
hst_plc = NULL;
}
GNUNET_SOCIAL_app_disconnect (app, NULL, NULL);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Terminate the test case (failure).
- *
- * @param cls NULL
- */
-static void
-end_badly (void *cls)
-{
- res = 1;
- cleanup ();
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test FAILED.\n");
}
@@ -242,8 +249,8 @@ end_badly (void *cls)
static void
end_normally (void *cls)
{
+ GNUNET_SCHEDULER_shutdown ();
res = 0;
- cleanup ();
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test PASSED.\n");
}
@@ -372,6 +379,7 @@ host_reconnected (void *cls, int result,
is_host_reconnected = GNUNET_YES;
if (GNUNET_YES == is_guest_reconnected)
{
+ GNUNET_assert (NULL != gst);
GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
}
}
@@ -390,6 +398,7 @@ guest_reconnected (void *cls, int result,
is_guest_reconnected = GNUNET_YES;
if (GNUNET_YES == is_host_reconnected)
{
+ GNUNET_assert (NULL != gst);
GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
}
}
@@ -411,11 +420,15 @@ app_recv_host (void *cls,
enum GNUNET_SOCIAL_AppPlaceState place_state)
{
struct GNUNET_HashCode host_pub_hash;
- GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash);
+
+ GNUNET_CRYPTO_hash (host_pub_key,
+ sizeof (*host_pub_key),
+ &host_pub_hash);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Test #%u: Got app host place notification: %s\n",
- test, GNUNET_h2s (&host_pub_hash));
+ test,
+ GNUNET_h2s (&host_pub_hash));
if (test == TEST_RECONNECT)
{
@@ -424,8 +437,11 @@ app_recv_host (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Test #%u: Reconnecting to host place: %s\n",
test, GNUNET_h2s (&host_pub_hash));
- hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer,
host_reconnected,
- host_answer_door,
host_farewell2, NULL);
+ hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer,
+ &host_reconnected,
+ &host_answer_door,
+ &host_farewell2,
+ NULL);
}
}
}
@@ -439,7 +455,10 @@ app_recv_guest (void *cls,
enum GNUNET_SOCIAL_AppPlaceState place_state)
{
struct GNUNET_HashCode guest_pub_hash;
- GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash);
+
+ GNUNET_CRYPTO_hash (guest_pub_key,
+ sizeof (*guest_pub_key),
+ &guest_pub_hash);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Test #%u: Got app guest place notification: %s\n",
@@ -447,13 +466,19 @@ app_recv_guest (void *cls,
if (test == TEST_RECONNECT)
{
- if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key)))
+ if (0 == memcmp (&place_pub_key,
+ guest_pub_key,
+ sizeof (*guest_pub_key)))
{
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Test #%u: Reconnecting to guest place: %s\n",
test, GNUNET_h2s (&guest_pub_hash));
- gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn,
GNUNET_PSYC_SLAVE_JOIN_NONE,
- guest_slicer,
guest_reconnected, NULL);
+ gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn,
+ GNUNET_PSYC_SLAVE_JOIN_NONE,
+ guest_slicer,
+ &guest_reconnected,
+ NULL);
+ GNUNET_assert (NULL != gst);
}
}
}
@@ -527,10 +552,10 @@ schedule_reconnect (void *cls)
GNUNET_SOCIAL_app_disconnect (app, NULL, NULL);
app = GNUNET_SOCIAL_app_connect (cfg, app_id,
- app_recv_ego,
- app_recv_host,
- app_recv_guest,
- app_connected,
+ &app_recv_ego,
+ &app_recv_host,
+ &app_recv_guest,
+ &app_connected,
NULL);
}
@@ -1387,9 +1412,11 @@ run (void *cls,
#endif
{
cfg = c;
+ res = 1;
end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly, NULL);
-
+ GNUNET_SCHEDULER_add_shutdown (&end_shutdown,
+ NULL);
GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer);
id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 03/64: don't call GNUNET_SERVICE_client_continue twice; maybe fix bug resulting from destroying MQ too early, (continued)
- [GNUnet-SVN] [gnunet] 03/64: don't call GNUNET_SERVICE_client_continue twice; maybe fix bug resulting from destroying MQ too early, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 04/64: -we no enter to place, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 13/64: clarify use of client_drop, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 17/64: logging, cosmetic fixes, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 09/64: misc social hacking with Lurchi, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 18/64: minor style fix, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 10/64: added logging, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 14/64: handle service disconnect without crashing if reconnect fails, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 15/64: better logging of message processing errors in mq handling, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 08/64: added logging, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 16/64: do handle CTRL-C properly in test_social,
gnunet <=
- [GNUnet-SVN] [gnunet] 12/64: fix wrong condition, do only drop if it has not been dropped, instead of causing double-drop, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 11/64: Merge branch 'fix_social' of gnunet.org:gnunet into fix_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 20/64: Fix tcp on exit crash -- could have sworn I fixed this one before, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 21/64: Merge branch 'fix_social' of gnunet.org:gnunet into fix_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 25/64: Merge branch 'fix_social' of gnunet.org:gnunet into fix_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 35/64: added FIXMEs, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 32/64: commented out wrong message type, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 40/64: revert commit 6490b5f31e58e9ec008f8c5ceda28f6054f1bbba, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 23/64: improve documentation, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 19/64: allow MST callback to distinguish between disconnect and parse error situations, and only log for the hard errors, gnunet, 2017/12/30