gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26371 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r26371 - gnunet/src/testbed
Date: Fri, 8 Mar 2013 18:06:49 +0100

Author: harsha
Date: 2013-03-08 18:06:49 +0100 (Fri, 08 Mar 2013)
New Revision: 26371

Modified:
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api_peers.c
   gnunet/src/testbed/testbed_api_peers.h
Log:
- cleanup peers after shutdown operation

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2013-03-08 16:37:39 UTC (rev 26370)
+++ gnunet/src/testbed/testbed_api.c    2013-03-08 17:06:49 UTC (rev 26371)
@@ -258,6 +258,7 @@
     struct GNUNET_TESTBED_Peer *peer;
 
     peer = opc->data;
+    GNUNET_TESTBED_peer_deregister_ (peer);
     GNUNET_free (peer);
     opc->data = NULL;
     //PEERDESTROYDATA
@@ -270,6 +271,7 @@
     data = opc->data;
     GNUNET_free (data);         /* FIXME: Decide whether we call data->op_cb */
     opc->data = NULL;
+    GNUNET_TESTBED_cleanup_peers_ ();
   }
     break;
   default:
@@ -330,6 +332,7 @@
   peer = data->peer;
   GNUNET_assert (peer->unique_id == ntohl (msg->peer_id));
   peer->state = PS_CREATED;
+  GNUNET_TESTBED_peer_register_ (peer);
   cb = data->cb;
   cls = data->cls;
   GNUNET_free (opc->data);

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2013-03-08 16:37:39 UTC (rev 
26370)
+++ gnunet/src/testbed/testbed_api_peers.c      2013-03-08 17:06:49 UTC (rev 
26371)
@@ -33,7 +33,60 @@
 #include "testbed_api_hosts.h"
 #include "testbed_api_operations.h"
 
+
 /**
+ * Peer list DLL head
+ */
+static struct GNUNET_TESTBED_Peer *peer_list_head;
+
+/**
+ * Peer list DLL tail
+ */
+static struct GNUNET_TESTBED_Peer *peer_list_tail;
+
+
+/**
+ * Adds a peer to the peer list
+ *
+ * @param peer the peer to add to the peer list
+ */
+void
+GNUNET_TESTBED_peer_register_ (struct GNUNET_TESTBED_Peer *peer)
+{
+  GNUNET_CONTAINER_DLL_insert_tail (peer_list_head, peer_list_tail, peer);
+}
+
+
+/**
+ * Removes a peer from the peer list
+ *
+ * @param peer the peer to remove
+ */
+void
+GNUNET_TESTBED_peer_deregister_ (struct GNUNET_TESTBED_Peer *peer)
+{
+  GNUNET_CONTAINER_DLL_remove (peer_list_head, peer_list_tail, peer);
+}
+
+
+/**
+ * Frees all peers
+ */
+void
+GNUNET_TESTBED_cleanup_peers_ (void)
+{
+  struct GNUNET_TESTBED_Peer *peer;
+
+  while (NULL != (peer = peer_list_head))
+  {
+    GNUNET_TESTBED_peer_deregister_ (peer);
+    GNUNET_free (peer);
+  }
+}
+
+
+
+/**
  * Function to call to start a peer_create type operation once all
  * queues the operation is part of declare that the
  * operation can be activated.

Modified: gnunet/src/testbed/testbed_api_peers.h
===================================================================
--- gnunet/src/testbed/testbed_api_peers.h      2013-03-08 16:37:39 UTC (rev 
26370)
+++ gnunet/src/testbed/testbed_api_peers.h      2013-03-08 17:06:49 UTC (rev 
26371)
@@ -66,6 +66,16 @@
 struct GNUNET_TESTBED_Peer
 {
   /**
+   * peer list DLL
+   */
+  struct GNUNET_TESTBED_Peer *next;
+
+  /**
+   * peer list DLL
+   */
+  struct GNUNET_TESTBED_Peer *prev;
+
+  /**
    * Our controller context (not necessarily the controller
    * that is responsible for starting/running the peer!).
    */
@@ -248,5 +258,30 @@
 GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
                                             uint64_t operation_id);
 
+
+/**
+ * Adds a peer to the peer list
+ *
+ * @param peer the peer to add to the peer list
+ */
+void
+GNUNET_TESTBED_peer_register_ (struct GNUNET_TESTBED_Peer *peer);
+
+
+/**
+ * Removes a peer from the peer list
+ *
+ * @param peer the peer to remove
+ */
+void
+GNUNET_TESTBED_peer_deregister_ (struct GNUNET_TESTBED_Peer *peer);
+
+
+/**
+ * Frees all peers
+ */
+void
+GNUNET_TESTBED_cleanup_peers_ (void);
+
 #endif
 /* end of testbed_api_peers.h */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]