aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-03-05 18:29:25 +0100
committerJulius Bünger <buenger@mytum.de>2018-03-05 18:34:36 +0100
commite1534af8705146a702e69f836969b6e8a9e6d495 (patch)
treeabf0cdf90cd71ab5f055c47fcbdeaa601657eb2d /src/rps
parent6c10bf3ecacc9701c0f189200dc66dbef00ed46d (diff)
downloadgnunet-e1534af8705146a702e69f836969b6e8a9e6d495.tar.gz
gnunet-e1534af8705146a702e69f836969b6e8a9e6d495.zip
rps: fixes
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c23
-rw-r--r--src/rps/gnunet-service-rps_custommap.c5
2 files changed, 23 insertions, 5 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 0499eb0ab..12e5b1b3e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1072,6 +1072,7 @@ Peers_terminate ()
1072 "Iteration destroying peers was aborted.\n"); 1072 "Iteration destroying peers was aborted.\n");
1073 } 1073 }
1074 GNUNET_CONTAINER_multipeermap_destroy (peer_map); 1074 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
1075 peer_map = NULL;
1075 store_valid_peers (); 1076 store_valid_peers ();
1076 GNUNET_free (filename_valid_peers); 1077 GNUNET_free (filename_valid_peers);
1077 GNUNET_CONTAINER_multipeermap_destroy (valid_peers); 1078 GNUNET_CONTAINER_multipeermap_destroy (valid_peers);
@@ -1439,7 +1440,13 @@ Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer,
1439int 1440int
1440Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer) 1441Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer)
1441{ 1442{
1442 return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer); 1443 if (NULL != peer_map)
1444 {
1445 return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
1446 } else
1447 {
1448 return GNUNET_NO;
1449 }
1443} 1450}
1444 1451
1445 1452
@@ -1514,6 +1521,7 @@ Peers_handle_inbound_channel (void *cls,
1514 const struct GNUNET_PeerIdentity *initiator) 1521 const struct GNUNET_PeerIdentity *initiator)
1515{ 1522{
1516 struct PeerContext *peer_ctx; 1523 struct PeerContext *peer_ctx;
1524 struct GNUNET_PeerIdentity *ctx_peer;
1517 1525
1518 LOG (GNUNET_ERROR_TYPE_DEBUG, 1526 LOG (GNUNET_ERROR_TYPE_DEBUG,
1519 "New channel was established to us (Peer %s).\n", 1527 "New channel was established to us (Peer %s).\n",
@@ -1522,6 +1530,8 @@ Peers_handle_inbound_channel (void *cls,
1522 /* Make sure we 'know' about this peer */ 1530 /* Make sure we 'know' about this peer */
1523 peer_ctx = create_or_get_peer_ctx (initiator); 1531 peer_ctx = create_or_get_peer_ctx (initiator);
1524 set_peer_live (peer_ctx); 1532 set_peer_live (peer_ctx);
1533 ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity);
1534 *ctx_peer = *initiator;
1525 /* We only accept one incoming channel per peer */ 1535 /* We only accept one incoming channel per peer */
1526 if (GNUNET_YES == Peers_check_peer_send_intention (initiator)) 1536 if (GNUNET_YES == Peers_check_peer_send_intention (initiator))
1527 { 1537 {
@@ -1531,10 +1541,10 @@ Peers_handle_inbound_channel (void *cls,
1531 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); 1541 GNUNET_CADET_channel_destroy (peer_ctx->recv_channel);
1532 peer_ctx->recv_channel = channel; 1542 peer_ctx->recv_channel = channel;
1533 /* return the channel context */ 1543 /* return the channel context */
1534 return &peer_ctx->peer_id; 1544 return ctx_peer;
1535 } 1545 }
1536 peer_ctx->recv_channel = channel; 1546 peer_ctx->recv_channel = channel;
1537 return &peer_ctx->peer_id; 1547 return ctx_peer;
1538} 1548}
1539 1549
1540 1550
@@ -1629,6 +1639,7 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
1629 set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_CLEAN); 1639 set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_CLEAN);
1630 GNUNET_CADET_channel_destroy (peer_ctx->send_channel); 1640 GNUNET_CADET_channel_destroy (peer_ctx->send_channel);
1631 peer_ctx->send_channel = NULL; 1641 peer_ctx->send_channel = NULL;
1642 peer_ctx->mq = NULL;
1632 (void) Peers_check_connected (peer); 1643 (void) Peers_check_connected (peer);
1633 return GNUNET_YES; 1644 return GNUNET_YES;
1634 } 1645 }
@@ -2615,6 +2626,7 @@ cleanup_destroyed_channel (void *cls,
2615 to_file (file_name_view_log, 2626 to_file (file_name_view_log,
2616 "-%s\t(cleanup channel, ourself)", 2627 "-%s\t(cleanup channel, ourself)",
2617 GNUNET_i2s_full (peer)); 2628 GNUNET_i2s_full (peer));
2629 //GNUNET_free (peer);
2618 return; 2630 return;
2619 } 2631 }
2620 2632
@@ -2630,6 +2642,7 @@ cleanup_destroyed_channel (void *cls,
2630 { /* We are about to clean the sending channel. Clean the respective 2642 { /* We are about to clean the sending channel. Clean the respective
2631 * context */ 2643 * context */
2632 Peers_cleanup_destroyed_channel (cls, channel); 2644 Peers_cleanup_destroyed_channel (cls, channel);
2645 //GNUNET_free (peer);
2633 return; 2646 return;
2634 } 2647 }
2635 else 2648 else
@@ -2637,6 +2650,7 @@ cleanup_destroyed_channel (void *cls,
2637 * open. It probably went down. Remove it from our knowledge. */ 2650 * open. It probably went down. Remove it from our knowledge. */
2638 Peers_cleanup_destroyed_channel (cls, channel); 2651 Peers_cleanup_destroyed_channel (cls, channel);
2639 remove_peer (peer); 2652 remove_peer (peer);
2653 //GNUNET_free (peer);
2640 return; 2654 return;
2641 } 2655 }
2642 } 2656 }
@@ -2653,6 +2667,7 @@ cleanup_destroyed_channel (void *cls,
2653 { /* Other peer tried to establish a channel to us twice. We do not accept 2667 { /* Other peer tried to establish a channel to us twice. We do not accept
2654 * that. Clean the context. */ 2668 * that. Clean the context. */
2655 Peers_cleanup_destroyed_channel (cls, channel); 2669 Peers_cleanup_destroyed_channel (cls, channel);
2670 //GNUNET_free (peer);
2656 return; 2671 return;
2657 } 2672 }
2658 else 2673 else
@@ -2660,6 +2675,7 @@ cleanup_destroyed_channel (void *cls,
2660 * it. */ 2675 * it. */
2661 Peers_cleanup_destroyed_channel (cls, channel); 2676 Peers_cleanup_destroyed_channel (cls, channel);
2662 clean_peer (peer); 2677 clean_peer (peer);
2678 //GNUNET_free (peer);
2663 return; 2679 return;
2664 } 2680 }
2665 } 2681 }
@@ -2668,6 +2684,7 @@ cleanup_destroyed_channel (void *cls,
2668 LOG (GNUNET_ERROR_TYPE_WARNING, 2684 LOG (GNUNET_ERROR_TYPE_WARNING,
2669 "Destroyed channel is neither sending nor receiving channel\n"); 2685 "Destroyed channel is neither sending nor receiving channel\n");
2670 } 2686 }
2687 //GNUNET_free (peer);
2671} 2688}
2672 2689
2673/*********************************************************************** 2690/***********************************************************************
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 064192d08..aef081a00 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -128,7 +128,9 @@ CustomPeerMap_put (const struct CustomPeerMap *c_peer_map,
128 *index = CustomPeerMap_size (c_peer_map); 128 *index = CustomPeerMap_size (c_peer_map);
129 p = GNUNET_new (struct GNUNET_PeerIdentity); 129 p = GNUNET_new (struct GNUNET_PeerIdentity);
130 *p = *peer; 130 *p = *peer;
131 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map, peer, index, 131 GNUNET_assert (p != peer);
132 GNUNET_assert (0 == memcmp (p, peer, sizeof(struct GNUNET_PeerIdentity)));
133 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map, p, index,
132 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 134 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
133 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, p, 135 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, p,
134 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 136 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
@@ -218,7 +220,6 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
218 *last_index = *index; 220 *last_index = *index;
219 } 221 }
220 GNUNET_free (index); 222 GNUNET_free (index);
221 GNUNET_free (p);
222 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) == 223 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) ==
223 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map)); 224 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map));
224 return GNUNET_OK; 225 return GNUNET_OK;