*/
/**
* @file cadet/gnunet-service-cadet_hello.c
- * @brief spread knowledge about how to contact other peers from PEERINFO
+ * @brief spread knowledge about how to contact us (get HELLO from peerinfo),
+ * and remember HELLOs of other peers we have an interest in
* @author Bartlomiej Polot
* @author Christian Grothoff
- *
- * TODO:
- * - is most of this necessary/helpful?
- * - should we not simply restrict this to OUR hello?
*/
#include "platform.h"
#include "gnunet_util_lib.h"
&port,
GNUNET_CADET_OPTION_RELIABLE,
NULL, /* WindowSize handler */
- cleanup_destroyed_channel, /* Disconnect handler */
+ &cleanup_destroyed_channel, /* Disconnect handler */
cadet_handlers);
}
GNUNET_assert (NULL != peer_ctx->send_channel_ctx);
return GNUNET_NO;
}
+
/**
* @brief Callback for scheduler to destroy a channel
*
destroy_channel (struct ChannelCtx *channel_ctx)
{
struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
-
+ struct GNUNET_CADET_Channel *channel;
+
if (NULL != channel_ctx->destruction_task)
{
GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
channel_ctx->destruction_task = NULL;
}
- GNUNET_CADET_channel_destroy (channel_ctx->channel);
+ channel = channel_ctx->channel;
channel_ctx->channel = NULL;
+ GNUNET_CADET_channel_destroy (channel);
remove_channel_ctx (channel_ctx);
}
+
/**
* @brief Destroy a cadet channel.
*
destroy_channel_cb (void *cls)
{
struct ChannelCtx *channel_ctx = cls;
+
channel_ctx->destruction_task = NULL;
destroy_channel (channel_ctx);
}
+
/**
* @brief Schedule the destruction of a channel for immediately afterwards.
*
static void
schedule_channel_destruction (struct ChannelCtx *channel_ctx)
{
+ GNUNET_assert (NULL ==
+ channel_ctx->destruction_task);
+ GNUNET_assert (NULL !=
+ channel_ctx->channel);
channel_ctx->destruction_task =
- GNUNET_SCHEDULER_add_now (destroy_channel_cb, channel_ctx);
+ GNUNET_SCHEDULER_add_now (&destroy_channel_cb,
+ channel_ctx);
}
+
/**
* @brief Remove peer
*
// * cleanup everything related to the channel
// * memory
// * remove peer if necessary
-
+ channel_ctx->channel = NULL;
if (peer_ctx->recv_channel_ctx == channel_ctx)
{
remove_channel_ctx (channel_ctx);