*
* @return Handle to the required channel or NULL if not found.
*/
-// 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)
{
struct GNUNET_CADET_Handle *h;
struct GNUNET_CADET_TransmitHandle *th;
ch);
/* signal channel destruction */
- if ( (NULL != h->cleaner) &&
- (0 != ch->peer) &&
- (GNUNET_YES == call_cleaner) )
+ if (0 != ch->peer)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- " calling cleaner\n");
- h->cleaner (h->cls, ch, ch->ctx);
+ if (NULL != h->cleaner)
+ {
+ /** @a deprecated */
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " calling cleaner\n");
+ h->cleaner (h->cls, ch, ch->ctx);
+ }
+ else if (NULL != ch->disconnects)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " calling disconnect handler\n");
+ ch->disconnects (ch->ctx, ch);
+ }
+ else
+ {
+ /* Application won't be aware of the channel destruction and use
+ * a pointer to free'd memory.
+ */
+ GNUNET_assert (0);
+ }
}
/* check that clients did not leave messages behind in the queue */
ntohl (ccn.channel_of_client));
return;
}
- destroy_channel (ch,
- GNUNET_YES);
+ destroy_channel (ch);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Requested RECONNECT, destroying all channels\n");
while (NULL != (ch = h->channels_head))
- destroy_channel (ch, GNUNET_YES);
+ destroy_channel (ch);
if (NULL == h->reconnect_task)
h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time,
&reconnect_cbk, h);
"channel %X not destroyed\n",
ntohl (ch->ccn.channel_of_client));
}
- destroy_channel (ch,
- GNUNET_YES);
+ destroy_channel (ch);
ch = aux;
}
while (NULL != (th = handle->th_head))
GNUNET_MQ_send (h->mq,
env);
- destroy_channel (channel,
- GNUNET_YES);
+ destroy_channel (channel);
}
h->mq_api = GNUNET_YES;
h->ports = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_YES);
do_reconnect (h);
- if (h->mq == NULL)
+ if (NULL == h->mq)
{
GNUNET_break (0);
GNUNET_CADET_disconnect (h);
struct GNUNET_CADET_Port *p;
GNUNET_assert (NULL != connects);
+ GNUNET_assert (NULL != disconnects);
p = GNUNET_new (struct GNUNET_CADET_Port);
p->cadet = h;
struct GNUNET_CADET_LocalChannelCreateMessage *msg;
struct GNUNET_MQ_Envelope *env;
+ GNUNET_assert (NULL != disconnects);
+
/* Save parameters */
ccn.channel_of_client = htonl (0);
ch = create_channel (h, ccn);