gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r26867 - gnunet/src/testbed
Date: Sat, 13 Apr 2013 18:04:24 +0200

Author: harsha
Date: 2013-04-13 18:04:24 +0200 (Sat, 13 Apr 2013)
New Revision: 26867

Modified:
   gnunet/src/testbed/gnunet-service-testbed_links.c
Log:
- fix

Modified: gnunet/src/testbed/gnunet-service-testbed_links.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_links.c   2013-04-13 11:39:30 UTC 
(rev 26866)
+++ gnunet/src/testbed/gnunet-service-testbed_links.c   2013-04-13 16:04:24 UTC 
(rev 26867)
@@ -180,13 +180,15 @@
   GNUNET_SCHEDULER_TaskIdentifier notify_task;
 
   unsigned int reference_cnt;
+
+  unsigned int inactive;
+
   
   /**
    * The id of the host this controller is running on
    */
   uint32_t host_id;
   
-  int8_t inactive;
 };
 
 static struct Neighbour **neighbour_list;
@@ -753,7 +755,13 @@
   if (NULL == n->controller)
     return;
   if (GNUNET_SCHEDULER_NO_TASK != n->notify_task)
-    return;
+    return;  
+  if (1 == n->inactive)
+  {
+    GNUNET_assert (0 == n->reference_cnt);
+    GNUNET_TESTBED_operation_activate_ (n->conn_op);
+    n->inactive = 0;
+  }
   n->notify_task = 
       GNUNET_SCHEDULER_add_now (&neighbour_connect_notify_task, n->nl_head);
 }
@@ -771,11 +779,6 @@
   GNUNET_assert (NULL != n->controller);
   GNUNET_CONTAINER_DLL_remove (n->nl_head, n->nl_tail, h);  
   trigger_notifications (n);
-  if ((0 == n->reference_cnt) && (1 == n->inactive))
-  {
-    GNUNET_TESTBED_operation_activate_ (n->conn_op);
-    n->inactive = 0;
-  }
   n->reference_cnt++;
   h->cb (h->cb_cls, n->controller);
   GNUNET_free (h);
@@ -804,10 +807,14 @@
    GNUNET_assert (0 == n->reference_cnt);
    GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == n->notify_task);
    GNUNET_assert (NULL == n->nl_head);
-   LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
-   GNUNET_TESTBED_controller_disconnect (n->controller);
-   n->controller = NULL;
+   if (NULL != n->controller)
+   {
+     LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
+     GNUNET_TESTBED_controller_disconnect (n->controller);
+     n->controller = NULL;
+   }
    n->conn_op = NULL;
+   n->inactive = 0;
 }
 
 struct NeighbourConnectNotification *
@@ -842,15 +849,28 @@
 GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h)
 {
   struct Neighbour *n;
+  int cleanup_task;
   
+  cleanup_task = (h == n->nl_head) ? GNUNET_YES : GNUNET_NO;
   n = h->n;
-  if ((h == n->nl_head) && (GNUNET_SCHEDULER_NO_TASK != n->notify_task))
+  GNUNET_CONTAINER_DLL_remove (n->nl_head, n->nl_tail, h);
+  GNUNET_free (h);
+  if (GNUNET_NO == cleanup_task)
+    return;
+  if (GNUNET_SCHEDULER_NO_TASK == n->notify_task)
+    return;
+  GNUNET_SCHEDULER_cancel (n->notify_task);
+  n->notify_task = GNUNET_SCHEDULER_NO_TASK;
+  if (NULL == n->nl_head)
   {
-    GNUNET_SCHEDULER_cancel (n->notify_task);
-    n->notify_task = GNUNET_SCHEDULER_NO_TASK;
+    if ( (0 == n->reference_cnt) && (0 == n->inactive) )
+    {
+      n->inactive = 1;
+      GNUNET_TESTBED_operation_inactivate_ (n->conn_op);
+    }
+    return;
   }
-  GNUNET_CONTAINER_DLL_remove (n->nl_head, n->nl_tail, h);
-  GNUNET_free (h);
+  trigger_notifications (n);
 }
 
 void
@@ -861,8 +881,8 @@
   n->reference_cnt--;
   if (0 == n->reference_cnt)
   {
+    n->inactive = 1;
     GNUNET_TESTBED_operation_inactivate_ (n->conn_op);
-    n->inactive = 1;
   }
 }
 




reply via email to

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