[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 06/09: Implement channel cleanup in MQ API, simpli
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 06/09: Implement channel cleanup in MQ API, simplify destroy channel |
Date: |
Tue, 31 Jan 2017 05:09:14 +0100 |
This is an automated email from the git hooks/post-receive script.
bart-polot pushed a commit to branch master
in repository gnunet.
commit bdfdbcc9d8ad8f46131c0836a9d489005d6a7bd0
Author: Bart Polot <address@hidden>
AuthorDate: Tue Jan 31 04:33:36 2017 +0100
Implement channel cleanup in MQ API, simplify destroy channel
---
src/cadet/cadet_api.c | 47 ++++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index e00203b25..50306b73b 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -491,10 +491,8 @@ create_channel (struct GNUNET_CADET_Handle *h,
*
* @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;
@@ -516,13 +514,28 @@ destroy_channel (struct GNUNET_CADET_Channel *ch,
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 */
@@ -853,8 +866,7 @@ handle_channel_destroy (void *cls,
ntohl (ccn.channel_of_client));
return;
}
- destroy_channel (ch,
- GNUNET_YES);
+ destroy_channel (ch);
}
@@ -1546,7 +1558,7 @@ reconnect (struct GNUNET_CADET_Handle *h)
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);
@@ -1621,8 +1633,7 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle
*handle)
"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))
@@ -1829,8 +1840,7 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel
*channel)
GNUNET_MQ_send (h->mq,
env);
- destroy_channel (channel,
- GNUNET_YES);
+ destroy_channel (channel);
}
@@ -2362,7 +2372,7 @@ GNUNET_CADET_connecT (const struct
GNUNET_CONFIGURATION_Handle *cfg)
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);
@@ -2403,6 +2413,7 @@ GNUNET_CADET_open_porT (struct GNUNET_CADET_Handle *h,
struct GNUNET_CADET_Port *p;
GNUNET_assert (NULL != connects);
+ GNUNET_assert (NULL != disconnects);
p = GNUNET_new (struct GNUNET_CADET_Port);
p->cadet = h;
@@ -2462,6 +2473,8 @@ GNUNET_CADET_channel_creatE (struct GNUNET_CADET_Handle
*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);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (98fead2b7 -> 0e73a0143), gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 01/09: CADET MQ API documentation improvements, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 05/09: Fix free of NULL pointer, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 06/09: Implement channel cleanup in MQ API, simplify destroy channel,
gnunet <=
- [GNUnet-SVN] [gnunet] 03/09: Add note for clarification, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 04/09: Implementation of port opening and handling in MQ, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 07/09: Refactor reconnect code, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 02/09: Implement the connect and create_channel call for mq api, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 09/09: Implement incoming traffic handling on MQ, gnunet, 2017/01/30
- [GNUnet-SVN] [gnunet] 08/09: Reconnect to service instead of aborting on a malformed data message, gnunet, 2017/01/30