summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-18 13:53:16 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-18 13:53:16 +0000
commit288b020f05fd7c6f48a745f10f0867886bd0ca0a (patch)
treec3a799797fd5b9adfe93bc1701106c59e06b1a6a /src
parent3afa50d4dc9a7d0253c3bb602202822cabb26b74 (diff)
-track hello offer handle while it is active
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_dht.c12
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c31
2 files changed, 31 insertions, 12 deletions
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c
index 2b9fdb0a3..fadf45e13 100644
--- a/src/cadet/gnunet-service-cadet_dht.c
+++ b/src/cadet/gnunet-service-cadet_dht.c
@@ -154,9 +154,9 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path,
* @param exp when will this value expire
* @param key key of the result
* @param get_path path of the get request
- * @param get_path_length lenght of get_path
+ * @param get_path_length lenght of @a get_path
* @param put_path path of the put request
- * @param put_path_length length of the put_path
+ * @param put_path_length length of the @a put_path
* @param type type of the result
* @param size number of bytes in data
* @param data pointer to the result data
@@ -185,11 +185,15 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
}
s = path_2s (p);
- LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Got path from DHT: %s\n",
+ s);
GNUNET_free_non_null (s);
peer = GCP_get_short (p->peers[p->length - 1], GNUNET_YES);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GCP_2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Got HELLO for %s\n",
+ GCP_2s (peer));
h->callback (h->cls, p);
path_destroy (p);
hello = (struct GNUNET_HELLO_Message *) data;
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index dfeeebd3b..4d5c09260 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -189,6 +189,11 @@ struct CadetPeer
* Hello message.
*/
struct GNUNET_HELLO_Message* hello;
+
+ /**
+ * Handle to us offering the HELLO to the transport.
+ */
+ struct GNUNET_TRANSPORT_OfferHelloHandle *hello_offer;
};
@@ -742,7 +747,9 @@ peer_destroy (struct CadetPeer *peer)
while (NULL != p)
{
nextp = p->next;
- GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, p);
+ GNUNET_CONTAINER_DLL_remove (peer->path_head,
+ peer->path_tail,
+ p);
path_destroy (p);
p = nextp;
}
@@ -755,6 +762,11 @@ peer_destroy (struct CadetPeer *peer)
}
if (NULL != peer->core_transmit)
GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit);
+ if (NULL != peer->hello_offer)
+ {
+ GNUNET_TRANSPORT_offer_hello_cancel (peer->hello_offer);
+ peer->hello_offer = NULL;
+ }
GNUNET_free_non_null (peer->hello);
GNUNET_free (peer);
return GNUNET_OK;
@@ -1906,10 +1918,12 @@ GCP_get_short (const GNUNET_PEER_Id peer, int create)
* @param tc TaskContext.
*/
static void
-try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+try_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct CadetPeer *peer = cls;
+ peer->hello_offer = NULL;
if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
return;
@@ -1934,8 +1948,9 @@ GCP_connect (struct CadetPeer *peer)
int rerun_search;
GCC_check_connections ();
- LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GCP_2s (peer));
-
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "peer_connect towards %s\n",
+ GCP_2s (peer));
/* If we have a current hello, try to connect using it. */
GCP_try_connect (peer);
@@ -2539,10 +2554,10 @@ GCP_try_connect (struct CadetPeer *peer)
return;
mh = GNUNET_HELLO_get_header (hello);
- GNUNET_TRANSPORT_offer_hello (transport_handle,
- mh,
- &try_connect,
- peer);
+ peer->hello_offer = GNUNET_TRANSPORT_offer_hello (transport_handle,
+ mh,
+ &try_connect,
+ peer);
GCC_check_connections ();
}