[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25948 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25948 - gnunet/src/testbed |
Date: |
Wed, 30 Jan 2013 17:01:57 +0100 |
Author: harsha
Date: 2013-01-30 17:01:57 +0100 (Wed, 30 Jan 2013)
New Revision: 25948
Modified:
gnunet/src/testbed/gnunet-service-testbed.h
gnunet/src/testbed/gnunet-service-testbed_hc.c
gnunet/src/testbed/gnunet-service-testbed_oc.c
Log:
- unified notify callback for cached transport and core handles
Modified: gnunet/src/testbed/gnunet-service-testbed.h
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.h 2013-01-30 15:54:31 UTC (rev
25947)
+++ gnunet/src/testbed/gnunet-service-testbed.h 2013-01-30 16:01:57 UTC (rev
25948)
@@ -808,9 +808,12 @@
* @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 peer_id the identity of the peer. Will be NULL if ch is NULL. In
other
+ * cases, its value being NULL means that CORE connection has failed.
*/
typedef void (*GST_cache_callback) (void *cls, struct GNUNET_CORE_Handle *ch,
- struct GNUNET_TRANSPORT_Handle *th);
+ struct GNUNET_TRANSPORT_Handle *th,
+ const struct GNUNET_PeerIdentity *peer_id);
/**
Modified: gnunet/src/testbed/gnunet-service-testbed_hc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_hc.c 2013-01-30 15:54:31 UTC
(rev 25947)
+++ gnunet/src/testbed/gnunet-service-testbed_hc.c 2013-01-30 16:01:57 UTC
(rev 25948)
@@ -179,6 +179,13 @@
struct GNUNET_TESTBED_Operation *core_op;
/**
+ * The peer identity of this peer. Will be set upon opening a connection to
+ * the peers CORE service. Will be NULL until then and after the CORE
+ * connection is closed
+ */
+ struct GNUNET_PeerIdentity *peer_identity;
+
+ /**
* The configuration of the peer. Should be not NULL as long as the
core_handle
* or transport_handle are valid
*/
@@ -334,6 +341,8 @@
GNUNET_TESTBED_operation_done (entry->core_op);
entry->core_op = NULL;
}
+ GNUNET_free_non_null (entry->peer_identity);
+ entry->peer_identity = NULL;
if (NULL != entry->cfg)
{
GNUNET_CONFIGURATION_destroy (entry->cfg);
@@ -359,30 +368,54 @@
}
+static struct GSTCacheGetHandle *
+search_suitable_gst (const struct CacheEntry *entry,
+ const struct GSTCacheGetHandle *head)
+{
+ const struct GSTCacheGetHandle *cgh;
+
+ for (cgh=head; NULL != cgh; cgh=cgh->next)
+ {
+ if (GNUNET_YES == cgh->notify_called)
+ return NULL;
+ switch (cgh->type)
+ {
+ case CGT_TRANSPORT_HANDLE:
+ if (NULL == entry->transport_handle_)
+ continue;
+ break;
+ case CGT_CORE_HANDLE:
+ if (NULL == entry->core_handle)
+ continue;
+ break;
+ }
+ break;
+ }
+ return (struct GSTCacheGetHandle *) cgh;
+}
+
+
static void
call_cgh_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct CacheEntry *entry = cls;
struct GSTCacheGetHandle *cgh;
-
+ const struct GSTCacheGetHandle *cgh2;
+
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != entry->notify_task);
entry->notify_task = GNUNET_SCHEDULER_NO_TASK;
- cgh = entry->cgh_qhead;
- GNUNET_assert (GNUNET_NO == cgh->notify_called);
+ cgh = search_suitable_gst (entry, entry->cgh_qhead);
+ GNUNET_assert (NULL != cgh);
+ cgh2 = NULL;
+ if (NULL != cgh->next)
+ cgh2 = search_suitable_gst (entry, cgh->next);
GNUNET_CONTAINER_DLL_remove (entry->cgh_qhead, entry->cgh_qtail, cgh);
cgh->notify_called = GNUNET_YES;
GNUNET_CONTAINER_DLL_insert_tail (entry->cgh_qhead, entry->cgh_qtail, cgh);
- if (GNUNET_NO == entry->cgh_qhead->notify_called)
+ if (NULL != cgh2)
entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
- switch (cgh->type)
- {
- case CGT_TRANSPORT_HANDLE:
- cgh->cb (cgh->cb_cls, NULL, entry->transport_handle_);
- break;
- case CGT_CORE_HANDLE:
- cgh->cb (cgh->cb_cls, entry->core_handle, NULL);
- break;
- }
+ cgh->cb (cgh->cb_cls, entry->core_handle,
+ entry->transport_handle_, entry->peer_identity);
}
/**
@@ -498,6 +531,14 @@
{
struct CacheEntry *entry = cls;
+ if (NULL == peer)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ GNUNET_assert (NULL == entry->peer_identity);
+ entry->peer_identity = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (entry->peer_identity, peer, sizeof (struct GNUNET_PeerIdentity));
if (0 == entry->demand)
return;
if (GNUNET_NO == entry->cgh_qhead->notify_called)
Modified: gnunet/src/testbed/gnunet-service-testbed_oc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-01-30 15:54:31 UTC
(rev 25947)
+++ gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-01-30 16:01:57 UTC
(rev 25948)
@@ -728,10 +728,12 @@
* @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
p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
- struct GNUNET_TRANSPORT_Handle *th)
+ struct GNUNET_TRANSPORT_Handle *th,
+ const struct GNUNET_PeerIdentity *ignore_)
{
struct OverlayConnectContext *occ = cls;
@@ -1461,10 +1463,12 @@
* @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
rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
- struct GNUNET_TRANSPORT_Handle *th)
+ struct GNUNET_TRANSPORT_Handle *th,
+ const struct GNUNET_PeerIdentity *ignore_)
{
struct RemoteOverlayConnectCtx *rocc = cls;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25948 - gnunet/src/testbed,
gnunet <=