[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35037 - gnunet/src/rps
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35037 - gnunet/src/rps |
Date: |
Wed, 28 Jan 2015 19:25:42 +0100 |
Author: bartpolot
Date: 2015-01-28 19:25:42 +0100 (Wed, 28 Jan 2015)
New Revision: 35037
Modified:
gnunet/src/rps/gnunet-service-rps.c
Log:
- fix memory mangement when calling cadet to detect liveness
Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-01-28 18:05:20 UTC (rev 35036)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-01-28 18:25:42 UTC (rev 35037)
@@ -170,6 +170,11 @@
struct GNUNET_CADET_TransmitHandle *is_live_task;
/**
+ * Identity of the peer
+ */
+ struct GNUNET_PeerIdentity peer_id;
+
+ /**
* This is pobably followed by 'statistical' data (when we first saw
* him, how did we get his ID, how many pushes (in a timeinterval),
* ...)
@@ -497,9 +502,10 @@
* This is given to ntfy_tmt_rdy and called when the channel was
* successfully established.
*/
- size_t
+static size_t
peer_is_live (void *cls, size_t size, void *buf)
{
+ struct PeerContext *ctx = cls;
struct GNUNET_PeerIdentity *peer;
struct PeerContext *peer_ctx;
@@ -507,7 +513,8 @@
// 0 == size)
// TODO check
- peer = (struct GNUNET_PeerIdentity *) cls;
+ ctx->is_live_task = NULL;
+ peer = &ctx->peer_id;
peer_ctx = get_peer_ctx (peer_map, peer);
peer_ctx->peer_flags |= LIVING;
@@ -522,8 +529,6 @@
GNUNET_array_grow (peer_ctx->outstanding_ops,
peer_ctx->num_outstanding_ops, 0);
}
- GNUNET_free (peer);
-
//if (NULL != peer_ctx->is_live_task)
//{
// GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task);
@@ -541,7 +546,6 @@
const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *ctx;
- struct GNUNET_PeerIdentity *tmp_peer;
ctx = get_peer_ctx (peer_map, peer);
if (NULL == ctx->send_channel)
@@ -552,11 +556,12 @@
if (NULL == ctx->recv_channel)
{
- tmp_peer = GNUNET_new (struct GNUNET_PeerIdentity);
- *tmp_peer = *peer;
- ctx->is_live_task = GNUNET_CADET_notify_transmit_ready
(ctx->send_channel, GNUNET_NO,
-
GNUNET_TIME_UNIT_FOREVER_REL,
- 0, peer_is_live,
tmp_peer);
+ ctx->peer_id = *peer;
+ ctx->is_live_task =
+ GNUNET_CADET_notify_transmit_ready (ctx->send_channel, GNUNET_NO,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ sizeof (struct
GNUNET_MessageHeader),
+ peer_is_live, ctx);
}
// do I have to explicitly put it in the peer_map?
@@ -1429,14 +1434,17 @@
}
+ /* FIXME instead of this, destroy every known channel */
+ {
if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map,
peer_remove_cb, NULL))
LOG (GNUNET_ERROR_TYPE_WARNING,
"Iterating over peers to disconnect from them was cancelled\n");
+ }
- GNUNET_CONTAINER_multipeermap_destroy (peer_map);
-
GNUNET_NSE_disconnect (nse);
GNUNET_CADET_disconnect (cadet_handle);
+ GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (peer_map));
+ GNUNET_CONTAINER_multipeermap_destroy (peer_map);
RPS_sampler_destroy ();
GNUNET_array_grow (request_deltas, request_deltas_size, 0);
GNUNET_array_grow (gossip_list, gossip_list_size, 0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35037 - gnunet/src/rps,
gnunet <=