[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14426 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14426 - gnunet/src/core |
Date: |
Wed, 16 Feb 2011 16:46:32 +0100 |
Author: nevans
Date: 2011-02-16 16:46:32 +0100 (Wed, 16 Feb 2011)
New Revision: 14426
Modified:
gnunet/src/core/core_api.c
Log:
handle out of sync connect callback scenario
Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c 2011-02-16 15:24:34 UTC (rev 14425)
+++ gnunet/src/core/core_api.c 2011-02-16 15:46:32 UTC (rev 14426)
@@ -921,7 +921,7 @@
&cnm->peer,
sizeof (struct GNUNET_PeerIdentity)))
{
- /* disconnect from self!? */
+ /* connect to self!? */
GNUNET_break (0);
return;
}
@@ -1716,7 +1716,9 @@
* @param peer who should we connect to
* @param cont function to call once the request has been completed (or timed
out)
* @param cont_cls closure for cont
- * @return NULL on error (cont will not be called), otherwise handle for
cancellation
+ *
+ * @return NULL on error or already connected,
+ * otherwise handle for cancellation
*/
struct GNUNET_CORE_PeerRequestHandle *
GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h,
@@ -1728,10 +1730,25 @@
struct GNUNET_CORE_PeerRequestHandle *ret;
struct ControlMessage *cm;
struct ConnectMessage *msg;
+ struct PeerRecord *pr;
+ static struct GNUNET_TRANSPORT_ATS_Information distance[2];
if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers,
&peer->hashPubKey))
- GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "core_api", "Received CONNECT
requests for already connected peer!\n");
+ {
+ pr = GNUNET_CONTAINER_multihashmap_get(h->peers, &peer->hashPubKey);
+ GNUNET_assert(pr != NULL);
+ distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+ distance[0].value = htonl (1);
+ distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+ distance[1].value = htonl (0);
+
+ if (NULL != h->connects)
+ h->connects (h->cls,
+ &pr->peer,
+ &distance[0]);
+ return NULL;
+ }
cm = GNUNET_malloc (sizeof (struct ControlMessage) +
sizeof (struct ConnectMessage));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14426 - gnunet/src/core,
gnunet <=