aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/gnunet-service-mesh_peer.c')
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 75decd3bb..ece4470e2 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -79,7 +79,7 @@ struct MeshPeer
79 * Transmission queue to core DLL head 79 * Transmission queue to core DLL head
80 */ 80 */
81 struct MeshPeerQueue *queue_head; 81 struct MeshPeerQueue *queue_head;
82 82
83 /** 83 /**
84 * Transmission queue to core DLL tail 84 * Transmission queue to core DLL tail
85 */ 85 */
@@ -121,8 +121,8 @@ static unsigned long long max_peers;
121 * #GNUNET_NO if not. 121 * #GNUNET_NO if not.
122 */ 122 */
123static int 123static int
124shutdown_tunnel (void *cls, 124shutdown_tunnel (void *cls,
125 const struct GNUNET_PeerIdentity *key, 125 const struct GNUNET_PeerIdentity *key,
126 void *value) 126 void *value)
127{ 127{
128 struct MeshPeer *p = value; 128 struct MeshPeer *p = value;
@@ -148,10 +148,10 @@ peer_destroy (struct MeshPeer *peer)
148 struct GNUNET_PeerIdentity id; 148 struct GNUNET_PeerIdentity id;
149 struct MeshPeerPath *p; 149 struct MeshPeerPath *p;
150 struct MeshPeerPath *nextp; 150 struct MeshPeerPath *nextp;
151 151
152 GNUNET_PEER_resolve (peer->id, &id); 152 GNUNET_PEER_resolve (peer->id, &id);
153 GNUNET_PEER_change_rc (peer->id, -1); 153 GNUNET_PEER_change_rc (peer->id, -1);
154 154
155 if (GNUNET_YES != 155 if (GNUNET_YES !=
156 GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) 156 GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer))
157 { 157 {
@@ -188,10 +188,10 @@ static int
188peer_is_used (struct MeshPeer *peer) 188peer_is_used (struct MeshPeer *peer)
189{ 189{
190 struct MeshPeerPath *p; 190 struct MeshPeerPath *p;
191 191
192 if (NULL != peer->tunnel) 192 if (NULL != peer->tunnel)
193 return GNUNET_YES; 193 return GNUNET_YES;
194 194
195 for (p = peer->path_head; NULL != p; p = p->next) 195 for (p = peer->path_head; NULL != p; p = p->next)
196 { 196 {
197 if (p->length < 3) 197 if (p->length < 3)
@@ -215,14 +215,14 @@ peer_get_oldest (void *cls,
215{ 215{
216 struct MeshPeer *p = value; 216 struct MeshPeer *p = value;
217 struct GNUNET_TIME_Absolute *abs = cls; 217 struct GNUNET_TIME_Absolute *abs = cls;
218 218
219 /* Don't count active peers */ 219 /* Don't count active peers */
220 if (GNUNET_YES == peer_is_used (p)) 220 if (GNUNET_YES == peer_is_used (p))
221 return GNUNET_YES; 221 return GNUNET_YES;
222 222
223 if (abs->abs_value_us < p->last_contact.abs_value_us) 223 if (abs->abs_value_us < p->last_contact.abs_value_us)
224 abs->abs_value_us = p->last_contact.abs_value_us; 224 abs->abs_value_us = p->last_contact.abs_value_us;
225 225
226 return GNUNET_YES; 226 return GNUNET_YES;
227} 227}
228 228
@@ -241,7 +241,7 @@ peer_timeout (void *cls,
241{ 241{
242 struct MeshPeer *p = value; 242 struct MeshPeer *p = value;
243 struct GNUNET_TIME_Absolute *abs = cls; 243 struct GNUNET_TIME_Absolute *abs = cls;
244 244
245 if (p->last_contact.abs_value_us == abs->abs_value_us && 245 if (p->last_contact.abs_value_us == abs->abs_value_us &&
246 GNUNET_NO == peer_is_used (p)) 246 GNUNET_NO == peer_is_used (p))
247 { 247 {
@@ -259,9 +259,9 @@ static void
259peer_delete_oldest (void) 259peer_delete_oldest (void)
260{ 260{
261 struct GNUNET_TIME_Absolute abs; 261 struct GNUNET_TIME_Absolute abs;
262 262
263 abs = GNUNET_TIME_UNIT_FOREVER_ABS; 263 abs = GNUNET_TIME_UNIT_FOREVER_ABS;
264 264
265 GNUNET_CONTAINER_multipeermap_iterate (peers, 265 GNUNET_CONTAINER_multipeermap_iterate (peers,
266 &peer_get_oldest, 266 &peer_get_oldest,
267 &abs); 267 &abs);
@@ -283,7 +283,7 @@ static struct MeshPeer *
283peer_get (const struct GNUNET_PeerIdentity *peer_id) 283peer_get (const struct GNUNET_PeerIdentity *peer_id)
284{ 284{
285 struct MeshPeer *peer; 285 struct MeshPeer *peer;
286 286
287 peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id); 287 peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id);
288 if (NULL == peer) 288 if (NULL == peer)
289 { 289 {
@@ -297,7 +297,7 @@ peer_get (const struct GNUNET_PeerIdentity *peer_id)
297 peer->id = GNUNET_PEER_intern (peer_id); 297 peer->id = GNUNET_PEER_intern (peer_id);
298 } 298 }
299 peer->last_contact = GNUNET_TIME_absolute_get(); 299 peer->last_contact = GNUNET_TIME_absolute_get();
300 300
301 return peer; 301 return peer;
302} 302}
303 303
@@ -333,13 +333,13 @@ peer_get_path_cost (const struct MeshPeer *peer,
333 unsigned int overlap; 333 unsigned int overlap;
334 unsigned int i; 334 unsigned int i;
335 unsigned int j; 335 unsigned int j;
336 336
337 if (NULL == path) 337 if (NULL == path)
338 return 0; 338 return 0;
339 339
340 overlap = 0; 340 overlap = 0;
341 GNUNET_assert (NULL != peer->tunnel); 341 GNUNET_assert (NULL != peer->tunnel);
342 342
343 for (i = 0; i < path->length; i++) 343 for (i = 0; i < path->length; i++)
344 { 344 {
345 for (c = peer->tunnel->connection_head; NULL != c; c = c->next) 345 for (c = peer->tunnel->connection_head; NULL != c; c = c->next)
@@ -373,7 +373,7 @@ peer_get_best_path (const struct MeshPeer *peer)
373 struct MeshConnection *c; 373 struct MeshConnection *c;
374 unsigned int best_cost; 374 unsigned int best_cost;
375 unsigned int cost; 375 unsigned int cost;
376 376
377 best_cost = UINT_MAX; 377 best_cost = UINT_MAX;
378 best_p = NULL; 378 best_p = NULL;
379 for (p = peer->path_head; NULL != p; p = p->next) 379 for (p = peer->path_head; NULL != p; p = p->next)
@@ -383,7 +383,7 @@ peer_get_best_path (const struct MeshPeer *peer)
383 break; 383 break;
384 if (NULL != c) 384 if (NULL != c)
385 continue; /* If path is in use in a connection, skip it. */ 385 continue; /* If path is in use in a connection, skip it. */
386 386
387 if ((cost = peer_get_path_cost (peer, p)) < best_cost) 387 if ((cost = peer_get_path_cost (peer, p)) < best_cost)
388 { 388 {
389 best_cost = cost; 389 best_cost = cost;
@@ -410,7 +410,7 @@ peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path,
410 struct MeshPeerPath *aux; 410 struct MeshPeerPath *aux;
411 unsigned int l; 411 unsigned int l;
412 unsigned int l2; 412 unsigned int l2;
413 413
414 if ((NULL == peer_info) || (NULL == path)) 414 if ((NULL == peer_info) || (NULL == path))
415 { 415 {
416 GNUNET_break (0); 416 GNUNET_break (0);
@@ -444,17 +444,17 @@ peer_add_path (struct MeshPeer *peer_info, struct MeshPeerPath *path,
444 GNUNET_realloc (path->peers, path->length * sizeof (GNUNET_PEER_Id)); 444 GNUNET_realloc (path->peers, path->length * sizeof (GNUNET_PEER_Id));
445 } 445 }
446 } 446 }
447 447
448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", 448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n",
449 path->length, peer2s (peer_info)); 449 path->length, peer2s (peer_info));
450 450
451 l = path_get_length (path); 451 l = path_get_length (path);
452 if (0 == l) 452 if (0 == l)
453 { 453 {
454 path_destroy (path); 454 path_destroy (path);
455 return; 455 return;
456 } 456 }
457 457
458 GNUNET_assert (peer_info->id == path->peers[path->length - 1]); 458 GNUNET_assert (peer_info->id == path->peers[path->length - 1]);
459 for (aux = peer_info->path_head; aux != NULL; aux = aux->next) 459 for (aux = peer_info->path_head; aux != NULL; aux = aux->next)
460 { 460 {
@@ -569,7 +569,7 @@ GMP_connect (struct MeshPeer *peer)
569 { 569 {
570 /* This case can happen when the path includes a first hop that is 570 /* This case can happen when the path includes a first hop that is
571 * not yet known to be connected. 571 * not yet known to be connected.
572 * 572 *
573 * This happens quite often during testing when running mesh 573 * This happens quite often during testing when running mesh
574 * under valgrind: core connect notifications come very late and the 574 * under valgrind: core connect notifications come very late and the
575 * DHT result has already come and created a valid path. 575 * DHT result has already come and created a valid path.