gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24964 - gnunet/src/testbed
Date: Wed, 14 Nov 2012 16:52:09 +0100

Author: harsha
Date: 2012-11-14 16:52:09 +0100 (Wed, 14 Nov 2012)
New Revision: 24964

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
Log:
- try connect as task in rocc

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-11-14 15:38:37 UTC (rev 
24963)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-11-14 15:52:09 UTC (rev 
24964)
@@ -660,11 +660,6 @@
   struct RequestOverlayConnectContext *prev;
 
   /**
-   * The transport handle of peer B
-   */
-  struct GNUNET_TRANSPORT_Handle *th;
-
-  /**
    * The peer handle of peer B
    */
   struct Peer *peer;
@@ -680,9 +675,9 @@
   struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
 
   /**
-   * The handle for transport try connect
+   * The transport try connect context
    */
-  struct GNUNET_TRANSPORT_TryConnectHandle *tch;
+  struct TryConnectContext tcc;
 
   /**
    * The peer identity of peer A
@@ -3556,11 +3551,13 @@
     GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id);
   if (GNUNET_SCHEDULER_NO_TASK != rocc->timeout_rocc_task_id)
     GNUNET_SCHEDULER_cancel (rocc->timeout_rocc_task_id);
-  if (NULL != rocc->tch)
-    GNUNET_TRANSPORT_try_connect_cancel (rocc->tch);
   if (NULL != rocc->ohh)
     GNUNET_TRANSPORT_offer_hello_cancel (rocc->ohh);
-  GNUNET_TRANSPORT_disconnect (rocc->th);
+  if (NULL != rocc->tcc.tch)
+    GNUNET_TRANSPORT_try_connect_cancel (rocc->tcc.tch);
+  if (GNUNET_SCHEDULER_NO_TASK != rocc->tcc.task)
+    GNUNET_SCHEDULER_cancel (rocc->tcc.task);
+  GNUNET_TRANSPORT_disconnect (rocc->tcc.th);
   rocc->peer->reference_cnt--;
   if ((GNUNET_YES == rocc->peer->destroy_flag)
       && (0 == rocc->peer->reference_cnt))
@@ -3612,24 +3609,6 @@
 
 
 /**
- * Callback to be called with result of the try connect request.
- *
- * @param cls the overlay connect context
- * @param result GNUNET_OK if message was transmitted to transport service
- *               GNUNET_SYSERR if message was not transmitted to transport 
service
- */
-static void 
-rocc_try_connect_cb (void *cls, const int result)
-{
-  struct RequestOverlayConnectContext *rocc = cls;
-  
-  rocc->tch = NULL;
-  rocc->tch = GNUNET_TRANSPORT_try_connect (rocc->th, &rocc->a_id,
-                                            &rocc_try_connect_cb, rocc);
-}
-
-
-/**
  * Task to offer the HELLO message to the peer and ask it to connect to the 
peer
  * whose identity is in RequestOverlayConnectContext
  *
@@ -3656,19 +3635,16 @@
   rocc->ohh = NULL;
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->attempt_connect_task_id);
   if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason)
-    goto schedule_attempt_connect;
+  {
+    GNUNET_break (0);
+    rocc->attempt_connect_task_id =
+        GNUNET_SCHEDULER_add_now (&attempt_connect_task,
+                                  rocc);
+    return;
+  }
   if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason)
     return;
-  rocc->tch = GNUNET_TRANSPORT_try_connect (rocc->th, &rocc->a_id,
-                                            &rocc_try_connect_cb, rocc);
-  if (NULL != rocc->tch)
-    return;
-   GNUNET_break (0);
-   
- schedule_attempt_connect:
-   rocc->attempt_connect_task_id =
-       GNUNET_SCHEDULER_add_now (&attempt_connect_task,
-                                 rocc);
+  rocc->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &rocc->tcc);
 }
 
 
@@ -3685,7 +3661,7 @@
   struct RequestOverlayConnectContext *rocc = cls;
 
   rocc->attempt_connect_task_id = GNUNET_SCHEDULER_NO_TASK;
-  rocc->ohh = GNUNET_TRANSPORT_offer_hello (rocc->th, rocc->hello,
+  rocc->ohh = GNUNET_TRANSPORT_offer_hello (rocc->tcc.th, rocc->hello,
                                             rocc_hello_sent_cb, rocc);
   if (NULL == rocc->ohh)
     rocc->attempt_connect_task_id = 
@@ -3757,9 +3733,9 @@
   GNUNET_CONTAINER_DLL_insert_tail (roccq_head, roccq_tail, rocc);
   rocc->peer = peer;
   rocc->peer->reference_cnt++;
-  rocc->th = GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, 
rocc,
-                                       NULL, &transport_connect_notify, NULL);
-  if (NULL == rocc->th)
+  rocc->tcc.th = GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, 
NULL, rocc,
+                                           NULL, &transport_connect_notify, 
NULL);
+  if (NULL == rocc->tcc.th)
   {
     GNUNET_break (0);
     GNUNET_free (rocc);
@@ -3768,6 +3744,7 @@
   }
   memcpy (&rocc->a_id, &msg->peer_identity,
           sizeof (struct GNUNET_PeerIdentity));
+  rocc->tcc.pid = &rocc->a_id;
   rocc->hello = GNUNET_malloc (hsize);
   memcpy (rocc->hello, msg->hello, hsize);
   rocc->attempt_connect_task_id =




reply via email to

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