Example #1
0
/**
 * Adapter function called to destroy a connection to
 * the DHT service.
 *
 * @param cls closure
 * @param op_result service handle returned from the connect adapter
 */
static void 
dht_disconnect_adapter (void *cls,
			void *op_result)
{
  struct GNUNET_DHT_Handle *dht = op_result;

  GNUNET_DHT_disconnect (dht);
}
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  if (NULL != dht_handle)
  {
    GNUNET_DHT_disconnect (dht_handle);
    dht_handle = NULL;
  }
}
Example #3
0
/**
 * Dual of 'dht_ca' to perform the 'disconnect'/cleanup operation
 * once we no longer need to access this subsystem.
 *
 * @param cls closure
 * @param op_result whatever we returned from 'dht_ca'
 */
static void
dht_da (void *cls, void *op_result)
{
  struct MyContext *ctxt = cls;

  /* Disconnect from DHT service */
  GNUNET_DHT_disconnect ((struct GNUNET_DHT_Handle *) op_result);
  dht_handle = NULL;
}
Example #4
0
static void
end (void *cls)
{
  GNUNET_SCHEDULER_cancel (die_task);
  die_task = NULL;
  GNUNET_DHT_disconnect (dht_handle);
  dht_handle = NULL;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "DHT disconnected, returning success!\n");
  ok = 0;
}
/**
 * Shut down the DHT subsystem.
 */
void
GCD_shutdown (void)
{
  if (NULL != dht_handle)
  {
    GNUNET_DHT_disconnect (dht_handle);
    dht_handle = NULL;
  }
  if (NULL != announce_id_task)
  {
    GNUNET_SCHEDULER_cancel (announce_id_task);
    announce_id_task = NULL;
  }
}
Example #6
0
static void
end_badly ()
{
  /* do work here */
  FPRINTF (stderr, "%s",  "Ending on an unhappy note.\n");
  if (get_handle != NULL)
  {
    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping get request!\n");
    GNUNET_DHT_get_stop (get_handle);
  }
  if (retry_context.retry_task != NULL)
    GNUNET_SCHEDULER_cancel (retry_context.retry_task);
  GNUNET_DHT_disconnect (dht_handle);
  dht_handle = NULL;
  ok = 1;
}
Example #7
0
/**
 * Task run during shutdown.
 *
 * @param cls unused
 */
static void
cleanup_task (void *cls)
{
  struct ClientEntry *ce;

  while (NULL != (ce = client_head))
    handle_client_disconnect (NULL,
                              ce->client);
  GNUNET_DHT_disconnect (dht);
  dht = NULL;
  GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
  stats = NULL;
  GNUNET_SERVER_notification_context_destroy (nc);
  nc = NULL;
  GNUNET_free (my_private_key);
  my_private_key = NULL;
}
Example #8
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;
  }
}
Example #9
0
/**
 * Initialize the connection with the DHT service.
 *
 * @param cfg configuration to use
 * @param ht_len size of the internal hash table to use for
 *               processing multiple GET/FIND requests in parallel
 * @return handle to the DHT service, or NULL on error
 */
struct GNUNET_DHT_Handle *
GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
                    unsigned int ht_len)
{
  struct GNUNET_DHT_Handle *handle;

  handle = GNUNET_new (struct GNUNET_DHT_Handle);
  handle->cfg = cfg;
  handle->uid_gen =
      GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
  handle->active_requests = GNUNET_CONTAINER_multihashmap_create (ht_len, GNUNET_YES);
  if (GNUNET_NO == try_connect (handle))
  {
    GNUNET_DHT_disconnect (handle);
    return NULL;
  }
  return handle;
}
/**
 * Continue shutdown
 */
static void
on_resolver_cleanup(void)
{
  GNUNET_NAMESTORE_disconnect(namestore_handle, 1);
  GNUNET_DHT_disconnect(dht_handle);
}