void *connect_notify_cb_cls);
+/**
+ * Get a CORE handle with the given configuration. If the handle is already
+ * cached before, it will be retured in the given callback; the peer_id is used
+ * to lookup in the cache. If the handle is not cached before, a new operation
+ * is started to open the CORE handle and will be given in the callback when it
+ * is available along with the peer identity
+ *
+ * @param peer_id the index of the peer
+ * @param cfg the configuration with which the transport handle has to be
+ * created if it was not present in the cache
+ * @param cb the callback to notify when the transport handle is available
+ * @param cb_cls the closure for the above callback
+ * @param target the peer identify of the peer whose connection to our CORE
+ * subsystem will be notified through the connect_notify_cb. Can be NULL
+ * @param connect_notify_cb the callback to call when the given target peer is
+ * connected. This callback will only be called once or never again (in
+ * case the target peer cannot be connected). Can be NULL
+ * @param connect_notify_cb_cls the closure for the above callback
+ * @return the handle which can be used cancel or mark that the handle is no
+ * longer being used
+ */
+struct GSTCacheGetHandle *
+GST_cache_get_handle_core (unsigned int peer_id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GST_cache_callback cb,
+ void *cb_cls,
+ const struct GNUNET_PeerIdentity *target,
+ GST_cache_peer_connect_notify connect_notify_cb,
+ void *connect_notify_cb_cls);
+
+
/**
* Mark the GetCacheHandle as being done if a handle has been provided already
* or as being cancelled if the callback for the handle hasn't been called.
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);
static struct GSTCacheGetHandle *
-search_suitable_gst (const struct CacheEntry *entry,
+search_suitable_cgh (const struct CacheEntry *entry,
const struct GSTCacheGetHandle *head)
{
const struct GSTCacheGetHandle *cgh;
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != entry->notify_task);
entry->notify_task = GNUNET_SCHEDULER_NO_TASK;
- cgh = search_suitable_gst (entry, entry->cgh_qhead);
+ cgh = search_suitable_cgh (entry, entry->cgh_qhead);
GNUNET_assert (NULL != cgh);
cgh2 = NULL;
if (NULL != cgh->next)
- cgh2 = search_suitable_gst (entry, cgh->next);
+ cgh2 = search_suitable_cgh (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);
const struct GNUNET_ATS_Information * atsi,
unsigned int atsi_count)
{
- peer_connect_notify_cb (cls, peer, CGT_TRANSPORT_HANDLE);
+ peer_connect_notify_cb (cls, peer, CGT_CORE_HANDLE);
}
GNUNET_assert (NULL != entry);
LOG_DEBUG ("Opening a CORE connection to peer %u\n", entry->peer_id);
- entry->core_handle = GNUNET_CORE_connect (entry->cfg,
- entry,
- &core_startup_cb,
- &core_peer_connect_cb,
- NULL, /* disconnect cb */
- NULL, /* inbound notify */
- GNUNET_NO,
- NULL, /* outbound notify */
- GNUNET_NO,
- no_handlers);
+ /* void?: We also get the handle when the connection to CORE is successful */
+ (void) GNUNET_CORE_connect (entry->cfg,
+ entry,
+ &core_startup_cb,
+ &core_peer_connect_cb,
+ NULL, /* disconnect cb */
+ NULL, /* inbound notify */
+ GNUNET_NO,
+ NULL, /* outbound notify */
+ GNUNET_NO,
+ no_handlers);
if (NULL == entry->core_handle)
{
GNUNET_break (0);
return;
GNUNET_CORE_disconnect (entry->core_handle);
entry->core_handle = NULL;
+ GNUNET_free_non_null (entry->peer_identity);
+ entry->peer_identity = NULL;
}
/**
- * Get a transport handle with the given configuration. If the handle is already
- * cached before, it will be retured in the given callback; the peer_id is used to lookup in the
- * cache. If not a new operation is started to open the transport handle and
- * will be given in the callback when it is available.
+ * Get a CORE handle with the given configuration. If the handle is already
+ * cached before, it will be retured in the given callback; the peer_id is used
+ * to lookup in the cache. If the handle is not cached before, a new operation
+ * is started to open the CORE handle and will be given in the callback when it
+ * is available along with the peer identity
*
* @param peer_id the index of the peer
* @param cfg the configuration with which the transport handle has to be
* created if it was not present in the cache
* @param cb the callback to notify when the transport handle is available
* @param cb_cls the closure for the above callback
- * @param target the peer identify of the peer whose connection to our TRANSPORT
+ * @param target the peer identify of the peer whose connection to our CORE
* subsystem will be notified through the connect_notify_cb. Can be NULL
* @param connect_notify_cb the callback to call when the given target peer is
* connected. This callback will only be called once or never again (in