gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25975 - gnunet/src/testbed
Date: Fri, 1 Feb 2013 13:51:14 +0100

Author: harsha
Date: 2013-02-01 13:51:14 +0100 (Fri, 01 Feb 2013)
New Revision: 25975

Modified:
   gnunet/src/testbed/gnunet-service-testbed_cache.c
   gnunet/src/testbed/gnunet-service-testbed_oc.c
Log:
- fixes

Modified: gnunet/src/testbed/gnunet-service-testbed_cache.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_cache.c   2013-02-01 12:49:17 UTC 
(rev 25974)
+++ gnunet/src/testbed/gnunet-service-testbed_cache.c   2013-02-01 12:51:14 UTC 
(rev 25975)
@@ -531,10 +531,11 @@
     GNUNET_break (0);
     return;
   }
-  //GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == entry->notify_task);
   if (0 == entry->demand)
     return;
-  if (GNUNET_NO == entry->cgh_qhead->notify_called)
+  if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task)
+    return;
+  if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
     entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
 }
 
@@ -588,8 +589,10 @@
   memcpy (entry->peer_identity, my_identity,
           sizeof (struct GNUNET_PeerIdentity));
   if (0 == entry->demand)
+    return;  
+  if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task)
     return;
-  if (GNUNET_NO == entry->cgh_qhead->notify_called)
+  if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
     entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
 }
 

Modified: gnunet/src/testbed/gnunet-service-testbed_oc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_oc.c      2013-02-01 12:49:17 UTC 
(rev 25974)
+++ gnunet/src/testbed/gnunet-service-testbed_oc.c      2013-02-01 12:51:14 UTC 
(rev 25975)
@@ -107,12 +107,12 @@
   /**
    * Transport handle of the first peer to get its HELLO
    */
-  struct GNUNET_TRANSPORT_Handle *p1th;
+  struct GNUNET_TRANSPORT_Handle *p1th_;
 
   /**
-   * The GetCacheHandle for the p1th transport handle
+   * The CacheGetHandle for the p1th transport handle
    */
-  struct GSTGetCacheHandle *gch_p1th;
+  struct GSTCacheGetHandle *cgh_p1th;
 
   /**
    * Core handles of the first peer; used to notify when second peer connects 
to it
@@ -418,9 +418,9 @@
     GNUNET_SCHEDULER_cancel (occ->tcc.task);
   if (NULL != occ->tcc.tch)
     GNUNET_TRANSPORT_try_connect_cancel (occ->tcc.tch);
-  if (NULL != occ->p1th)
+  if (NULL != occ->cgh_p1th)
   {
-    GNUNET_TRANSPORT_disconnect (occ->p1th);
+    GST_cache_get_handle_done (occ->cgh_p1th);
     occ->peer->reference_cnt--;
   }
   if (NULL != occ->tcc.cgh_th)
@@ -764,7 +764,8 @@
   GNUNET_assert (NULL == occ->emsg);
   GNUNET_assert (NULL != occ->hello);
   GNUNET_assert (NULL == occ->ghh);
-  GNUNET_assert (NULL == occ->p1th);
+  GNUNET_assert (NULL == occ->p1th_);
+  GNUNET_assert (NULL == occ->cgh_p1th);
   if (NULL == occ->peer2_controller)
   {
     GST_peer_list[occ->other_peer_id]->reference_cnt++;
@@ -835,9 +836,10 @@
   memcpy (occ->hello, hello, msize);
   GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
   occ->ghh = NULL;
-  GNUNET_TRANSPORT_disconnect (occ->p1th);
-  occ->p1th = NULL;
+  GST_cache_get_handle_done (occ->cgh_p1th);
   occ->peer->reference_cnt--;
+  occ->cgh_p1th = NULL;
+  occ->p1th_ = NULL;
   GNUNET_free_non_null (occ->emsg);
   occ->emsg = NULL;
   p2_transport_connect (occ);
@@ -850,6 +852,42 @@
  * @param cls the closure passed to GST_cache_get_handle_transport()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ignore_ peer identity which is ignored in this callback
+ */
+static void 
+p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, 
+                                     struct GNUNET_TRANSPORT_Handle *th,
+                                     const struct GNUNET_PeerIdentity *ignore_)
+{
+  struct OverlayConnectContext *occ = cls;
+
+  GNUNET_free_non_null (occ->emsg);
+  occ->emsg = NULL;
+  if (NULL == th)
+  {
+    GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s",
+                     occ->op_id, GNUNET_i2s (&occ->peer_identity));
+    GNUNET_SCHEDULER_cancel (occ->timeout_task);
+    occ->timeout_task =
+        GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
+    return;
+  }
+  GNUNET_assert (NULL == occ->p1th_);
+  GNUNET_assert (NULL != occ->cgh_p1th);
+  occ->p1th_ = th;
+  GNUNET_asprintf (&occ->emsg,
+                   "0x%llx: Timeout while acquiring HELLO of peer %4s",
+                   occ->op_id, GNUNET_i2s (&occ->peer_identity));
+  occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th_, &hello_update_cb, occ);
+}
+
+
+/**
+ * Callback from cache with needed handles set
+ *
+ * @param cls the closure passed to GST_cache_get_handle_transport()
+ * @param ch the handle to CORE. Can be NULL if it is not requested
+ * @param th the handle to TRANSPORT. Can be NULL if it is not requested
  * @param my_identity the identity of our peer
  */
 static void 
@@ -862,12 +900,15 @@
 
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task);
   GNUNET_free_non_null (occ->emsg);
-  (void) GNUNET_asprintf (&occ->emsg,
-                          "0x%llx: Failed to connect to CORE of peer with"
-                          "id: %u", occ->op_id, occ->peer_id);
   if ((NULL == ch) || (NULL == my_identity))
-    goto error_return;
-  GNUNET_free (occ->emsg);
+  {
+    (void) GNUNET_asprintf (&occ->emsg,
+                            "0x%llx: Failed to connect to CORE of peer with"
+                            "id: %u", occ->op_id, occ->peer_id);
+    GNUNET_SCHEDULER_cancel (occ->timeout_task);
+    occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, 
occ);
+    return;
+  }
   //occ->ch_ = ch;
   occ->emsg = NULL;
   if (GNUNET_YES == 
@@ -893,27 +934,17 @@
     p2_transport_connect (occ);
     return;
   }
-  occ->peer->reference_cnt++;
-  occ->p1th =
-      GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg,
-                                &occ->peer_identity, NULL, NULL, NULL, NULL);
-  if (NULL == occ->p1th)
-  {
-    GNUNET_asprintf (&occ->emsg,
-                     "0x%llx: Cannot connect to TRANSPORT of peer %4s",
-                     occ->op_id, GNUNET_i2s (&occ->peer_identity));
-    goto error_return;
-  }
   GNUNET_asprintf (&occ->emsg,
-                   "0x%llx: Timeout while acquiring HELLO of peer %4s",
+                   "0x%llx: Timeout while acquiring TRANSPORT of %s from 
cache",
                    occ->op_id, GNUNET_i2s (&occ->peer_identity));
-  occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ);
+  occ->peer->reference_cnt++;
+  occ->cgh_p1th = 
+      GST_cache_get_handle_transport (occ->peer_id,
+                                      occ->peer->details.local.cfg,
+                                      p1_transport_connect_cache_callback,
+                                      occ,
+                                      NULL, NULL, NULL);
   return;
-
-error_return:
-  GNUNET_SCHEDULER_cancel (occ->timeout_task);
-  occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
-  return;
 }
 
 




reply via email to

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