summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-21 22:45:13 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-21 22:45:13 +0000
commitdfdf4604dbc772f414cf0776f247e639f3f132bc (patch)
treeb3c61128741c2452f130e57da327e0aeba0d5300 /src
parent28a7927307f5919892c4df4cf475f0d06bb60830 (diff)
Free successor_hash_map
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c2
-rw-r--r--src/dht/gnunet_dht_profiler.c30
2 files changed, 25 insertions, 7 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index d4d640a82..51b651670 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -3471,7 +3471,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_break_op (0);
return GNUNET_OK;
}
- DEBUG("GET FOR DATA_SIZE = %lu\n",msize);
+
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# Bytes received from other peers"), (int64_t) msize,
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index a2bb1fca1..fbf20f028 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -785,6 +785,17 @@ start_profiling()
}
}
+static int
+hashmap_iterate_remove(void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct GNUNET_HashCode *remove_key = key;
+ GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value));
+ return GNUNET_YES;
+}
+
+
static unsigned int tries;
/**
@@ -814,8 +825,7 @@ successor_stats_cont (void *cls,
start_val =
(struct GNUNET_HashCode *) GNUNET_CONTAINER_multihashmap_get(successor_peer_hashmap,
start_key);
- val = GNUNET_new(struct GNUNET_HashCode);
- key = GNUNET_new(struct GNUNET_HashCode);
+
val = start_val;
for (count = 0; count < num_peers; count++)
{
@@ -835,12 +845,20 @@ successor_stats_cont (void *cls,
break;
}
/* If a peer has its own identity as its successor. */
- if (0 == memcmp(&key, &val, sizeof (struct GNUNET_HashCode)))
+ if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode)))
{
break;
}
}
+ GNUNET_assert(GNUNET_SYSERR !=
+ GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap,
+ hashmap_iterate_remove,
+ NULL));
+
+ successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
+ GNUNET_NO);
+
if ((start_val == val) && (count == num_peers))
{
DEBUG("CIRCLE COMPLETED after %u tries", tries);
@@ -849,6 +867,7 @@ successor_stats_cont (void *cls,
//are fill atleast O(log N) and then start with the experiments.
if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task)
start_profiling();
+
return;
}
else
@@ -859,7 +878,6 @@ successor_stats_cont (void *cls,
"Maximum tries %u exceeded while checking successor TOTAL TRIES %u"
" cirle formation. Exiting\n",
max_searches,tries);
- //FIXME: FREE HASHMAP
if (GNUNET_SCHEDULER_NO_TASK != successor_stats_task)
{
successor_stats_task = GNUNET_SCHEDULER_NO_TASK;
@@ -952,6 +970,8 @@ collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
GNUNET_assert(NULL != testbed_handles);
+ successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
+ GNUNET_NO);
successor_stats_op =
GNUNET_TESTBED_get_statistics (num_peers, testbed_handles,
"dht", NULL,
@@ -1014,8 +1034,6 @@ service_started (void *cls,
struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context);
collect_stat_cls->service_connect_ctx = cls;
collect_stat_cls->op = op;
- successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
- GNUNET_NO);
successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay,
&collect_stats,
collect_stat_cls);