aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
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,
303 303
304 304
305/** 305/**
306 * Channel went down, notify client and free data
307 * structure.
308 *
309 * @param ch channel that went down
310 */
311static void
312clean_up_channel (struct Channel *ch)
313{
314 struct Line *line = ch->line;
315 struct GNUNET_MQ_Envelope *env;
316 struct ClientPhoneHangupMessage *hup;
317
318 switch (ch->status)
319 {
320 case CS_CALLEE_INIT:
321 case CS_CALLEE_SHUTDOWN:
322 case CS_CALLER_SHUTDOWN:
323 break;
324 case CS_CALLEE_RINGING:
325 case CS_CALLEE_CONNECTED:
326 case CS_CALLER_CALLING:
327 case CS_CALLER_CONNECTED:
328 if (NULL != line)
329 {
330 env = GNUNET_MQ_msg (hup,
331 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
332 hup->cid = ch->cid;
333 GNUNET_MQ_send (line->mq,
334 env);
335 }
336 break;
337 }
338 if (NULL != line)
339 GNUNET_CONTAINER_DLL_remove (line->channel_head,
340 line->channel_tail,
341 ch);
342 GNUNET_free (ch);
343}
344
345
346/**
306 * Destroy a channel. 347 * Destroy a channel.
307 * 348 *
308 * @param ch channel to destroy. 349 * @param ch channel to destroy.
@@ -313,7 +354,11 @@ destroy_line_cadet_channels (struct Channel *ch)
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
314 "Destroying cadet channels\n"); 355 "Destroying cadet channels\n");
315 if (NULL != ch->channel) 356 if (NULL != ch->channel)
357 {
316 GNUNET_CADET_channel_destroy (ch->channel); 358 GNUNET_CADET_channel_destroy (ch->channel);
359 ch->channel = NULL;
360 }
361 clean_up_channel (ch);
317} 362}
318 363
319 364
@@ -1027,40 +1072,13 @@ inbound_end (void *cls,
1027 const struct GNUNET_CADET_Channel *channel) 1072 const struct GNUNET_CADET_Channel *channel)
1028{ 1073{
1029 struct Channel *ch = cls; 1074 struct Channel *ch = cls;
1030 struct Line *line = ch->line;
1031 struct GNUNET_MQ_Envelope *env;
1032 struct ClientPhoneHangupMessage *hup;
1033 1075
1034 GNUNET_assert (channel == ch->channel); 1076 GNUNET_assert (channel == ch->channel);
1035 ch->channel = NULL; 1077 ch->channel = NULL;
1036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1037 "Channel destroyed by CADET in state %d\n", 1079 "Channel destroyed by CADET in state %d\n",
1038 ch->status); 1080 ch->status);
1039 switch (ch->status) 1081 clean_up_channel (ch);
1040 {
1041 case CS_CALLEE_INIT:
1042 case CS_CALLEE_SHUTDOWN:
1043 case CS_CALLER_SHUTDOWN:
1044 break;
1045 case CS_CALLEE_RINGING:
1046 case CS_CALLEE_CONNECTED:
1047 case CS_CALLER_CALLING:
1048 case CS_CALLER_CONNECTED:
1049 if (NULL != line)
1050 {
1051 env = GNUNET_MQ_msg (hup,
1052 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
1053 hup->cid = ch->cid;
1054 GNUNET_MQ_send (line->mq,
1055 env);
1056 }
1057 break;
1058 }
1059 if (NULL != line)
1060 GNUNET_CONTAINER_DLL_remove (line->channel_head,
1061 line->channel_tail,
1062 ch);
1063 GNUNET_free (ch);
1064} 1082}
1065 1083
1066 1084