aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-05 12:24:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-05 12:24:07 +0000
commitb8b60d5df0677de95d2d8960468d5c0390dc5884 (patch)
tree4ba036867649bf252456cc40bc15bb02d34468fb
parent6deed95ec80ae2676066cc931e59b8b00dc56908 (diff)
downloadgnunet-b8b60d5df0677de95d2d8960468d5c0390dc5884.tar.gz
gnunet-b8b60d5df0677de95d2d8960468d5c0390dc5884.zip
ensure neighbour map is existing
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index caed3e4d4..031950151 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -226,7 +226,6 @@ static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb;
226 */ 226 */
227static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb; 227static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb;
228 228
229
230/** 229/**
231 * Lookup a neighbour entry in the neighbours hash map. 230 * Lookup a neighbour entry in the neighbours hash map.
232 * 231 *
@@ -477,6 +476,8 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
477void 476void
478GST_neighbours_stop () 477GST_neighbours_stop ()
479{ 478{
479 GNUNET_assert (neighbours != NULL);
480
480 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, 481 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours,
481 NULL); 482 NULL);
482 GNUNET_CONTAINER_multihashmap_destroy (neighbours); 483 GNUNET_CONTAINER_multihashmap_destroy (neighbours);
@@ -510,6 +511,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
510 struct NeighbourMapEntry *n; 511 struct NeighbourMapEntry *n;
511 struct GNUNET_MessageHeader connect_msg; 512 struct GNUNET_MessageHeader connect_msg;
512 513
514 GNUNET_assert (neighbours != NULL);
515
513 n = lookup_neighbour (peer); 516 n = lookup_neighbour (peer);
514 if (NULL == n) 517 if (NULL == n)
515 { 518 {
@@ -593,6 +596,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
593{ 596{
594 struct NeighbourMapEntry *n; 597 struct NeighbourMapEntry *n;
595 598
599 GNUNET_assert (neighbours != NULL);
600
596 GNUNET_assert (0 != 601 GNUNET_assert (0 !=
597 memcmp (target, &GST_my_identity, 602 memcmp (target, &GST_my_identity,
598 sizeof (struct GNUNET_PeerIdentity))); 603 sizeof (struct GNUNET_PeerIdentity)));
@@ -633,6 +638,8 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
633{ 638{
634 struct NeighbourMapEntry *n; 639 struct NeighbourMapEntry *n;
635 640
641 GNUNET_assert (neighbours != NULL);
642
636 n = lookup_neighbour (target); 643 n = lookup_neighbour (target);
637 if ((NULL == n) || (n->is_connected != GNUNET_YES)) 644 if ((NULL == n) || (n->is_connected != GNUNET_YES))
638 return GNUNET_NO; /* not connected */ 645 return GNUNET_NO; /* not connected */
@@ -652,6 +659,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
652{ 659{
653 struct NeighbourMapEntry *n; 660 struct NeighbourMapEntry *n;
654 661
662 GNUNET_assert (neighbours != NULL);
663
655 n = lookup_neighbour (peer); 664 n = lookup_neighbour (peer);
656 if (NULL == n) 665 if (NULL == n)
657 return; 666 return;
@@ -695,6 +704,8 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
695 struct NeighbourMapEntry *n; 704 struct NeighbourMapEntry *n;
696 struct MessageQueue *mq; 705 struct MessageQueue *mq;
697 706
707 GNUNET_assert (neighbours != NULL);
708
698 n = lookup_neighbour (target); 709 n = lookup_neighbour (target);
699 if ((n == NULL) || (GNUNET_YES != n->is_connected)) 710 if ((n == NULL) || (GNUNET_YES != n->is_connected))
700 { 711 {
@@ -754,6 +765,8 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
754 struct NeighbourMapEntry *n; 765 struct NeighbourMapEntry *n;
755 struct GNUNET_TIME_Relative ret; 766 struct GNUNET_TIME_Relative ret;
756 767
768 GNUNET_assert (neighbours != NULL);
769
757 n = lookup_neighbour (sender); 770 n = lookup_neighbour (sender);
758 if (n == NULL) 771 if (n == NULL)
759 { 772 {
@@ -821,6 +834,8 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
821{ 834{
822 struct NeighbourMapEntry *n; 835 struct NeighbourMapEntry *n;
823 836
837 GNUNET_assert (neighbours != NULL);
838
824 n = lookup_neighbour (neighbour); 839 n = lookup_neighbour (neighbour);
825 if (NULL == n) 840 if (NULL == n)
826 { 841 {
@@ -849,6 +864,8 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
849{ 864{
850 struct NeighbourMapEntry *n; 865 struct NeighbourMapEntry *n;
851 866
867 GNUNET_assert (neighbours != NULL);
868
852 n = lookup_neighbour (neighbour); 869 n = lookup_neighbour (neighbour);
853 if (n == NULL) 870 if (n == NULL)
854 { 871 {
@@ -922,6 +939,8 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
922{ 939{
923 struct IteratorContext ic; 940 struct IteratorContext ic;
924 941
942 GNUNET_assert (neighbours != NULL);
943
925 ic.cb = cb; 944 ic.cb = cb;
926 ic.cb_cls = cb_cls; 945 ic.cb_cls = cb_cls;
927 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &neighbours_iterate, &ic); 946 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &neighbours_iterate, &ic);
@@ -940,6 +959,8 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
940 struct GNUNET_TRANSPORT_PluginFunctions *papi; 959 struct GNUNET_TRANSPORT_PluginFunctions *papi;
941 struct GNUNET_MessageHeader disconnect_msg; 960 struct GNUNET_MessageHeader disconnect_msg;
942 961
962 GNUNET_assert (neighbours != NULL);
963
943 n = lookup_neighbour (target); 964 n = lookup_neighbour (target);
944 if (NULL == n) 965 if (NULL == n)
945 return; /* not active */ 966 return; /* not active */