summaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-08-09 16:35:32 +0200
committerChristian Grothoff <christian@grothoff.org>2018-08-09 16:35:32 +0200
commit7caba06019ecc5775d3dbb513b70f52f620affb5 (patch)
tree93696c0ab1a31e3744fc375015fb0b6dbd95003d /src/conversation
parent1ded1c1bb3bcb16d1770f03b299fcaa0a0c2d813 (diff)
change CADET channel destroy API to not call the callback if the client initiated the channel's destruction
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/gnunet-service-conversation.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c
index fb9eec26e..059bb158b 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -303,6 +303,47 @@ handle_client_pickup_message (void *cls,
/**
+ * Channel went down, notify client and free data
+ * structure.
+ *
+ * @param ch channel that went down
+ */
+static void
+clean_up_channel (struct Channel *ch)
+{
+ struct Line *line = ch->line;
+ struct GNUNET_MQ_Envelope *env;
+ struct ClientPhoneHangupMessage *hup;
+
+ switch (ch->status)
+ {
+ case CS_CALLEE_INIT:
+ case CS_CALLEE_SHUTDOWN:
+ case CS_CALLER_SHUTDOWN:
+ break;
+ case CS_CALLEE_RINGING:
+ case CS_CALLEE_CONNECTED:
+ case CS_CALLER_CALLING:
+ case CS_CALLER_CONNECTED:
+ if (NULL != line)
+ {
+ env = GNUNET_MQ_msg (hup,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
+ hup->cid = ch->cid;
+ GNUNET_MQ_send (line->mq,
+ env);
+ }
+ break;
+ }
+ if (NULL != line)
+ GNUNET_CONTAINER_DLL_remove (line->channel_head,
+ line->channel_tail,
+ ch);
+ GNUNET_free (ch);
+}
+
+
+/**
* Destroy a channel.
*
* @param ch channel to destroy.
@@ -313,7 +354,11 @@ destroy_line_cadet_channels (struct Channel *ch)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Destroying cadet channels\n");
if (NULL != ch->channel)
+ {
GNUNET_CADET_channel_destroy (ch->channel);
+ ch->channel = NULL;
+ }
+ clean_up_channel (ch);
}
@@ -1027,40 +1072,13 @@ inbound_end (void *cls,
const struct GNUNET_CADET_Channel *channel)
{
struct Channel *ch = cls;
- struct Line *line = ch->line;
- struct GNUNET_MQ_Envelope *env;
- struct ClientPhoneHangupMessage *hup;
GNUNET_assert (channel == ch->channel);
ch->channel = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Channel destroyed by CADET in state %d\n",
ch->status);
- switch (ch->status)
- {
- case CS_CALLEE_INIT:
- case CS_CALLEE_SHUTDOWN:
- case CS_CALLER_SHUTDOWN:
- break;
- case CS_CALLEE_RINGING:
- case CS_CALLEE_CONNECTED:
- case CS_CALLER_CALLING:
- case CS_CALLER_CONNECTED:
- if (NULL != line)
- {
- env = GNUNET_MQ_msg (hup,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
- hup->cid = ch->cid;
- GNUNET_MQ_send (line->mq,
- env);
- }
- break;
- }
- if (NULL != line)
- GNUNET_CONTAINER_DLL_remove (line->channel_head,
- line->channel_tail,
- ch);
- GNUNET_free (ch);
+ clean_up_channel (ch);
}