示例#1
0
/**
 * Callback called when a client disconnected from the service
 *
 * @param cls closure for the service
 * @param client the client that disconnected
 * @param internal_cls should be equal to @a c
 */
static void
client_disconnect_cb (void *cls,
		      struct GNUNET_SERVICE_Client *client,
		      void *internal_cls)
{
  struct CadetClient *c = internal_cls;

  GNUNET_assert (c->client == client);
  c->shutting_down = GNUNET_YES;
  if (NULL != c->own_channels)
  {
    GNUNET_CONTAINER_multihashmap32_iterate (c->own_channels,
                                             &own_channel_destroy_iterator,
                                             c);
    GNUNET_CONTAINER_multihashmap32_destroy (c->own_channels);
  }
  if (NULL != c->incoming_channels)
  {
    GNUNET_CONTAINER_multihashmap32_iterate (c->incoming_channels,
                                             &incoming_channel_destroy_iterator,
                                             c);
    GNUNET_CONTAINER_multihashmap32_destroy (c->incoming_channels);
  }
  if (NULL != c->ports)
  {
    GNUNET_CONTAINER_multihashmap_iterate (c->ports,
                                           &client_release_ports,
                                           c);
    GNUNET_CONTAINER_multihashmap_destroy (c->ports);
  }
  GNUNET_CONTAINER_DLL_remove (clients_head,
                               clients_tail,
                               c);
  GNUNET_STATISTICS_update (stats,
                            "# clients",
                            -1,
                            GNUNET_NO);
  GNUNET_free (c);
}
/**
 * Iterate over all channels of a tunnel.
 *
 * @param t Tunnel whose channels to iterate.
 * @param iter Iterator.
 * @param iter_cls Closure for @c iter.
 */
void
GCT_iterate_channels (struct CadetTunnel *t,
                      GCT_ChannelIterator iter,
                      void *iter_cls)
{
  struct ChanIterCls ctx;

  ctx.iter = iter;
  ctx.iter_cls = iter_cls;
  GNUNET_CONTAINER_multihashmap32_iterate (t->channels,
                                           &iterate_channels_cb,
                                           &ctx);

}
/**
 * Clear cache
 */
void
GST_cache_clear ()
{
  if (NULL != cache)
  {
    GNUNET_CONTAINER_multihashmap32_iterate (cache, &cache_clear_iterator, NULL);
    GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (cache));
    GNUNET_CONTAINER_multihashmap32_destroy (cache);
    cache = NULL;
  }
  cache_size = 0;
  cache_head = NULL;
  cache_tail = NULL;
}
示例#4
0
/**
 * Shut down the DHT subsystem.
 */
void
GCD_shutdown (void)
{
  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down DHT\n");
  GNUNET_CONTAINER_multihashmap32_iterate (get_requests, &stop_get, NULL);
  GNUNET_CONTAINER_multihashmap32_destroy (get_requests);
  if (dht_handle != NULL)
  {
    GNUNET_DHT_disconnect (dht_handle);
    dht_handle = NULL;
  }
  if (NULL != announce_id_task)
  {
    GNUNET_SCHEDULER_cancel (announce_id_task);
    announce_id_task = NULL;
  }
}
示例#5
0
/**
 * Cancels operations and tasks which are assigned to the given run context
 *
 * @param rc the RunContext
 */
static void
rc_cleanup_operations (struct GNUNET_TESTBED_RunHandle *rc)
{
  struct CompatibilityCheckContext *hc;
  unsigned int nhost;

  if (NULL != rc->hclist)
  {
    for (nhost = 0; nhost < rc->num_hosts; nhost++)
    {
      hc = &rc->hclist[nhost];
      if (NULL != hc->h)
        GNUNET_TESTBED_is_host_habitable_cancel (hc->h);
    }
    GNUNET_free (rc->hclist);
    rc->hclist = NULL;
  }
  /* Stop register hosts task if it is running */
  if (NULL != rc->register_hosts_task)
  {
    GNUNET_SCHEDULER_cancel (rc->register_hosts_task);
    rc->register_hosts_task = NULL;
  }
  if (NULL != rc->timeout_task)
  {
    GNUNET_SCHEDULER_cancel (rc->timeout_task);
    rc->timeout_task = NULL;
  }
  if (NULL != rc->reg_handle)
  {
    GNUNET_TESTBED_cancel_registration (rc->reg_handle);
    rc->reg_handle = NULL;
  }
  if (NULL != rc->topology_operation)
  {
    GNUNET_TESTBED_operation_done (rc->topology_operation);
    rc->topology_operation = NULL;
  }
  /* cancel any exiting operations */
  GNUNET_assert (GNUNET_SYSERR !=
                 GNUNET_CONTAINER_multihashmap32_iterate (rc->rcop_map,
                                                          &rcop_cleanup_iterator,
                                                          rc));
}
/**
 * Log all possible info about the tunnel state.
 *
 * @param t Tunnel to debug.
 * @param level Debug level to use.
 */
void
GCT_debug (const struct CadetTunnel *t,
           enum GNUNET_ErrorType level)
{
  struct CadetTConnection *iter_c;
  int do_log;

  do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK),
                                       "cadet-tun",
                                       __FILE__, __FUNCTION__, __LINE__);
  if (0 == do_log)
    return;

  LOG2 (level,
        "TTT TUNNEL TOWARDS %s in cstate %s, estate %s tq_len: %u #cons: %u\n",
        GCT_2s (t),
        cstate2s (t->cstate),
        estate2s (t->estate),
        t->tq_len,
        t->num_connections);
#if DUMP_KEYS_TO_STDERR
  ax_debug (t->ax, level);
#endif
  LOG2 (level,
        "TTT channels:\n");
  GNUNET_CONTAINER_multihashmap32_iterate (t->channels,
                                           &debug_channel,
                                           &level);
  LOG2 (level,
        "TTT connections:\n");
  for (iter_c = t->connection_head; NULL != iter_c; iter_c = iter_c->next)
    GCC_debug (iter_c->cc,
               level);

  LOG2 (level,
        "TTT TUNNEL END\n");
}