aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorharsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96>2013-02-01 12:51:14 +0000
committerharsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96>2013-02-01 12:51:14 +0000
commit9a703fe14abda778edd693889d3846912d1f20d5 (patch)
tree8f33504ddb23e10ba7fbf8d6a83766e467e81686 /src
parenteff5cc9f24ec800469223d42a76463ead01736dc (diff)
- fixes
git-svn-id: https://gnunet.org/svn/gnunet@25975 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c9
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c93
2 files changed, 68 insertions, 34 deletions
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index f91e8c9d91..c75ae7dc45 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -531,10 +531,11 @@ opstart_get_handle_transport (void *cls)
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 @@ core_startup_cb (void *cls,
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);
}
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index b7650e932c..43841b461d 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -107,12 +107,12 @@ struct OverlayConnectContext
/**
* 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 @@ cleanup_occ (struct OverlayConnectContext *occ)
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 @@ p2_transport_connect (struct OverlayConnectContext *occ)
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 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
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 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
* @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 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
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,26 +934,16 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
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);
- return;
-
-error_return:
- GNUNET_SCHEDULER_cancel (occ->timeout_task);
- occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, 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;
}