diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-17 17:18:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-17 17:18:53 +0100 |
commit | f9b01d9c8eeac932db6357426f8a70bf525a4e07 (patch) | |
tree | f3023b6cfe959a38ed5d9ab131fc8e1c62d136ea /src/cadet/gnunet-service-cadet_peer.c | |
parent | 100e16ba31dac7138413bda3389d30b3575a8b8e (diff) | |
download | gnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.tar.gz gnunet-f9b01d9c8eeac932db6357426f8a70bf525a4e07.zip |
use new shortmap to simplify CADET logic a bit
Diffstat (limited to 'src/cadet/gnunet-service-cadet_peer.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index b2ad1124c..a3defb87e 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -165,7 +165,7 @@ struct CadetPeer | |||
165 | /** | 165 | /** |
166 | * Connections that go through this peer; indexed by tid. | 166 | * Connections that go through this peer; indexed by tid. |
167 | */ | 167 | */ |
168 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 168 | struct GNUNET_CONTAINER_MultiShortmap *connections; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Handle for core transmissions. | 171 | * Handle for core transmissions. |
@@ -268,7 +268,7 @@ static int in_shutdown; | |||
268 | */ | 268 | */ |
269 | static int | 269 | static int |
270 | notify_broken (void *cls, | 270 | notify_broken (void *cls, |
271 | const struct GNUNET_HashCode *key, | 271 | const struct GNUNET_ShortHashCode *key, |
272 | void *value) | 272 | void *value) |
273 | { | 273 | { |
274 | struct CadetPeer *peer = cls; | 274 | struct CadetPeer *peer = cls; |
@@ -373,7 +373,8 @@ core_connect_handler (void *cls, | |||
373 | 373 | ||
374 | /* Create the connections hashmap */ | 374 | /* Create the connections hashmap */ |
375 | GNUNET_assert (NULL == neighbor->connections); | 375 | GNUNET_assert (NULL == neighbor->connections); |
376 | neighbor->connections = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); | 376 | neighbor->connections = GNUNET_CONTAINER_multishortmap_create (16, |
377 | GNUNET_YES); | ||
377 | GNUNET_STATISTICS_update (stats, | 378 | GNUNET_STATISTICS_update (stats, |
378 | "# peers", | 379 | "# peers", |
379 | 1, | 380 | 1, |
@@ -425,11 +426,11 @@ core_disconnect_handler (void *cls, | |||
425 | direct_path = pop_direct_path (p); | 426 | direct_path = pop_direct_path (p); |
426 | if (NULL != p->connections) | 427 | if (NULL != p->connections) |
427 | { | 428 | { |
428 | GNUNET_CONTAINER_multihashmap_iterate (p->connections, | 429 | GNUNET_CONTAINER_multishortmap_iterate (p->connections, |
429 | ¬ify_broken, | 430 | ¬ify_broken, |
430 | p); | 431 | p); |
431 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); | 432 | GNUNET_CONTAINER_multishortmap_destroy (p->connections); |
432 | p->connections = NULL; | 433 | p->connections = NULL; |
433 | } | 434 | } |
434 | GNUNET_STATISTICS_update (stats, | 435 | GNUNET_STATISTICS_update (stats, |
435 | "# peers", | 436 | "# peers", |
@@ -800,8 +801,8 @@ peer_destroy (struct CadetPeer *peer) | |||
800 | GCT_destroy_empty (peer->tunnel); | 801 | GCT_destroy_empty (peer->tunnel); |
801 | if (NULL != peer->connections) | 802 | if (NULL != peer->connections) |
802 | { | 803 | { |
803 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 804 | GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
804 | GNUNET_CONTAINER_multihashmap_destroy (peer->connections); | 805 | GNUNET_CONTAINER_multishortmap_destroy (peer->connections); |
805 | peer->connections = NULL; | 806 | peer->connections = NULL; |
806 | } | 807 | } |
807 | if (NULL != peer->hello_offer) | 808 | if (NULL != peer->hello_offer) |
@@ -1574,14 +1575,14 @@ GCP_add_connection (struct CadetPeer *peer, | |||
1574 | GCP_2s (peer)); | 1575 | GCP_2s (peer)); |
1575 | GNUNET_assert (NULL != peer->connections); | 1576 | GNUNET_assert (NULL != peer->connections); |
1576 | GNUNET_assert (GNUNET_OK == | 1577 | GNUNET_assert (GNUNET_OK == |
1577 | GNUNET_CONTAINER_multihashmap_put (peer->connections, | 1578 | GNUNET_CONTAINER_multishortmap_put (peer->connections, |
1578 | GCC_get_h (c), | 1579 | &GCC_get_id (c)->connection_of_tunnel, |
1579 | c, | 1580 | c, |
1580 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1581 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1581 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1582 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1582 | "Peer %s has now %u connections.\n", | 1583 | "Peer %s has now %u connections.\n", |
1583 | GCP_2s (peer), | 1584 | GCP_2s (peer), |
1584 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1585 | GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
1585 | } | 1586 | } |
1586 | 1587 | ||
1587 | 1588 | ||
@@ -1792,13 +1793,13 @@ void | |||
1792 | GCP_check_connection (const struct CadetPeer *peer, | 1793 | GCP_check_connection (const struct CadetPeer *peer, |
1793 | const struct CadetConnection *c) | 1794 | const struct CadetConnection *c) |
1794 | { | 1795 | { |
1795 | GNUNET_assert (NULL != peer); | 1796 | GNUNET_assert (NULL != peer); |
1796 | GNUNET_assert (NULL != peer->connections); | 1797 | GNUNET_assert (NULL != peer->connections); |
1797 | return; | 1798 | return; // ???? |
1798 | GNUNET_assert (GNUNET_YES == | 1799 | GNUNET_assert (GNUNET_YES == |
1799 | GNUNET_CONTAINER_multihashmap_contains_value (peer->connections, | 1800 | GNUNET_CONTAINER_multishortmap_contains_value (peer->connections, |
1800 | GCC_get_h (c), | 1801 | &GCC_get_id (c)->connection_of_tunnel, |
1801 | c)); | 1802 | c)); |
1802 | } | 1803 | } |
1803 | 1804 | ||
1804 | 1805 | ||
@@ -1822,13 +1823,13 @@ GCP_remove_connection (struct CadetPeer *peer, | |||
1822 | (NULL == peer->connections) ) | 1823 | (NULL == peer->connections) ) |
1823 | return; | 1824 | return; |
1824 | GNUNET_assert (GNUNET_YES == | 1825 | GNUNET_assert (GNUNET_YES == |
1825 | GNUNET_CONTAINER_multihashmap_remove (peer->connections, | 1826 | GNUNET_CONTAINER_multishortmap_remove (peer->connections, |
1826 | GCC_get_h (c), | 1827 | &GCC_get_id (c)->connection_of_tunnel, |
1827 | c)); | 1828 | c)); |
1828 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1829 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1829 | "Peer %s remains with %u connections.\n", | 1830 | "Peer %s remains with %u connections.\n", |
1830 | GCP_2s (peer), | 1831 | GCP_2s (peer), |
1831 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1832 | GNUNET_CONTAINER_multishortmap_size (peer->connections)); |
1832 | } | 1833 | } |
1833 | 1834 | ||
1834 | 1835 | ||