[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35884 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35884 - gnunet/src/cadet |
Date: |
Mon, 8 Jun 2015 21:04:25 +0200 |
Author: grothoff
Date: 2015-06-08 21:04:24 +0200 (Mon, 08 Jun 2015)
New Revision: 35884
Modified:
gnunet/src/cadet/gnunet-service-cadet_connection.c
gnunet/src/cadet/gnunet-service-cadet_peer.c
gnunet/src/cadet/gnunet-service-cadet_tunnel.c
Log:
-assertion also does not hold, messy code
Modified: gnunet/src/cadet/gnunet-service-cadet_connection.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.c 2015-06-08 18:26:42 UTC
(rev 35883)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.c 2015-06-08 19:04:24 UTC
(rev 35884)
@@ -22,12 +22,9 @@
* @brief GNUnet CADET service connection handling
* @author Bartlomiej Polot
*/
-
#include "platform.h"
#include "gnunet_util_lib.h"
-
#include "gnunet_statistics_service.h"
-
#include "cadet_path.h"
#include "cadet_protocol.h"
#include "cadet.h"
@@ -101,7 +98,7 @@
/**
* Task to poll the peer in case of a lost ACK causes stall.
*/
- struct GNUNET_SCHEDULER_Task * poll_task;
+ struct GNUNET_SCHEDULER_Task *poll_task;
/**
* How frequently to poll for ACKs.
@@ -177,11 +174,6 @@
struct GNUNET_CADET_Hash id;
/**
- * State of the connection.
- */
- enum CadetConnectionState state;
-
- /**
* Path being used for the tunnel. At the origin of the connection
* it's a pointer to the destination's path pool, otherwise just a copy.
*/
@@ -188,21 +180,16 @@
struct CadetPeerPath *path;
/**
- * Position of the local peer in the path.
- */
- unsigned int own_pos;
-
- /**
* Task to keep the used paths alive at the owner,
* time tunnel out on all the other peers.
*/
- struct GNUNET_SCHEDULER_Task * fwd_maintenance_task;
+ struct GNUNET_SCHEDULER_Task *fwd_maintenance_task;
/**
* Task to keep the used paths alive at the destination,
* time tunnel out on all the other peers.
*/
- struct GNUNET_SCHEDULER_Task * bck_maintenance_task;
+ struct GNUNET_SCHEDULER_Task *bck_maintenance_task;
/**
* Queue handle for maintainance traffic. One handle for FWD and BCK since
@@ -211,11 +198,16 @@
struct CadetPeerQueue *maintenance_q;
/**
- * Counter to do exponential backoff when creating a connection (max 64).
+ * State of the connection.
*/
- unsigned short create_retry;
+ enum CadetConnectionState state;
/**
+ * Position of the local peer in the path.
+ */
+ unsigned int own_pos;
+
+ /**
* Pending message count.
*/
unsigned int pending_messages;
@@ -224,8 +216,14 @@
* Destroy flag: if true, destroy on last message.
*/
int destroy;
+
+ /**
+ * Counter to do exponential backoff when creating a connection (max 64).
+ */
+ unsigned short create_retry;
};
+
/**
* Handle for messages queued but not yet sent.
*/
@@ -237,19 +235,19 @@
struct CadetPeerQueue *q;
/**
- * Was this a forced message? (Do not account for it)
+ * Continuation to call once sent.
*/
- int forced;
+ GCC_sent cont;
/**
- * Continuation to call once sent.
+ * Closure for @e cont.
*/
- GCC_sent cont;
+ void *cont_cls;
/**
- * Closure for @c cont.
+ * Was this a forced message? (Do not account for it)
*/
- void *cont_cls;
+ int forced;
};
/******************************************************************************/
Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c 2015-06-08 18:26:42 UTC
(rev 35883)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c 2015-06-08 19:04:24 UTC
(rev 35884)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013, 2015 Christian Grothoff (and other contributing
authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -17,19 +17,18 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
-
+/**
+ * @file cadet/gnunet-service-cadet_peer.c
+ * @brief GNUnet CADET service connection handling
+ * @author Bartlomiej Polot
+ */
#include "platform.h"
#include "gnunet_util_lib.h"
-
#include "gnunet_signatures.h"
-
#include "gnunet_transport_service.h"
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"
-
#include "cadet_protocol.h"
-
#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet_dht.h"
#include "gnunet-service-cadet_connection.h"
@@ -385,6 +384,7 @@
/***************************** CORE CALLBACKS
*********************************/
/******************************************************************************/
+
/**
* Method called whenever a given peer connects.
*
@@ -392,41 +392,48 @@
* @param peer peer identity this notification is about
*/
static void
-core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+core_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct CadetPeer *mp;
struct CadetPeerPath *path;
char own_id[16];
- strncpy (own_id, GNUNET_i2s (&my_full_id), 15);
+ GNUNET_snprintf (own_id,
+ sizeof (own_id),
+ "%s",
+ GNUNET_i2s (&my_full_id));
mp = GCP_get (peer);
if (myid == mp->id)
{
- LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s (self)\n", own_id);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "CONNECTED %s (self)\n",
+ own_id);
path = path_new (1);
}
else
{
- LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s <= %s\n",
- own_id, GNUNET_i2s (peer));
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "CONNECTED %s <= %s\n",
+ own_id,
+ GNUNET_i2s (peer));
path = path_new (2);
path->peers[1] = mp->id;
GNUNET_PEER_change_rc (mp->id, 1);
- GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO);
}
path->peers[0] = myid;
GNUNET_PEER_change_rc (myid, 1);
GCP_add_path (mp, path, GNUNET_YES);
-
+ GNUNET_STATISTICS_update (stats,
+ "# peers",
+ 1,
+ GNUNET_NO);
+ GNUNET_assert (NULL == mp->connections);
mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES);
- if (NULL != GCP_get_tunnel (mp) &&
- 0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer))
- {
+ if ( (NULL != GCP_get_tunnel (mp)) &&
+ (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) )
GCP_connect (mp);
- }
-
- return;
}
@@ -467,15 +474,16 @@
GNUNET_CONTAINER_multihashmap_destroy (p->connections);
p->connections = NULL;
if (NULL != p->core_transmit)
- {
- GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit);
- p->core_transmit = NULL;
- p->tmt_time.abs_value_us = 0;
- }
- GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO);
-
+ {
+ GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit);
+ p->core_transmit = NULL;
+ p->tmt_time.abs_value_us = 0;
+ }
+ GNUNET_STATISTICS_update (stats,
+ "# peers",
+ -1,
+ GNUNET_NO);
path_destroy (direct_path);
- return;
}
@@ -534,7 +542,6 @@
GNUNET_assert (0);
}
GML_start ();
- return;
}
@@ -717,9 +724,8 @@
* Check if peer is searching for a path (either active or delayed search).
*
* @param peer Peer to check
- *
- * @return GNUNET_YES if there is a search active.
- * GNUNET_NO otherwise.
+ * @return #GNUNET_YES if there is a search active.
+ * #GNUNET_NO otherwise.
*/
static int
is_searching (const struct CadetPeer *peer)
@@ -753,8 +759,7 @@
* Destroy the peer_info and free any allocated resources linked to it
*
* @param peer The peer_info to destroy.
- *
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
*/
static int
peer_destroy (struct CadetPeer *peer)
@@ -797,7 +802,6 @@
* Returns if peer is used (has a tunnel or is neighbor).
*
* @param peer Peer to check.
- *
* @return #GNUNET_YES if peer is in use.
*/
static int
@@ -895,7 +899,6 @@
* considering the tunnel properties.
*
* @param peer The destination peer.
- *
* @return Best current known path towards the peer, if any.
*/
static struct CadetPeerPath *
@@ -932,7 +935,6 @@
* - For payload traffic, check the connection flow control.
*
* @param q Queue element to inspect.
- *
* @return #GNUNET_YES if it is sendable, #GNUNET_NO otherwise.
*/
static int
@@ -1013,7 +1015,6 @@
LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n");
GCP_connect (peer);
}
- return;
}
Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c 2015-06-08 18:26:42 UTC
(rev 35883)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c 2015-06-08 19:04:24 UTC
(rev 35884)
@@ -2694,7 +2694,6 @@
}
-
/**
* The peer's ephemeral key has changed: update the symmetrical keys.
*
@@ -2788,7 +2787,8 @@
* @param msg Key eXchange Pong message.
*/
static void
-handle_pong (struct CadetTunnel *t, const struct GNUNET_CADET_KX_Pong *msg)
+handle_pong (struct CadetTunnel *t,
+ const struct GNUNET_CADET_KX_Pong *msg)
{
uint32_t challenge;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35884 - gnunet/src/cadet,
gnunet <=