static struct PeerContext p2;
-static void
-clean_up (void *cls)
-{
- if (NULL != p1.ghh)
- {
- GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
- p1.ghh = NULL;
- }
- if (p1.th != NULL)
- {
- GNUNET_TRANSPORT_disconnect (p1.th);
- p1.th = NULL;
- }
- if (NULL != p2.ghh)
- {
- GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
- p2.ghh = NULL;
- }
- if (p2.th != NULL)
- {
- GNUNET_TRANSPORT_disconnect (p2.th);
- p2.th = NULL;
- }
- GNUNET_SCHEDULER_shutdown ();
-}
-
/**
* Timeout, give up.
*/
timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout trying to connect peers, test failed.\n");
- clean_up (NULL);
+ GNUNET_SCHEDULER_shutdown ();
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peers connected, shutting down.\n");
ok = 0;
- if (timeout_task != NULL)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
- GNUNET_SCHEDULER_add_now (&clean_up, NULL);
+ GNUNET_SCHEDULER_shutdown ();
}
static void
shutdown_task (void *cls)
{
+ if (NULL != timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel (timeout_task);
+ timeout_task = NULL;
+ }
+ if (NULL != p1.ghh)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ p1.ghh = NULL;
+ }
+ if (p1.th != NULL)
+ {
+ GNUNET_TRANSPORT_disconnect (p1.th);
+ p1.th = NULL;
+ }
+ if (NULL != p2.ghh)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ p2.ghh = NULL;
+ }
+ if (p2.th != NULL)
+ {
+ GNUNET_TRANSPORT_disconnect (p2.th);
+ p2.th = NULL;
+ }
stop_arm (&p1);
stop_arm (&p2);
}
ok++;
timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&timeout_error, NULL);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf");
setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf");
}