static void
terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "ENDING ANGRILY %u\n", ok);
    GNUNET_break (0);
    if (NULL != p1.ch)
    {
        GNUNET_CORE_disconnect (p1.ch);
        p1.ch = NULL;
    }
    if (NULL != p2.ch)
    {
        GNUNET_CORE_disconnect (p2.ch);
        p2.ch = NULL;
    }
    if (p1.th != NULL)
    {
        GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
        GNUNET_TRANSPORT_disconnect (p1.th);
        p1.th = NULL;
    }
    if (p2.th != NULL)
    {
        GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
        GNUNET_TRANSPORT_disconnect (p2.th);
        p2.th = NULL;
    }
    if (GNUNET_SCHEDULER_NO_TASK != con_task)
    {
        GNUNET_SCHEDULER_cancel (con_task);
        con_task = GNUNET_SCHEDULER_NO_TASK;
    }
    ok = 42;
}
static void
terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct GNUNET_CORE_Handle *ch;

  err_task = GNUNET_SCHEDULER_NO_TASK;
  GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO);
  GNUNET_STATISTICS_destroy (p2.stats, GNUNET_NO);
  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
  if (p1.nth != NULL)
  {
    GNUNET_CORE_notify_transmit_ready_cancel (p1.nth);
    p1.nth = NULL;
  }
  if (connect_task != GNUNET_SCHEDULER_NO_TASK)
  {
    GNUNET_SCHEDULER_cancel (connect_task);
    connect_task = GNUNET_SCHEDULER_NO_TASK;
  }
  ch = p1.ch;
  p1.ch = NULL;
  GNUNET_CORE_disconnect (ch);
  ch = p2.ch;
  p2.ch = NULL;
  GNUNET_CORE_disconnect (ch);
  GNUNET_TRANSPORT_disconnect (p1.th);
  p1.th = NULL;
  GNUNET_TRANSPORT_disconnect (p2.th);
  p2.th = NULL;
  GNUNET_free_non_null (p1.hello);
  GNUNET_free_non_null (p2.hello);
}
static void
disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct TestMessageContext *pos = cls;

  /* Disconnect from the respective cores */
#if VERBOSE > 1
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
              GNUNET_i2s (&pos->peer1->id));
#endif
  if (pos->peer1handle != NULL)
    GNUNET_CORE_disconnect (pos->peer1handle);
#if VERBOSE > 1
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
              GNUNET_i2s (&pos->peer2->id));
#endif
  if (pos->peer2handle != NULL)
    GNUNET_CORE_disconnect (pos->peer2handle);
  /* Set handles to NULL so test case can be ended properly */
  pos->peer1handle = NULL;
  pos->peer2handle = NULL;
  pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
  /* Decrement total connections so new can be established */
  total_server_connections -= 2;
}
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  GNUNET_CORE_disconnect (p1.ch);
  p1.ch = NULL;
  GNUNET_CORE_disconnect (p2.ch);
  p2.ch = NULL;
  ok = 0;
}
static void
finish_testing ()
{
  GNUNET_assert (pg != NULL);
  struct TestMessageContext *pos;
  struct TestMessageContext *free_pos;

#if VERBOSE
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Called finish testing, stopping daemons.\n");
#endif

  pos = test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
    {
      GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
    }
    GNUNET_free (free_pos);
  }
#if VERBOSE
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
              transmit_ready_scheduled, transmit_ready_failed,
              transmit_ready_called);
#endif

#if VERBOSE
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n");
#endif
  GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL);

  if (dotOutFile != NULL)
  {
    FPRINTF (dotOutFile, "%s",  "}");
    FCLOSE (dotOutFile);
  }

  ok = 0;
}
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  char *msg = cls;

  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
              "End badly was called (%s)... stopping daemons.\n", msg);
  struct TestMessageContext *pos;
  struct TestMessageContext *free_pos;

  pos = test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    GNUNET_free (free_pos);
  }

#if VERBOSE
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
              transmit_ready_scheduled, transmit_ready_failed,
              transmit_ready_called);
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Total messages received %d, expected %d.\n",
              total_messages_received, expected_messages);
#endif

  if (pg != NULL)
  {
    GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL);
    ok = 7331;                  /* Opposite of leet */
  }
  else
    ok = 401;                   /* Never got peers started */

  if (dotOutFile != NULL)
  {
    FPRINTF (dotOutFile, "%s",  "}");
    FCLOSE (dotOutFile);
  }
}
Exemple #7
0
static void
terminate_peer (struct PeerContext *p)
{
  if (NULL != p->ch)
  {
    GNUNET_CORE_disconnect (p->ch);
    p->ch = NULL;
  }
  if (NULL != p->ghh)
  {
    GNUNET_TRANSPORT_hello_get_cancel (p->ghh);
    p->ghh = NULL;
  }
  if (NULL != p->oh)
  {
    GNUNET_TRANSPORT_offer_hello_cancel (p->oh);
    p->oh = NULL;
  }
  if (NULL != p->ats_sh)
  {
    GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
    p->ats_sh = NULL;
  }
  if (NULL != p->ats)
  {
    GNUNET_ATS_connectivity_done (p->ats);
    p->ats = NULL;
  }
}
/**
 * Last task run during shutdown.  Disconnects us from
 * the transport and core.
 *
 * @param cls unused, NULL
 * @param tc scheduler context
 */
static void
cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  if (NULL != peerinfo_notify)
  {
    GNUNET_PEERINFO_notify_cancel (peerinfo_notify);
    peerinfo_notify = NULL;
  }
  GNUNET_TRANSPORT_disconnect (transport);
  transport = NULL;
  if (handle != NULL)
  {
    GNUNET_CORE_disconnect (handle);
    handle = NULL;
  }
  whitelist_peers ();
  if (GNUNET_SCHEDULER_NO_TASK != add_task)
  {
    GNUNET_SCHEDULER_cancel (add_task);
    add_task = GNUNET_SCHEDULER_NO_TASK;
  }
  GNUNET_CONTAINER_multihashmap_iterate (peers, &free_peer, NULL);
  GNUNET_CONTAINER_multihashmap_destroy (peers);
  peers = NULL;
  if (stats != NULL)
  {
    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
    stats = NULL;
  }
}
static void
timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  FPRINTF (stderr, "%s",  "Timeout.\n");
  if (p1.ch != NULL)
  {
    GNUNET_CORE_disconnect (p1.ch);
    p1.ch = NULL;
  }
  if (p2.ch != NULL)
  {
    GNUNET_CORE_disconnect (p2.ch);
    p2.ch = NULL;
  }
  ok = 42;
}
Exemple #10
0
/**
 * Last task run during shutdown.  Disconnects us from
 * the other services.
 *
 * @param cls NULL
 * @param tc scheduler context
 */
static void
cleaning_task (void *cls,
               const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
	      "Hostlist daemon is shutting down\n");
  if (NULL != core)
  {
    GNUNET_CORE_disconnect (core);
    core = NULL;
  }
  if (bootstrapping)
  {
    GNUNET_HOSTLIST_client_stop ();
  }
#if HAVE_MHD
  if (provide_hostlist)
  {
    GNUNET_HOSTLIST_server_stop ();
  }
#endif
  if (NULL != stats)
  {
    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
    stats = NULL;
  }
}
Exemple #11
0
static void
shutdown_task (void *cls,
               const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
  GNUNET_MQ_destroy (mq);
  GNUNET_CORE_disconnect (core);
}
Exemple #12
0
/**
 * Task run during shutdown.
 *
 * @param cls unused
 */
static void
shutdown_task (void *cls)
{
  if (NULL != flood_task)
  {
    GNUNET_SCHEDULER_cancel (flood_task);
    flood_task = NULL;
  }
  if (NULL != proof_task)
  {
    GNUNET_SCHEDULER_cancel (proof_task);
    proof_task = NULL;
    write_proof ();             /* remember progress */
  }
  if (NULL != nc)
  {
    GNUNET_notification_context_destroy (nc);
    nc = NULL;
  }
  if (NULL != core_api)
  {
    GNUNET_CORE_disconnect (core_api);
    core_api = NULL;
  }
  if (NULL != stats)
  {
    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
    stats = NULL;
  }
  if (NULL != peers)
  {
    GNUNET_CONTAINER_multipeermap_destroy (peers);
    peers = NULL;
  }
  if (NULL != my_private_key)
  {
    GNUNET_free (my_private_key);
    my_private_key = NULL;
  }
#if ENABLE_NSE_HISTOGRAM
  if (NULL != logger_test)
  {
    GNUNET_CLIENT_service_test_cancel (logger_test);
    logger_test = NULL;
  }
  if (NULL != lh)
  {
    GNUNET_TESTBED_LOGGER_flush (lh,
                                 &flush_comp_cb,
                                 NULL);
  }
  if (NULL != histogram)
  {
    GNUNET_BIO_write_close (histogram);
    histogram = NULL;
  }
#endif
}
Exemple #13
0
/**
 * @brief This function releases all resources held by the flooding component.
 *
 * \latexonly \\ \\ \endlatexonly
 * \em Detailed \em description \n
 * This function releases all resources held by the flooding component. It also disconnects from the GNUnet core and flushes the output queue.
 */
void gnunet_search_flooding_free() {
	GNUNET_CORE_disconnect(gnunet_search_flooding_core_handle);

	GNUNET_free(gnunet_search_flooding_routing_table);

	while(queue_get_length(gnunet_search_flooding_message_queue)) {
		struct gnunet_search_flooding_queued_message *msg =
				(struct gnunet_search_flooding_queued_message *) queue_dequeue(gnunet_search_flooding_message_queue);
		GNUNET_free(msg->buffer);
		GNUNET_free(msg);
	}
}
/**
 * Function scheduled as very last function, cleans up after us
 */
static void
cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tskctx)
{
  die_task = GNUNET_SCHEDULER_NO_TASK;

  if (core != NULL)
  {
    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting core.\n");
    GNUNET_CORE_disconnect (core);
    core = NULL;
  }
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
}
static void
terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
    GNUNET_assert (ok == 6);
    GNUNET_CORE_disconnect (p1.ch);
    p1.ch = NULL;
    GNUNET_CORE_disconnect (p2.ch);
    p2.ch = NULL;
    GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
    p1.ghh = NULL;
    GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
    p2.ghh = NULL;
    GNUNET_TRANSPORT_disconnect (p1.th);
    p1.th = NULL;
    GNUNET_TRANSPORT_disconnect (p2.th);
    p2.th = NULL;
    if (GNUNET_SCHEDULER_NO_TASK != con_task)
    {
        GNUNET_SCHEDULER_cancel (con_task);
        con_task = GNUNET_SCHEDULER_NO_TASK;
    }
    ok = 0;
}
static void
terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  err_task = GNUNET_SCHEDULER_NO_TASK;

  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase failed!\n");
  //GNUNET_break (0);
  if (p1.nth != NULL)
  {
    GNUNET_CORE_notify_transmit_ready_cancel (p1.nth);
    p1.nth = NULL;
  }
  if (measure_task != GNUNET_SCHEDULER_NO_TASK)
    GNUNET_SCHEDULER_cancel (measure_task);
  if (connect_task != GNUNET_SCHEDULER_NO_TASK)
  {
    GNUNET_SCHEDULER_cancel (connect_task);
    connect_task = GNUNET_SCHEDULER_NO_TASK;
  }

  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
  if (NULL != p1.ch)
    GNUNET_CORE_disconnect (p1.ch);
  p1.ch = NULL;
  if (NULL != p2.ch)
    GNUNET_CORE_disconnect (p2.ch);
  p2.ch = NULL;
  if (NULL != p1.th)
    GNUNET_TRANSPORT_disconnect (p1.th);
  p1.th = NULL;
  if (NULL != p2.th)
    GNUNET_TRANSPORT_disconnect (p2.th);
  p2.th = NULL;
  ok = 42;
}
static void
disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct TestMessageContext *pos = cls;

  /* Disconnect from the respective cores */
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
              GNUNET_i2s (&pos->peer1->id));
  if (pos->peer1handle != NULL)
  {
    GNUNET_CORE_disconnect (pos->peer1handle);
    pos->peer1handle = NULL;
  }
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
              GNUNET_i2s (&pos->peer2->id));
  if (pos->peer2handle != NULL)
  {
    GNUNET_CORE_disconnect (pos->peer2handle);
    pos->peer2handle = NULL;
  }
  pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
  /* Decrement total connections so new can be established */
  total_server_connections -= 2;
}
/**
 * Last task run during shutdown.  Disconnects us from
 * the transport and core.
 *
 * @param cls unused, NULL
 */
static void
cleaning_task (void *cls)
{
  if (NULL != peerinfo_notify)
  {
    GNUNET_PEERINFO_notify_cancel (peerinfo_notify);
    peerinfo_notify = NULL;
  }
  if (NULL != handle)
  {
    GNUNET_CORE_disconnect (handle);
    handle = NULL;
  }
  whitelist_peers ();
  if (NULL != add_task)
  {
    GNUNET_SCHEDULER_cancel (add_task);
    add_task = NULL;
  }
  if (NULL != oh)
  {
    GNUNET_TRANSPORT_offer_hello_cancel (oh);
    oh = NULL;
  }
  GNUNET_CONTAINER_multipeermap_iterate (peers,
                                         &free_peer,
                                         NULL);
  GNUNET_CONTAINER_multipeermap_destroy (peers);
  peers = NULL;
  if (NULL != ats)
  {
    GNUNET_ATS_connectivity_done (ats);
    ats = NULL;
  }
  if (NULL != stats)
  {
    GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
    stats = NULL;
  }
}
static void
terminate_peer (struct PeerContext *p)
{
  if (p->nth != NULL)
  {
    GNUNET_CORE_notify_transmit_ready_cancel (p->nth);
    p->nth = NULL;
  }
  if (NULL != p->ch)
  {
    GNUNET_CORE_disconnect (p->ch);
    p->ch = NULL;
  }
  if (NULL != p->th)
  {
    GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
    GNUNET_TRANSPORT_disconnect (p->th);
    p->th = NULL;
  }
  if (NULL != p->ats_sh)
  {
    GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
    p->ats_sh = NULL;
  }
  if (NULL != p->ats)
  {
    GNUNET_ATS_connectivity_done (p->ats);
    p->ats = NULL;
  }
  if (NULL != p->stats)
  {
    GNUNET_STATISTICS_destroy (p->stats, GNUNET_NO);
    p->stats = NULL;
  }
  if (NULL != p->hello)
  {
    GNUNET_free (p->hello);
    p->hello = NULL;
  }
}
/**
 * Stop the nodes management
 */
void
GED_nodes_stop ()
{
  if (NULL != ch)
  {
  		GNUNET_CORE_disconnect (ch);
  		ch = NULL;
  }

  if (NULL != nodes_requested)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_requested,
  																					 &cleanup_node,
  																					 nodes_requested);
  		update_stats (nodes_requested);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_requested);
  		nodes_requested = NULL;
  }

  if (NULL != nodes_active)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_active,
  																					 &cleanup_node,
  																					 nodes_active);
  		update_stats (nodes_active);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_active);
  		nodes_active = NULL;
  }

  if (NULL != nodes_inactive)
  {
  		GNUNET_CONTAINER_multipeermap_iterate (nodes_inactive,
  																					 &cleanup_node,
  																					 nodes_inactive);
  		update_stats (nodes_inactive);
  		GNUNET_CONTAINER_multipeermap_destroy (nodes_inactive);
  		nodes_inactive = NULL;
  }
}
static void
shutdown_testcase ()
{
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown testcase....\n");
  if (timeout_task != NULL)
  {
    GNUNET_SCHEDULER_cancel (timeout_task);
    timeout_task = NULL;
  }
  if (NULL != download_stats)
  {
    GNUNET_STATISTICS_get_cancel (download_stats);
    download_stats = NULL;
  }
  if (NULL != urisrecv_stat)
  {
    GNUNET_STATISTICS_get_cancel (urisrecv_stat);
    urisrecv_stat = NULL;
  }
  if (NULL != advsent_stat)
  {
    GNUNET_STATISTICS_get_cancel (advsent_stat);
    advsent_stat = NULL;
  }
  if (NULL != adv_peer.stats)
  {
    GNUNET_STATISTICS_destroy (adv_peer.stats, GNUNET_NO);
    adv_peer.stats = NULL;
  }
  if (NULL != learn_peer.stats)
  {
    GNUNET_STATISTICS_destroy (learn_peer.stats, GNUNET_NO);
    learn_peer.stats = NULL;
  }
  if (check_task != NULL)
  {
    GNUNET_SCHEDULER_cancel (check_task);
    check_task = NULL;
  }
  if (NULL != current_adv_uri)
  {
    GNUNET_free (current_adv_uri);
    current_adv_uri = NULL;
  }
  if (adv_peer.th != NULL)
  {
    GNUNET_TRANSPORT_disconnect (adv_peer.th);
    adv_peer.th = NULL;
  }
  if (learn_peer.th != NULL)
  {
    GNUNET_TRANSPORT_disconnect (learn_peer.th);
    learn_peer.th = NULL;
  }
  if (adv_peer.core != NULL)
  {
    GNUNET_CORE_disconnect (adv_peer.core);
    adv_peer.core = NULL;
  }
  if (learn_peer.core != NULL)
  {
    GNUNET_CORE_disconnect (learn_peer.core);
    learn_peer.core = NULL;
  }
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Killing hostlist server ARM process.\n");
  if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, GNUNET_TERM_SIG))
    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
  if (GNUNET_OS_process_wait (adv_peer.arm_proc) != GNUNET_OK)
    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
  GNUNET_OS_process_destroy (adv_peer.arm_proc);
  adv_peer.arm_proc = NULL;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Killing hostlist client ARM process.\n");
  if (0 != GNUNET_OS_process_kill (learn_peer.arm_proc, GNUNET_TERM_SIG))
    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
  if (GNUNET_OS_process_wait (learn_peer.arm_proc) != GNUNET_OK)
    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
  GNUNET_OS_process_destroy (learn_peer.arm_proc);
  learn_peer.arm_proc = NULL;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n");
}
static void
send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct TestMessageContext *pos;
  struct TestMessageContext *free_pos;
  struct PeerContext *peer_pos;

#if TEST_ALL
  struct PeerContext *inner_peer_pos;
  struct TestMessageContext *temp_context;
#endif
  peer_pos = all_peers;
  while (peer_pos != NULL)
  {
    if (peer_pos->peer_handle != NULL)
    {
      GNUNET_CORE_disconnect (peer_pos->peer_handle);
      peer_pos->peer_handle = NULL;
    }
#if TEST_ALL
    inner_peer_pos = all_peers;
    while (inner_peer_pos != NULL)
    {
      if (inner_peer_pos != peer_pos)
      {
        temp_total_other_messages++;
        temp_context = GNUNET_malloc (sizeof (struct TestMessageContext));
        temp_context->peer1 = peer_pos->daemon;
        temp_context->peer2 = inner_peer_pos->daemon;
        temp_context->next = other_test_messages;
        temp_context->uid = total_connections + temp_total_other_messages;
        temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
        other_test_messages = temp_context;
      }
      inner_peer_pos = inner_peer_pos->next;
    }
#endif
    peer_pos = peer_pos->next;
  }
  all_peers = NULL;

  pos = test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
    {
      GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
    }
    GNUNET_free (free_pos);
  }
  test_messages = NULL;

  total_other_expected_messages = temp_total_other_messages;
  if (total_other_expected_messages == 0)
  {
    GNUNET_SCHEDULER_add_now (&end_badly,
                              "send_other_messages had 0 messages to send, no DV connections made!");
  }
  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
              "Preparing to send %d other test messages\n",
              total_other_expected_messages);
  GNUNET_SCHEDULER_add_now (&send_test_messages, other_test_messages);
  if (GNUNET_SCHEDULER_NO_TASK != die_task)
    GNUNET_SCHEDULER_cancel (die_task);
  die_task =
      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                    (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly,
                                    "from send_other_messages");
}
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  char *msg = cls;
  struct TestMessageContext *pos;
  struct TestMessageContext *free_pos;
  struct PeerContext *peer_pos;
  struct PeerContext *free_peer_pos;

  die_task = GNUNET_SCHEDULER_NO_TASK;
  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
              "End badly was called (%s)... stopping daemons.\n", msg);

  peer_pos = all_peers;
  while (peer_pos != NULL)
  {
    if (peer_pos->peer_handle != NULL)
      GNUNET_CORE_disconnect (peer_pos->peer_handle);
    free_peer_pos = peer_pos;
    peer_pos = peer_pos->next;
    GNUNET_free (free_peer_pos);
  }
  all_peers = NULL;

  pos = test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    GNUNET_free (free_pos);
  }

  pos = other_test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
    {
      GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
    }
    GNUNET_free (free_pos);
  }

  if (pg != NULL)
  {
    GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
    ok = 7331;                  /* Opposite of leet */
  }
  else
    ok = 401;                   /* Never got peers started */

  if (dotOutFile != NULL)
  {
    FPRINTF (dotOutFile, "%s",  "}");
    FCLOSE (dotOutFile);
  }
}
static void
finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  GNUNET_assert (pg != NULL);
  struct PeerContext *peer_pos;
  struct PeerContext *free_peer_pos;
  struct TestMessageContext *pos;
  struct TestMessageContext *free_pos;

  die_task = GNUNET_SCHEDULER_NO_TASK;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Called finish testing, stopping daemons.\n");
  peer_pos = all_peers;
  while (peer_pos != NULL)
  {
    if (peer_pos->peer_handle != NULL)
      GNUNET_CORE_disconnect (peer_pos->peer_handle);
    free_peer_pos = peer_pos;
    peer_pos = peer_pos->next;
    GNUNET_free (free_peer_pos);
  }
  all_peers = NULL;

  pos = test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
    {
      GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
    }
    GNUNET_free (free_pos);
  }

  pos = other_test_messages;
  while (pos != NULL)
  {
    if (pos->peer1handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer1handle);
      pos->peer1handle = NULL;
    }
    if (pos->peer2handle != NULL)
    {
      GNUNET_CORE_disconnect (pos->peer2handle);
      pos->peer2handle = NULL;
    }
    free_pos = pos;
    pos = pos->next;
    if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
    {
      GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
    }
    GNUNET_free (free_pos);
  }
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
              transmit_ready_scheduled, transmit_ready_failed,
              transmit_ready_called);
  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
  if (dotOutFile != NULL)
  {
    FPRINTF (dotOutFile, "%s",  "}");
    FCLOSE (dotOutFile);
  }

  ok = 0;
}