gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22945 - gnunet/src/testbed
Date: Fri, 27 Jul 2012 15:54:13 +0200

Author: harsha
Date: 2012-07-27 15:54:13 +0200 (Fri, 27 Jul 2012)
New Revision: 22945

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
Log:
fixed LCF forwarding

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-07-27 13:07:19 UTC (rev 
22944)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-07-27 13:54:13 UTC (rev 
22945)
@@ -184,6 +184,11 @@
     DELEGATED_HOST_REGISTERED,
     
     /**
+     * The slave host has been registred at the forwarding controller
+     */
+    SLAVE_HOST_REGISTERED,
+
+    /**
      * The context has been finished (may have error)
      */
     FINISHED
@@ -235,8 +240,12 @@
    * The delegated host
    */
   uint32_t delegated_host_id;
-  
 
+  /**
+   * The slave host
+   */
+  uint32_t slave_host_id;
+
 };
 
 
@@ -654,19 +663,26 @@
   {
   case INIT:
     if (NULL != emsg)
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING, 
-           "Host registration failed with message: %s\n", emsg);
-      lcf->state = FINISHED;
-      lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
-      return;
-    }
+      goto registration_error;
     lcf->state = DELEGATED_HOST_REGISTERED;
     lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
     break;
+  case DELEGATED_HOST_REGISTERED:
+     if (NULL != emsg)
+      goto registration_error;
+     lcf->state = SLAVE_HOST_REGISTERED;
+     lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
+     break;
   default:
     GNUNET_assert (0);                 /* Shouldn't reach here */
   }  
+  return;
+
+ registration_error:
+  LOG (GNUNET_ERROR_TYPE_WARNING, 
+       "Host registration failed with message: %s\n", emsg);
+  lcf->state = FINISHED;
+  lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
 }
 
 
@@ -693,7 +709,7 @@
       lcf->rhandle =
        GNUNET_TESTBED_register_host (lcf->gateway->controller,
                                      host_list[lcf->delegated_host_id],
-                                     lcf_proc_cc, lcf);                        
                           
+                                     lcf_proc_cc, lcf);
     }
     else
     {
@@ -702,14 +718,32 @@
     }
     break;
   case DELEGATED_HOST_REGISTERED:
+    if (GNUNET_NO ==
+       GNUNET_TESTBED_is_host_registered_ (host_list[lcf->slave_host_id],
+                                           lcf->gateway->controller))
+    {
+      lcf->rhandle =
+       GNUNET_TESTBED_register_host (lcf->gateway->controller,
+                                     host_list[lcf->slave_host_id],
+                                     lcf_proc_cc, lcf);
+    }
+    else
+    {
+      lcf->state = SLAVE_HOST_REGISTERED;
+      lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
+    }
+    break;
+  case SLAVE_HOST_REGISTERED:
     GNUNET_TESTBED_controller_link_2 (lcf->gateway->controller,
                                       host_list[lcf->delegated_host_id],
-                                      host_list[lcf->gateway->host_id],
+                                      host_list[lcf->slave_host_id],
                                       lcf->sxcfg, lcf->sxcfg_size,
                                       lcf->scfg_size,
                                       lcf->is_subordinate);
     lcf->state = FINISHED;
-  case FINISHED:   
+    lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
+    break;
+  case FINISHED:
     lcfq = lcfq_head;
     GNUNET_assert (lcfq->lcf == lcf);
     GNUNET_free (lcf->sxcfg);
@@ -1137,6 +1171,10 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
+  lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue));
+  lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
+  lcfq->lcf->delegated_host_id = delegated_host_id;
+  lcfq->lcf->slave_host_id = slave_host_id;
   while (NULL != (route = route_list[slave_host_id]))
   {
     if (route->thru == master_context->host_id)
@@ -1146,9 +1184,6 @@
   GNUNET_assert (NULL != route); /* because we add routes carefully */
   GNUNET_assert (route->dest < slave_list_size);
   GNUNET_assert (NULL != slave_list[route->dest]);  
-  lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue));
-  lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
-  lcfq->lcf->delegated_host_id = delegated_host_id;
   lcfq->lcf->is_subordinate =
     (1 == msg->is_subordinate) ? GNUNET_YES : GNUNET_NO;
   lcfq->lcf->state = INIT;




reply via email to

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