aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-rps.c5
-rw-r--r--src/rps/gnunet-service-rps.c122
-rw-r--r--src/rps/gnunet-service-rps_custommap.c1
-rw-r--r--src/rps/gnunet-service-rps_sampler.c1
-rw-r--r--src/rps/rps-test_util.c6
-rw-r--r--src/rps/test_rps.c12
6 files changed, 89 insertions, 58 deletions
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index 739f71dac..b3785a733 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -150,6 +150,11 @@ run (void *cls,
150 static struct GNUNET_PeerIdentity zero_pid; 150 static struct GNUNET_PeerIdentity zero_pid;
151 151
152 rps_handle = GNUNET_RPS_connect (cfg); 152 rps_handle = GNUNET_RPS_connect (cfg);
153 if (NULL == rps_handle)
154 {
155 FPRINTF (stderr, "Failed to connect to the rps service\n");
156 return;
157 }
153 158
154 if ((0 == memcmp (&zero_pid, &peer_id, sizeof (peer_id))) && 159 if ((0 == memcmp (&zero_pid, &peer_id, sizeof (peer_id))) &&
155 (!view_update)) 160 (!view_update))
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 1b9681663..84fb33be2 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -243,7 +243,7 @@ struct PeerContext
243 243
244 /** 244 /**
245 * This is pobably followed by 'statistical' data (when we first saw 245 * This is pobably followed by 'statistical' data (when we first saw
246 * him, how did we get his ID, how many pushes (in a timeinterval), 246 * it, how did we get its ID, how many pushes (in a timeinterval),
247 * ...) 247 * ...)
248 */ 248 */
249}; 249};
@@ -503,6 +503,8 @@ add_valid_peer (const struct GNUNET_PeerIdentity *peer)
503 return ret; 503 return ret;
504} 504}
505 505
506static void
507remove_pending_message (struct PendingMessage *pending_msg, int cancel);
506 508
507/** 509/**
508 * @brief Set the peer flag to living and 510 * @brief Set the peer flag to living and
@@ -531,7 +533,7 @@ set_peer_live (struct PeerContext *peer_ctx)
531 GNUNET_i2s (&peer_ctx->peer_id)); 533 GNUNET_i2s (&peer_ctx->peer_id));
532 // TODO wait until cadet sets mq->cancel_impl 534 // TODO wait until cadet sets mq->cancel_impl
533 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); 535 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
534 GNUNET_free (peer_ctx->liveliness_check_pending); 536 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
535 peer_ctx->liveliness_check_pending = NULL; 537 peer_ctx->liveliness_check_pending = NULL;
536 } 538 }
537 539
@@ -653,56 +655,6 @@ get_mq (const struct GNUNET_PeerIdentity *peer)
653 return peer_ctx->mq; 655 return peer_ctx->mq;
654} 656}
655 657
656
657/**
658 * @brief This is called in response to the first message we sent as a
659 * liveliness check.
660 *
661 * @param cls #PeerContext of peer with pending liveliness check
662 */
663static void
664mq_liveliness_check_successful (void *cls)
665{
666 struct PeerContext *peer_ctx = cls;
667
668 if (NULL != peer_ctx->liveliness_check_pending)
669 {
670 LOG (GNUNET_ERROR_TYPE_DEBUG,
671 "Liveliness check for peer %s was successfull\n",
672 GNUNET_i2s (&peer_ctx->peer_id));
673 GNUNET_free (peer_ctx->liveliness_check_pending);
674 peer_ctx->liveliness_check_pending = NULL;
675 set_peer_live (peer_ctx);
676 }
677}
678
679/**
680 * Issue a check whether peer is live
681 *
682 * @param peer_ctx the context of the peer
683 */
684static void
685check_peer_live (struct PeerContext *peer_ctx)
686{
687 LOG (GNUNET_ERROR_TYPE_DEBUG,
688 "Get informed about peer %s getting live\n",
689 GNUNET_i2s (&peer_ctx->peer_id));
690
691 struct GNUNET_MQ_Handle *mq;
692 struct GNUNET_MQ_Envelope *ev;
693
694 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE);
695 peer_ctx->liveliness_check_pending = GNUNET_new (struct PendingMessage);
696 peer_ctx->liveliness_check_pending->ev = ev;
697 peer_ctx->liveliness_check_pending->peer_ctx = peer_ctx;
698 peer_ctx->liveliness_check_pending->type = "Check liveliness";
699 mq = get_mq (&peer_ctx->peer_id);
700 GNUNET_MQ_notify_sent (ev,
701 mq_liveliness_check_successful,
702 peer_ctx);
703 GNUNET_MQ_send (mq, ev);
704}
705
706/** 658/**
707 * @brief Add an envelope to a message passed to mq to list of pending messages 659 * @brief Add an envelope to a message passed to mq to list of pending messages
708 * 660 *
@@ -757,6 +709,54 @@ remove_pending_message (struct PendingMessage *pending_msg, int cancel)
757 709
758 710
759/** 711/**
712 * @brief This is called in response to the first message we sent as a
713 * liveliness check.
714 *
715 * @param cls #PeerContext of peer with pending liveliness check
716 */
717static void
718mq_liveliness_check_successful (void *cls)
719{
720 struct PeerContext *peer_ctx = cls;
721
722 if (NULL != peer_ctx->liveliness_check_pending)
723 {
724 LOG (GNUNET_ERROR_TYPE_DEBUG,
725 "Liveliness check for peer %s was successfull\n",
726 GNUNET_i2s (&peer_ctx->peer_id));
727 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
728 peer_ctx->liveliness_check_pending = NULL;
729 set_peer_live (peer_ctx);
730 }
731}
732
733/**
734 * Issue a check whether peer is live
735 *
736 * @param peer_ctx the context of the peer
737 */
738static void
739check_peer_live (struct PeerContext *peer_ctx)
740{
741 LOG (GNUNET_ERROR_TYPE_DEBUG,
742 "Get informed about peer %s getting live\n",
743 GNUNET_i2s (&peer_ctx->peer_id));
744
745 struct GNUNET_MQ_Handle *mq;
746 struct GNUNET_MQ_Envelope *ev;
747
748 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE);
749 peer_ctx->liveliness_check_pending =
750 insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness");
751 mq = get_mq (&peer_ctx->peer_id);
752 GNUNET_MQ_notify_sent (ev,
753 mq_liveliness_check_successful,
754 peer_ctx);
755 GNUNET_MQ_send (mq, ev);
756}
757
758
759/**
760 * @brief Check whether function of type #PeerOp was already scheduled 760 * @brief Check whether function of type #PeerOp was already scheduled
761 * 761 *
762 * The array with pending operations will probably never grow really big, so 762 * The array with pending operations will probably never grow really big, so
@@ -1256,6 +1256,13 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1256 "Removing unsent %s\n", 1256 "Removing unsent %s\n",
1257 peer_ctx->pending_messages_head->type); 1257 peer_ctx->pending_messages_head->type);
1258 /* Cancle pending message, too */ 1258 /* Cancle pending message, too */
1259 if ( (NULL != peer_ctx->liveliness_check_pending) &&
1260 (0 == memcmp (peer_ctx->pending_messages_head,
1261 peer_ctx->liveliness_check_pending,
1262 sizeof (struct PendingMessage))) )
1263 {
1264 peer_ctx->liveliness_check_pending = NULL;
1265 }
1259 remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); 1266 remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES);
1260 } 1267 }
1261 /* If we are still waiting for notification whether this peer is live 1268 /* If we are still waiting for notification whether this peer is live
@@ -1267,7 +1274,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1267 GNUNET_i2s (&peer_ctx->peer_id)); 1274 GNUNET_i2s (&peer_ctx->peer_id));
1268 // TODO wait until cadet sets mq->cancel_impl 1275 // TODO wait until cadet sets mq->cancel_impl
1269 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); 1276 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
1270 GNUNET_free (peer_ctx->liveliness_check_pending); 1277 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
1271 peer_ctx->liveliness_check_pending = NULL; 1278 peer_ctx->liveliness_check_pending = NULL;
1272 } 1279 }
1273 channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING); 1280 channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING);
@@ -2728,7 +2735,7 @@ cleanup_destroyed_channel (void *cls,
2728 return; 2735 return;
2729 } 2736 }
2730 else 2737 else
2731 { /* Other peer destroyed our sending channel that he is supposed to keep 2738 { /* Other peer destroyed our sending channel that it is supposed to keep
2732 * open. It probably went down. Remove it from our knowledge. */ 2739 * open. It probably went down. Remove it from our knowledge. */
2733 Peers_cleanup_destroyed_channel (cls, channel); 2740 Peers_cleanup_destroyed_channel (cls, channel);
2734 remove_peer (peer); 2741 remove_peer (peer);
@@ -2893,7 +2900,6 @@ client_respond (void *cls,
2893 GNUNET_memcpy (&out_msg[1], 2900 GNUNET_memcpy (&out_msg[1],
2894 peer_ids, 2901 peer_ids,
2895 num_peers * sizeof (struct GNUNET_PeerIdentity)); 2902 num_peers * sizeof (struct GNUNET_PeerIdentity));
2896 GNUNET_free (peer_ids);
2897 2903
2898 cli_ctx = reply_cls->cli_ctx; 2904 cli_ctx = reply_cls->cli_ctx;
2899 GNUNET_assert (NULL != cli_ctx); 2905 GNUNET_assert (NULL != cli_ctx);
@@ -3210,6 +3216,10 @@ handle_peer_push (void *cls,
3210 tmp_att_peer); 3216 tmp_att_peer);
3211 add_peer_array_to_set (peer, 1, att_peer_set); 3217 add_peer_array_to_set (peer, 1, att_peer_set);
3212 } 3218 }
3219 else
3220 {
3221 GNUNET_free (tmp_att_peer);
3222 }
3213 } 3223 }
3214 3224
3215 3225
@@ -3588,6 +3598,7 @@ handle_client_act_malicious (void *cls,
3588 3598
3589 num_mal_peers_sent = ntohl (msg->num_peers) - 1; 3599 num_mal_peers_sent = ntohl (msg->num_peers) - 1;
3590 num_mal_peers_old = num_mal_peers; 3600 num_mal_peers_old = num_mal_peers;
3601 GNUNET_assert (GNUNET_MAX_MALLOC_CHECKED > num_mal_peers_sent);
3591 GNUNET_array_grow (mal_peers, 3602 GNUNET_array_grow (mal_peers,
3592 num_mal_peers, 3603 num_mal_peers,
3593 num_mal_peers + num_mal_peers_sent); 3604 num_mal_peers + num_mal_peers_sent);
@@ -4172,6 +4183,7 @@ shutdown_task (void *cls)
4172 { 4183 {
4173 tmp_att_peer = att_peers_head; 4184 tmp_att_peer = att_peers_head;
4174 GNUNET_CONTAINER_DLL_remove (att_peers_head, att_peers_tail, tmp_att_peer); 4185 GNUNET_CONTAINER_DLL_remove (att_peers_head, att_peers_tail, tmp_att_peer);
4186 GNUNET_free (tmp_att_peer);
4175 } 4187 }
4176 #endif /* ENABLE_MALICIOUS */ 4188 #endif /* ENABLE_MALICIOUS */
4177} 4189}
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 90177cb94..42507655b 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -220,6 +220,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
220 GNUNET_free (index); 220 GNUNET_free (index);
221 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) == 221 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) ==
222 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map)); 222 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map));
223 GNUNET_free (p);
223 return GNUNET_OK; 224 return GNUNET_OK;
224} 225}
225 226
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index 711d5be63..4d1ae4650 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -725,6 +725,7 @@ RPS_sampler_request_cancel (struct RPS_SamplerRequestHandle *req_handle)
725 } 725 }
726 GNUNET_free (i); 726 GNUNET_free (i);
727 } 727 }
728 GNUNET_free (req_handle->ids);
728 GNUNET_CONTAINER_DLL_remove (req_handle->sampler->req_handle_head, 729 GNUNET_CONTAINER_DLL_remove (req_handle->sampler->req_handle_head,
729 req_handle->sampler->req_handle_tail, 730 req_handle->sampler->req_handle_tail,
730 req_handle); 731 req_handle);
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 0ee290e67..d47e4952f 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -352,10 +352,10 @@ create_file (const char *name)
352 if (NULL == strstr (name, "sampler_el")) 352 if (NULL == strstr (name, "sampler_el"))
353 {/* only append random string to sampler */ 353 {/* only append random string to sampler */
354 if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) 354 if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
355 LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); 355 LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
356 356
357 GNUNET_free (name_buf); 357 GNUNET_free (name_buf);
358 return file_name; 358 return file_name;
359 } 359 }
360 360
361 return name_buf; 361 return name_buf;
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 3ef1e6611..08424022f 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -841,6 +841,13 @@ seed_peers (void *cls)
841 unsigned int amount; 841 unsigned int amount;
842 unsigned int i; 842 unsigned int i;
843 843
844 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
845 {
846 return;
847 }
848
849 GNUNET_assert (NULL != peer->rps_handle);
850
844 // TODO if malicious don't seed mal peers 851 // TODO if malicious don't seed mal peers
845 amount = round (.5 * num_peers); 852 amount = round (.5 * num_peers);
846 853
@@ -953,6 +960,8 @@ rps_connect_complete_cb (void *cls,
953 struct RPSPeer *rps_peer = cls; 960 struct RPSPeer *rps_peer = cls;
954 struct GNUNET_RPS_Handle *rps = ca_result; 961 struct GNUNET_RPS_Handle *rps = ca_result;
955 962
963 GNUNET_assert (NULL != ca_result);
964
956 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) 965 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
957 { 966 {
958 return; 967 return;
@@ -996,9 +1005,11 @@ rps_connect_adapter (void *cls,
996 struct GNUNET_RPS_Handle *h; 1005 struct GNUNET_RPS_Handle *h;
997 1006
998 h = GNUNET_RPS_connect (cfg); 1007 h = GNUNET_RPS_connect (cfg);
1008 GNUNET_assert (NULL != h);
999 1009
1000 if (NULL != cur_test_run.pre_test) 1010 if (NULL != cur_test_run.pre_test)
1001 cur_test_run.pre_test (cls, h); 1011 cur_test_run.pre_test (cls, h);
1012 GNUNET_assert (NULL != h);
1002 1013
1003 return h; 1014 return h;
1004} 1015}
@@ -2905,6 +2916,7 @@ main (int argc, char *argv[])
2905 } 2916 }
2906 2917
2907 ret_value = cur_test_run.eval_cb(); 2918 ret_value = cur_test_run.eval_cb();
2919
2908 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) 2920 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
2909 { 2921 {
2910 GNUNET_array_grow (rps_peers->cur_view, 2922 GNUNET_array_grow (rps_peers->cur_view,