/**
* Destroy an existing channel.
*
- * The existing end callback for the channel will be called immediately.
+ * The existing end callback for the channel will NOT be called.
* Any pending outgoing messages will be sent but no incoming messages will be
* accepted and no data callbacks will be called.
*
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Destroying channel due to GNUNET_CADET_channel_destroy()\n");
+ channel->disconnects = NULL;
destroy_channel (channel);
}
}
+/**
+ * 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.
*
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);
}
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);
}
/**
- * Function called whenever an MQ-channel is destroyed, even if the destruction
+ * Function called whenever an MQ-channel is destroyed, unless the destruction
* was requested by #GNUNET_CADET_channel_destroy.
* It must NOT call #GNUNET_CADET_channel_destroy on the channel.
*
/**
* Destroy an existing channel.
*
- * The existing end callback for the channel will be called immediately.
+ * The existing end callback for the channel will NOT be called.
* Any pending outgoing messages will be sent but no incoming messages will be
* accepted and no data callbacks will be called.
*
GNUNET_SCHEDULER_cancel (op->timeout_task);
op->timeout_task = NULL;
}
- if (NULL != (channel = op->channel))
- {
- op->channel = NULL;
- GNUNET_CADET_channel_destroy (channel);
- }
+ _GSS_operation_destroy2 (op);
}
{
struct Operation *op = channel_ctx;
+ op->channel = NULL;
+ _GSS_operation_destroy2 (op);
+}
+
+
+/**
+ * This function probably should not exist
+ * and be replaced by inlining more specific
+ * logic in the various places where it is called.
+ */
+void
+_GSS_operation_destroy2 (struct Operation *op)
+{
+ struct GNUNET_CADET_Channel *channel;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"channel_end_cb called\n");
- op->channel = NULL;
+ if (NULL != (channel = op->channel))
+ {
+ /* This will free op; called conditionally as this helper function
+ is also called from within the channel disconnect handler. */
+ op->channel = NULL;
+ GNUNET_CADET_channel_destroy (channel);
+ }
if (NULL != op->listener)
incoming_destroy (op);
else if (NULL != op->set)
"Peer request (op %u, app %s) rejected by client\n",
op->listener->operation,
GNUNET_h2s (&cs->listener->app_id));
- GNUNET_CADET_channel_destroy (op->channel);
+ _GSS_operation_destroy2 (op);
GNUNET_SERVICE_client_continue (cs->client);
}
int gc);
+/**
+ * This function probably should not exist
+ * and be replaced by inlining more specific
+ * logic in the various places where it is called.
+ */
+void
+_GSS_operation_destroy2 (struct Operation *op);
+
+
/**
* Get the table with implementing functions for set union.
*
}
-/**
- * Destroy remote channel.
- *
- * @param op operation
- */
-void destroy_channel (struct Operation *op)
-{
- struct GNUNET_CADET_Channel *channel;
-
- if (NULL != (channel = op->channel))
- {
- /* This will free op; called conditionally as this helper function
- is also called from within the channel disconnect handler. */
- op->channel = NULL;
- GNUNET_CADET_channel_destroy (channel);
- }
-}
-
-
/**
* Signal to the client that the operation has finished and
* destroy the operation.
{
op->state->phase = PHASE_DONE;
send_client_done (op);
- destroy_channel (op);
+ _GSS_operation_destroy2 (op);
}
}
}
op->state->phase = PHASE_DONE;
GNUNET_CADET_receive_done (op->channel);
send_client_done (op);
- destroy_channel (op);
+ _GSS_operation_destroy2 (op);
return;
}
break;