aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-22 22:50:14 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-22 22:50:14 +0100
commitd6142b7f56400dbe45361c17c44ffab64a9b2c7f (patch)
tree600ab44b0011acad5e2c039197985fa27d3a95bc /src/cadet/cadet_api.c
parentac78538f43e5bf63af2d5327d93834e48bb10795 (diff)
API code cleanup
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 83ff2b3b79..1643f20958 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -432,29 +432,35 @@ create_channel (struct GNUNET_CADET_Handle *h,
*/
// FIXME: simplify: call_cleaner is always #GNUNET_YES!!!
static void
-destroy_channel (struct GNUNET_CADET_Channel *ch, int call_cleaner)
+destroy_channel (struct GNUNET_CADET_Channel *ch,
+ int call_cleaner)
{
struct GNUNET_CADET_Handle *h;
struct GNUNET_CADET_TransmitHandle *th;
struct GNUNET_CADET_TransmitHandle *next;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " destroy_channel %X\n", ch->ccn);
-
if (NULL == ch)
{
GNUNET_break (0);
return;
}
h = ch->cadet;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " destroy_channel %X of %p\n",
+ ch->ccn,
+ h);
GNUNET_CONTAINER_DLL_remove (h->channels_head,
h->channels_tail,
ch);
/* signal channel destruction */
- if ( (NULL != h->cleaner) && (0 != ch->peer) && (GNUNET_YES == call_cleaner) )
+ if ( (NULL != h->cleaner) &&
+ (0 != ch->peer) &&
+ (GNUNET_YES == call_cleaner) )
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " calling cleaner\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " calling cleaner\n");
h->cleaner (h->cls, ch, ch->ctx);
}
@@ -781,7 +787,6 @@ handle_local_ack (void *cls,
struct GNUNET_CADET_Channel *ch;
struct GNUNET_CADET_ClientChannelNumber ccn;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK!\n");
ccn = message->ccn;
ch = retrieve_channel (h, ccn);
if (NULL == ch)
@@ -792,7 +797,7 @@ handle_local_ack (void *cls,
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- " on channel %X!\n",
+ "Got an ACK on channel %X!\n",
ntohl (ch->ccn.channel_of_client));
ch->allow_send = GNUNET_YES;
if (0 < ch->packet_size)
@@ -1420,6 +1425,14 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
}
+/**
+ * Disconnect from the cadet service. All channels will be destroyed. All channel
+ * disconnect callbacks will be called on any still connected peers, notifying
+ * about their disconnection. The registered inbound channel cleaner will be
+ * called should any inbound channels still exist.
+ *
+ * @param handle connection to cadet to disconnect
+ */
void
GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
{
@@ -1632,7 +1645,9 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
{
LOG (GNUNET_ERROR_TYPE_WARNING, "no meta-traffic should be queued\n");
}
- GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th);
+ GNUNET_CONTAINER_DLL_remove (h->th_head,
+ h->th_tail,
+ th);
GNUNET_CADET_notify_transmit_ready_cancel (th);
}
}
@@ -1643,7 +1658,8 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
GNUNET_MQ_send (h->mq,
env);
- destroy_channel (channel, GNUNET_YES);
+ destroy_channel (channel,
+ GNUNET_YES);
}