static int result;
-static struct GNUNET_SCHEDULER_Task * abort_task;
+static struct GNUNET_SCHEDULER_Task *abort_task;
-static struct GNUNET_SCHEDULER_Task * shutdown_task;
+static struct GNUNET_SCHEDULER_Task *connect_task;
static unsigned int repetition;
* Shutdown nicely
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutdown\n");
if (NULL != abort_task)
{
GNUNET_SCHEDULER_cancel (abort_task);
+ abort_task = NULL;
+ }
+ if (NULL != connect_task)
+ {
+ GNUNET_SCHEDULER_cancel (connect_task);
+ connect_task = NULL;
}
if (NULL != ch1)
{
GNUNET_CADET_channel_destroy (ch1);
+ ch1 = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n");
* Something went wrong and timed out. Kill everything and set error flag
*/
static void
-do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_abort (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ABORT\n");
result = GNUNET_SYSERR;
abort_task = NULL;
- if (NULL != shutdown_task)
- {
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = NULL;
- }
- do_shutdown (cls, tc);
-}
-
-
-static void
-finish (void)
-{
- if (NULL != shutdown_task)
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &do_shutdown, NULL);
+ GNUNET_SCHEDULER_shutdown ();
}
ch2 = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "everything fine! finishing!\n");
result = GNUNET_OK;
- finish ();
+ GNUNET_SCHEDULER_shutdown ();
}
}
* Connect to other client and send data
*
* @param cls Closue (unused).
- * @param tc TaskContext.
*/
static void
-do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_connect (void *cls)
{
struct GNUNET_PeerIdentity id;
size_t size = sizeof (struct GNUNET_MessageHeader) + DATA_SIZE;
- if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
- return;
-
+ connect_task = NULL;
GNUNET_TESTING_peer_get_identity (me, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n");
ch1 = GNUNET_CADET_channel_create (cadet, NULL, &id, 1,
static uint32_t ports[] = {1, 0};
me = peer;
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
abort_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 15), &do_abort,
result = GNUNET_SYSERR;
return;
}
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO CADET :D\n");
- }
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_connect, NULL);
+ connect_task
+ = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &do_connect,
+ NULL);
}