aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet-new_peer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-17 17:18:53 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-17 17:18:53 +0100
commitf9b01d9c8eeac932db6357426f8a70bf525a4e07 (patch)
treef3023b6cfe959a38ed5d9ab131fc8e1c62d136ea /src/cadet/gnunet-service-cadet-new_peer.c
parent100e16ba31dac7138413bda3389d30b3575a8b8e (diff)
downloadgnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.tar.gz
gnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.zip
use new shortmap to simplify CADET logic a bit
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_peer.c')
-rw-r--r--src/cadet/gnunet-service-cadet-new_peer.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_peer.c b/src/cadet/gnunet-service-cadet-new_peer.c
index 5c3e6cf17..55a03a206 100644
--- a/src/cadet/gnunet-service-cadet-new_peer.c
+++ b/src/cadet/gnunet-service-cadet-new_peer.c
@@ -155,7 +155,7 @@ struct CadetPeer
155 /** 155 /**
156 * Connections that go through this peer; indexed by tid. 156 * Connections that go through this peer; indexed by tid.
157 */ 157 */
158 struct GNUNET_CONTAINER_MultiHashMap *connections; 158 struct GNUNET_CONTAINER_MultiShortmap *connections;
159 159
160 /** 160 /**
161 * Handle for core transmissions. 161 * Handle for core transmissions.
@@ -227,7 +227,7 @@ destroy_peer (void *cls)
227 GNUNET_assert (NULL == cp->t); 227 GNUNET_assert (NULL == cp->t);
228 GNUNET_assert (NULL == cp->core_mq); 228 GNUNET_assert (NULL == cp->core_mq);
229 GNUNET_assert (0 == cp->path_dll_length); 229 GNUNET_assert (0 == cp->path_dll_length);
230 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections)); 230 GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections));
231 GNUNET_assert (GNUNET_YES == 231 GNUNET_assert (GNUNET_YES ==
232 GNUNET_CONTAINER_multipeermap_remove (peers, 232 GNUNET_CONTAINER_multipeermap_remove (peers,
233 &cp->pid, 233 &cp->pid,
@@ -252,7 +252,7 @@ destroy_peer (void *cls)
252 GNUNET_ATS_connectivity_suggest_cancel (cp->connectivity_suggestion); 252 GNUNET_ATS_connectivity_suggest_cancel (cp->connectivity_suggestion);
253 cp->connectivity_suggestion = NULL; 253 cp->connectivity_suggestion = NULL;
254 } 254 }
255 GNUNET_CONTAINER_multihashmap_destroy (cp->connections); 255 GNUNET_CONTAINER_multishortmap_destroy (cp->connections);
256 GNUNET_CONTAINER_heap_destroy (cp->path_heap); 256 GNUNET_CONTAINER_heap_destroy (cp->path_heap);
257 GNUNET_free_non_null (cp->hello); 257 GNUNET_free_non_null (cp->hello);
258 /* Peer should not be freed if paths exist; if there are no paths, 258 /* Peer should not be freed if paths exist; if there are no paths,
@@ -385,7 +385,7 @@ consider_peer_destroy (struct CadetPeer *cp)
385 return; /* still relevant! */ 385 return; /* still relevant! */
386 if (NULL != cp->core_mq) 386 if (NULL != cp->core_mq)
387 return; /* still relevant! */ 387 return; /* still relevant! */
388 if (0 != GNUNET_CONTAINER_multihashmap_size (cp->connections)) 388 if (0 != GNUNET_CONTAINER_multishortmap_size (cp->connections))
389 return; /* still relevant! */ 389 return; /* still relevant! */
390 if (0 < GNUNET_CONTAINER_heap_get_size (cp->path_heap)) 390 if (0 < GNUNET_CONTAINER_heap_get_size (cp->path_heap))
391 { 391 {
@@ -563,10 +563,10 @@ GCP_add_connection (struct CadetPeer *cp,
563 struct CadetConnection *cc) 563 struct CadetConnection *cc)
564{ 564{
565 GNUNET_assert (GNUNET_OK == 565 GNUNET_assert (GNUNET_OK ==
566 GNUNET_CONTAINER_multihashmap_put (cp->connections, 566 GNUNET_CONTAINER_multishortmap_put (cp->connections,
567 GCC_get_h (cc), 567 &GCC_get_id (cc)->connection_of_tunnel,
568 cc, 568 cc,
569 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 569 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
570} 570}
571 571
572 572
@@ -581,9 +581,9 @@ GCP_remove_connection (struct CadetPeer *cp,
581 struct CadetConnection *cc) 581 struct CadetConnection *cc)
582{ 582{
583 GNUNET_assert (GNUNET_YES == 583 GNUNET_assert (GNUNET_YES ==
584 GNUNET_CONTAINER_multihashmap_remove (cp->connections, 584 GNUNET_CONTAINER_multishortmap_remove (cp->connections,
585 GCC_get_h (cc), 585 &GCC_get_id (cc)->connection_of_tunnel,
586 cc)); 586 cc));
587} 587}
588 588
589 589
@@ -603,7 +603,7 @@ consider_peer_activate (struct CadetPeer *cp)
603 GNUNET_SCHEDULER_cancel (cp->destroy_task); 603 GNUNET_SCHEDULER_cancel (cp->destroy_task);
604 cp->destroy_task = NULL; 604 cp->destroy_task = NULL;
605 } 605 }
606 if ( (0 == GNUNET_CONTAINER_multihashmap_size (cp->connections)) && 606 if ( (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections)) &&
607 (NULL == cp->t) ) 607 (NULL == cp->t) )
608 { 608 {
609 /* We're just on a path or directly connected; don't bother too much */ 609 /* We're just on a path or directly connected; don't bother too much */
@@ -673,8 +673,8 @@ GCP_get (const struct GNUNET_PeerIdentity *peer_id,
673 return NULL; 673 return NULL;
674 cp = GNUNET_new (struct CadetPeer); 674 cp = GNUNET_new (struct CadetPeer);
675 cp->pid = *peer_id; 675 cp->pid = *peer_id;
676 cp->connections = GNUNET_CONTAINER_multihashmap_create (32, 676 cp->connections = GNUNET_CONTAINER_multishortmap_create (32,
677 GNUNET_YES); 677 GNUNET_YES);
678 cp->path_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 678 cp->path_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
679 GNUNET_assert (GNUNET_YES == 679 GNUNET_assert (GNUNET_YES ==
680 GNUNET_CONTAINER_multipeermap_put (peers, 680 GNUNET_CONTAINER_multipeermap_put (peers,