[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24424 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24424 - gnunet/src/testbed |
Date: |
Fri, 19 Oct 2012 15:47:58 +0200 |
Author: harsha
Date: 2012-10-19 15:47:57 +0200 (Fri, 19 Oct 2012)
New Revision: 24424
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/test_testbed_api_topology.c
gnunet/src/testbed/testbed_api_topology.c
Log:
counting references in overlay connect context
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-10-19 12:56:14 UTC (rev
24423)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-10-19 13:47:57 UTC (rev
24424)
@@ -2169,6 +2169,33 @@
/**
+ * Function to destroy a peer
+ *
+ * @param the peer structure to destroy
+ */
+static void
+destroy_peer (struct Peer *peer)
+{
+ GNUNET_break (0 == peer->reference_cnt);
+ if (GNUNET_YES == peer->is_remote)
+ {
+ peer_list_remove (peer);
+ GNUNET_free (peer);
+ return;
+ }
+ if (GNUNET_YES == peer->details.local.is_running)
+ {
+ GNUNET_TESTING_peer_stop (peer->details.local.peer);
+ peer->details.local.is_running = GNUNET_NO;
+ }
+ GNUNET_TESTING_peer_destroy (peer->details.local.peer);
+ GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
+ peer_list_remove (peer);
+ GNUNET_free (peer);
+}
+
+
+/**
* Callback to be called when forwarded peer destroy operation is successfull.
We
* have to relay the reply msg back to the client
*
@@ -2187,7 +2214,9 @@
{
remote_peer = fopc->cls;
GNUNET_assert (NULL != remote_peer);
- peer_list_remove (remote_peer);
+ remote_peer->destroy_flag = GNUNET_YES;
+ if (0 == remote_peer->reference_cnt)
+ destroy_peer (remote_peer);
}
dup_msg = GNUNET_copy_message (msg);
queue_message (fopc->client, dup_msg);
@@ -2389,15 +2418,12 @@
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if (GNUNET_YES == peer->details.local.is_running)
- {
- GNUNET_TESTING_peer_stop (peer->details.local.peer);
- peer->details.local.is_running = GNUNET_NO;
- }
- GNUNET_TESTING_peer_destroy (peer->details.local.peer);
- GNUNET_CONFIGURATION_destroy (peer->details.local.cfg);
- peer_list_remove (peer);
- GNUNET_free (peer);
+ peer->destroy_flag = GNUNET_YES;
+ if (0 == peer->reference_cnt)
+ destroy_peer (peer);
+ else
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Delaying peer destroy as peer is currently in use\n");
send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id));
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -2625,13 +2651,28 @@
if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task)
GNUNET_SCHEDULER_cancel (occ->timeout_task);
if (NULL != occ->ch)
+ {
GNUNET_CORE_disconnect (occ->ch);
+ occ->peer->reference_cnt--;
+ }
if (NULL != occ->ghh)
GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
if (NULL != occ->p1th)
+ {
GNUNET_TRANSPORT_disconnect (occ->p1th);
+ occ->peer->reference_cnt--;
+ }
if (NULL != occ->p2th)
+ {
GNUNET_TRANSPORT_disconnect (occ->p2th);
+ peer_list[occ->other_peer_id]->reference_cnt--;
+ if ((GNUNET_YES == peer_list[occ->other_peer_id]->destroy_flag)
+ && (0 == peer_list[occ->other_peer_id]->reference_cnt))
+ destroy_peer (peer_list[occ->other_peer_id]);
+ }
+ if ((GNUNET_YES == occ->peer->destroy_flag)
+ && (0 == occ->peer->reference_cnt))
+ destroy_peer (occ->peer);
GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ);
GNUNET_free (occ);
}
@@ -2726,7 +2767,10 @@
GNUNET_free_non_null (occ->emsg);
occ->emsg = NULL;
if (NULL != occ->p2th)
+ {
GNUNET_TRANSPORT_disconnect (occ->p2th);
+ peer_list[occ->other_peer_id]->reference_cnt--;
+ }
occ->p2th = NULL;
LOG_DEBUG ("Peers connected - Sending overlay connect success\n");
msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
@@ -2847,9 +2891,11 @@
occ->ghh = NULL;
GNUNET_TRANSPORT_disconnect (occ->p1th);
occ->p1th = NULL;
+ occ->peer->reference_cnt--;
GNUNET_free_non_null (occ->emsg);
if (NULL == occ->peer2_controller)
- {
+ {
+ peer_list[occ->other_peer_id]->reference_cnt++;
occ->p2th =
GNUNET_TRANSPORT_connect
(peer_list[occ->other_peer_id]->details.local.cfg,
&occ->other_peer_identity, NULL, NULL, NULL,
@@ -2894,6 +2940,7 @@
occ->emsg = NULL;
memcpy (&occ->peer_identity, my_identity,
sizeof (struct GNUNET_PeerIdentity));
+ occ->peer->reference_cnt++;
occ->p1th =
GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg,
&occ->peer_identity, NULL, NULL, NULL, NULL);
@@ -2941,6 +2988,7 @@
sizeof (struct GNUNET_PeerIdentity));
GNUNET_free_non_null (occ->emsg);
occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE");
+ occ->peer->reference_cnt++;
occ->ch =
GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb,
&overlay_connect_notify, NULL, NULL, GNUNET_NO,
NULL,
@@ -3091,12 +3139,16 @@
if ((NULL != route_to_peer2_host)
|| (peer2_host_id == master_context->host_id))
{
+ /* Peer 2 either below us OR with us */
route_to_peer1_host =
find_dest_route (peer_list[p1]->details.remote.remote_host_id);
+ /* Because we get this message only if we know where peer 1 is */
GNUNET_assert (NULL != route_to_peer1_host);
if ((peer2_host_id == master_context->host_id)
|| (route_to_peer2_host->dest != route_to_peer1_host->dest))
{
+ /* Peer2 is either with us OR peer1 and peer2 can be reached through
+ different gateways */
struct GNUNET_HashCode hash;
struct RegisteredHostContext *rhc;
int skip_focc;
@@ -3136,7 +3188,7 @@
}
else {
/* rhc is now set to the existing one from the hash map by
- reghost_match_iterator */
+ reghost_match_iterator() */
/* if queue is empty then ignore creating focc and proceed with
normal forwarding */
if (NULL == rhc->focc_dll_head)
@@ -3254,6 +3306,7 @@
&occ->other_peer_identity);
/* Connect to the core of 1st peer and wait for the 2nd peer to connect */
occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE");
+ occ->peer->reference_cnt++;
occ->ch =
GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb,
&overlay_connect_notify, NULL, NULL, GNUNET_NO,
NULL,
Modified: gnunet/src/testbed/test_testbed_api_topology.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_topology.c 2012-10-19 12:56:14 UTC
(rev 24423)
+++ gnunet/src/testbed/test_testbed_api_topology.c 2012-10-19 13:47:57 UTC
(rev 24424)
@@ -138,8 +138,10 @@
GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
NUM_PEERS);
GNUNET_assert (NULL != op);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS,
120),
+ shutdown_task = GNUNET_SCHEDULER_add_delayed (//GNUNET_TIME_relative_multiply
+ //(GNUNET_TIME_UNIT_SECONDS,
+ //120),
+ GNUNET_TIME_UNIT_FOREVER_REL,
do_shutdown, NULL);
}
Modified: gnunet/src/testbed/testbed_api_topology.c
===================================================================
--- gnunet/src/testbed/testbed_api_topology.c 2012-10-19 12:56:14 UTC (rev
24423)
+++ gnunet/src/testbed/testbed_api_topology.c 2012-10-19 13:47:57 UTC (rev
24424)
@@ -94,7 +94,7 @@
/**
* The size of the link array
*/
- unsigned int link_array_size;
+ unsigned int link_array_size;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24424 - gnunet/src/testbed,
gnunet <=