diff options
-rw-r--r-- | src/rps/gnunet-service-rps.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 9be4036f8..1a6654003 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -690,6 +690,10 @@ hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | |||
690 | sampler_size_est_need - GNUNET_CONTAINER_multipeermap_size (view), | 690 | sampler_size_est_need - GNUNET_CONTAINER_multipeermap_size (view), |
691 | num_peers); i++) | 691 | num_peers); i++) |
692 | { | 692 | { |
693 | /* Make sure there is a context associated with the id in the peermap */ | ||
694 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, &ids[i])) | ||
695 | (void) create_peer_ctx (&ids[i]); | ||
696 | |||
693 | if (GNUNET_OK != GNUNET_CONTAINER_multipeermap_put (view, | 697 | if (GNUNET_OK != GNUNET_CONTAINER_multipeermap_put (view, |
694 | &ids[i], | 698 | &ids[i], |
695 | NULL, | 699 | NULL, |
@@ -1724,7 +1728,12 @@ handle_peer_pull_reply (void *cls, | |||
1724 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, | 1728 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, |
1725 | &peers[i])) | 1729 | &peers[i])) |
1726 | { | 1730 | { |
1727 | peer_ctx = get_peer_ctx (&peers[i]); | 1731 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, |
1732 | &peers[i])) | ||
1733 | peer_ctx = create_peer_ctx (&peers[i]); | ||
1734 | else | ||
1735 | peer_ctx = get_peer_ctx (&peers[i]); | ||
1736 | |||
1728 | if (GNUNET_YES == get_peer_flag (peer_ctx, VALID)) | 1737 | if (GNUNET_YES == get_peer_flag (peer_ctx, VALID)) |
1729 | { | 1738 | { |
1730 | if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])) | 1739 | if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])) |
@@ -1744,6 +1753,8 @@ handle_peer_pull_reply (void *cls, | |||
1744 | 1753 | ||
1745 | unset_peer_flag (sender_ctx, PULL_REPLY_PENDING); | 1754 | unset_peer_flag (sender_ctx, PULL_REPLY_PENDING); |
1746 | 1755 | ||
1756 | peer_clean (sender); | ||
1757 | |||
1747 | GNUNET_CADET_receive_done (channel); | 1758 | GNUNET_CADET_receive_done (channel); |
1748 | return GNUNET_OK; | 1759 | return GNUNET_OK; |
1749 | } | 1760 | } |
@@ -1922,6 +1933,8 @@ handle_client_act_malicious (void *cls, | |||
1922 | || 3 == mal_type) | 1933 | || 3 == mal_type) |
1923 | { /* Try to partition the network */ | 1934 | { /* Try to partition the network */ |
1924 | /* Add other malicious peers to those we already know */ | 1935 | /* Add other malicious peers to those we already know */ |
1936 | struct PeerContext *att_ctx; | ||
1937 | |||
1925 | num_mal_peers_sent = ntohl (in_msg->num_peers) - 1; | 1938 | num_mal_peers_sent = ntohl (in_msg->num_peers) - 1; |
1926 | num_mal_peers_old = num_mal_peers; | 1939 | num_mal_peers_old = num_mal_peers; |
1927 | GNUNET_array_grow (mal_peers, | 1940 | GNUNET_array_grow (mal_peers, |
@@ -1944,6 +1957,13 @@ handle_client_act_malicious (void *cls, | |||
1944 | memcpy (&attacked_peer, | 1957 | memcpy (&attacked_peer, |
1945 | &in_msg->attacked_peer, | 1958 | &in_msg->attacked_peer, |
1946 | sizeof (struct GNUNET_PeerIdentity)); | 1959 | sizeof (struct GNUNET_PeerIdentity)); |
1960 | /* Set the flag of the attacked peer to valid to avoid problems */ | ||
1961 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, | ||
1962 | &attacked_peer)) | ||
1963 | { | ||
1964 | att_ctx = create_peer_ctx (&attacked_peer); | ||
1965 | set_peer_flag (att_ctx, VALID); | ||
1966 | } | ||
1947 | 1967 | ||
1948 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1968 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1949 | "Attacked peer is %s\n", | 1969 | "Attacked peer is %s\n", |
@@ -2032,6 +2052,8 @@ do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2032 | * Send as many pushes to the attacked peer as possible | 2052 | * Send as many pushes to the attacked peer as possible |
2033 | * That is one push per round as it will ignore more. | 2053 | * That is one push per round as it will ignore more. |
2034 | */ | 2054 | */ |
2055 | peer_ctx = get_peer_ctx (&attacked_peer); | ||
2056 | if (NULL == peer_ctx->transmit_handle) | ||
2035 | send_push (&attacked_peer); | 2057 | send_push (&attacked_peer); |
2036 | } | 2058 | } |
2037 | 2059 | ||
@@ -2264,13 +2286,13 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2264 | /* Clean peers that were removed from the view */ | 2286 | /* Clean peers that were removed from the view */ |
2265 | for (i = 0; i < peers_to_clean_size; i++) | 2287 | for (i = 0; i < peers_to_clean_size; i++) |
2266 | { | 2288 | { |
2267 | peer_clean (&peers_to_clean[i]); | ||
2268 | to_file (file_name_view_log, | 2289 | to_file (file_name_view_log, |
2269 | "-%s", | 2290 | "-%s", |
2270 | GNUNET_i2s_full (&peers_to_clean[i])); | 2291 | GNUNET_i2s_full (&peers_to_clean[i])); |
2292 | peer_clean (&peers_to_clean[i]); | ||
2271 | } | 2293 | } |
2272 | 2294 | ||
2273 | GNUNET_free (peers_to_clean); | 2295 | GNUNET_array_grow (peers_to_clean, peers_to_clean_size, 0); |
2274 | peers_to_clean = NULL; | 2296 | peers_to_clean = NULL; |
2275 | } | 2297 | } |
2276 | else | 2298 | else |
@@ -2467,12 +2489,13 @@ peer_clean (const struct GNUNET_PeerIdentity *peer) | |||
2467 | struct PeerContext *peer_ctx; | 2489 | struct PeerContext *peer_ctx; |
2468 | /* struct GNUNET_CADET_Channel *channel; */ | 2490 | /* struct GNUNET_CADET_Channel *channel; */ |
2469 | 2491 | ||
2470 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_contains (view, peer) && | 2492 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (view, peer) && |
2471 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) | 2493 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) |
2472 | { | 2494 | { |
2473 | peer_ctx = get_peer_ctx (peer); | 2495 | peer_ctx = get_peer_ctx (peer); |
2474 | 2496 | ||
2475 | if (NULL == peer_ctx->recv_channel) | 2497 | if ( (NULL == peer_ctx->recv_channel) && |
2498 | (GNUNET_NO == get_peer_flag (peer_ctx, PULL_REPLY_PENDING)) ) | ||
2476 | { | 2499 | { |
2477 | peer_remove_cb (NULL, peer, peer_ctx); | 2500 | peer_remove_cb (NULL, peer, peer_ctx); |
2478 | } | 2501 | } |