diff options
author | Julius Bünger <buenger@mytum.de> | 2018-06-27 03:58:42 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-06-27 03:59:59 +0200 |
commit | 6ac64e16ee69704579ebfd942183e04f32f60590 (patch) | |
tree | e8f10ae4a57170f265de3ea07329c522407dda51 | |
parent | 332d987a4c618f4d51abe9df9e662a59cc68b51c (diff) | |
download | gnunet-6ac64e16ee69704579ebfd942183e04f32f60590.tar.gz gnunet-6ac64e16ee69704579ebfd942183e04f32f60590.zip |
fix rps service/test: handle pending messages properly
-rw-r--r-- | src/rps/gnunet-service-rps.c | 15 | ||||
-rw-r--r-- | src/rps/test_rps.c | 9 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 55569866b..8fe64c2eb 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -724,7 +724,6 @@ mq_liveliness_check_successful (void *cls) | |||
724 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 724 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
725 | "Liveliness check for peer %s was successfull\n", | 725 | "Liveliness check for peer %s was successfull\n", |
726 | GNUNET_i2s (&peer_ctx->peer_id)); | 726 | GNUNET_i2s (&peer_ctx->peer_id)); |
727 | //GNUNET_free (peer_ctx->liveliness_check_pending); | ||
728 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); | 727 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); |
729 | peer_ctx->liveliness_check_pending = NULL; | 728 | peer_ctx->liveliness_check_pending = NULL; |
730 | set_peer_live (peer_ctx); | 729 | set_peer_live (peer_ctx); |
@@ -747,10 +746,6 @@ check_peer_live (struct PeerContext *peer_ctx) | |||
747 | struct GNUNET_MQ_Envelope *ev; | 746 | struct GNUNET_MQ_Envelope *ev; |
748 | 747 | ||
749 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE); | 748 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE); |
750 | //peer_ctx->liveliness_check_pending = GNUNET_new (struct PendingMessage); | ||
751 | //peer_ctx->liveliness_check_pending->ev = ev; | ||
752 | //peer_ctx->liveliness_check_pending->peer_ctx = peer_ctx; | ||
753 | //peer_ctx->liveliness_check_pending->type = "Check liveliness"; | ||
754 | peer_ctx->liveliness_check_pending = | 749 | peer_ctx->liveliness_check_pending = |
755 | insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness"); | 750 | insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness"); |
756 | mq = get_mq (&peer_ctx->peer_id); | 751 | mq = get_mq (&peer_ctx->peer_id); |
@@ -1261,6 +1256,13 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1261 | "Removing unsent %s\n", | 1256 | "Removing unsent %s\n", |
1262 | peer_ctx->pending_messages_head->type); | 1257 | peer_ctx->pending_messages_head->type); |
1263 | /* 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 | } | ||
1264 | remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); | 1266 | remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); |
1265 | } | 1267 | } |
1266 | /* 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 |
@@ -1272,7 +1274,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1272 | GNUNET_i2s (&peer_ctx->peer_id)); | 1274 | GNUNET_i2s (&peer_ctx->peer_id)); |
1273 | // TODO wait until cadet sets mq->cancel_impl | 1275 | // TODO wait until cadet sets mq->cancel_impl |
1274 | //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); | 1276 | //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); |
1275 | GNUNET_free (peer_ctx->liveliness_check_pending); | 1277 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); |
1276 | peer_ctx->liveliness_check_pending = NULL; | 1278 | peer_ctx->liveliness_check_pending = NULL; |
1277 | } | 1279 | } |
1278 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING); | 1280 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING); |
@@ -3596,6 +3598,7 @@ handle_client_act_malicious (void *cls, | |||
3596 | 3598 | ||
3597 | num_mal_peers_sent = ntohl (msg->num_peers) - 1; | 3599 | num_mal_peers_sent = ntohl (msg->num_peers) - 1; |
3598 | 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); | ||
3599 | GNUNET_array_grow (mal_peers, | 3602 | GNUNET_array_grow (mal_peers, |
3600 | num_mal_peers, | 3603 | num_mal_peers, |
3601 | num_mal_peers + num_mal_peers_sent); | 3604 | num_mal_peers + num_mal_peers_sent); |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index e7b82458a..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 | ||
@@ -998,9 +1005,11 @@ rps_connect_adapter (void *cls, | |||
998 | struct GNUNET_RPS_Handle *h; | 1005 | struct GNUNET_RPS_Handle *h; |
999 | 1006 | ||
1000 | h = GNUNET_RPS_connect (cfg); | 1007 | h = GNUNET_RPS_connect (cfg); |
1008 | GNUNET_assert (NULL != h); | ||
1001 | 1009 | ||
1002 | if (NULL != cur_test_run.pre_test) | 1010 | if (NULL != cur_test_run.pre_test) |
1003 | cur_test_run.pre_test (cls, h); | 1011 | cur_test_run.pre_test (cls, h); |
1012 | GNUNET_assert (NULL != h); | ||
1004 | 1013 | ||
1005 | return h; | 1014 | return h; |
1006 | } | 1015 | } |