fix rps service/test: handle pending messages properly
authorJulius Bünger <buenger@mytum.de>
Wed, 27 Jun 2018 01:58:42 +0000 (03:58 +0200)
committerJulius Bünger <buenger@mytum.de>
Wed, 27 Jun 2018 01:59:59 +0000 (03:59 +0200)
src/rps/gnunet-service-rps.c
src/rps/test_rps.c

index 55569866b11707557d01a5d48925c6f0302666ac..8fe64c2eb99c334d49c8370cb97421f59220275f 100644 (file)
@@ -724,7 +724,6 @@ mq_liveliness_check_successful (void *cls)
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Liveliness check for peer %s was successfull\n",
         GNUNET_i2s (&peer_ctx->peer_id));
-    //GNUNET_free (peer_ctx->liveliness_check_pending);
     remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
     peer_ctx->liveliness_check_pending = NULL;
     set_peer_live (peer_ctx);
@@ -747,10 +746,6 @@ check_peer_live (struct PeerContext *peer_ctx)
   struct GNUNET_MQ_Envelope *ev;
 
   ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE);
-  //peer_ctx->liveliness_check_pending = GNUNET_new (struct PendingMessage);
-  //peer_ctx->liveliness_check_pending->ev = ev;
-  //peer_ctx->liveliness_check_pending->peer_ctx = peer_ctx;
-  //peer_ctx->liveliness_check_pending->type = "Check liveliness";
   peer_ctx->liveliness_check_pending =
     insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness");
   mq = get_mq (&peer_ctx->peer_id);
@@ -1261,6 +1256,13 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
         "Removing unsent %s\n",
         peer_ctx->pending_messages_head->type);
     /* Cancle pending message, too */
+    if ( (NULL != peer_ctx->liveliness_check_pending) &&
+         (0 == memcmp (peer_ctx->pending_messages_head,
+                     peer_ctx->liveliness_check_pending,
+                     sizeof (struct PendingMessage))) )
+      {
+        peer_ctx->liveliness_check_pending = NULL;
+      }
     remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES);
   }
   /* If we are still waiting for notification whether this peer is live
@@ -1272,7 +1274,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
          GNUNET_i2s (&peer_ctx->peer_id));
     // TODO wait until cadet sets mq->cancel_impl
     //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
-    GNUNET_free (peer_ctx->liveliness_check_pending);
+    remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES);
     peer_ctx->liveliness_check_pending = NULL;
   }
   channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING);
@@ -3596,6 +3598,7 @@ handle_client_act_malicious (void *cls,
 
     num_mal_peers_sent = ntohl (msg->num_peers) - 1;
     num_mal_peers_old = num_mal_peers;
+    GNUNET_assert (GNUNET_MAX_MALLOC_CHECKED > num_mal_peers_sent);
     GNUNET_array_grow (mal_peers,
                        num_mal_peers,
                        num_mal_peers + num_mal_peers_sent);
index e7b82458a016eb848c3047c6b7f4ce29b0e1ef7a..08424022f559d778d9e272064efe1fa7e2dc7f99 100644 (file)
@@ -841,6 +841,13 @@ seed_peers (void *cls)
   unsigned int amount;
   unsigned int i;
 
+  if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
+  {
+    return;
+  }
+
+  GNUNET_assert (NULL != peer->rps_handle);
+
   // TODO if malicious don't seed mal peers
   amount = round (.5 * num_peers);
 
@@ -998,9 +1005,11 @@ rps_connect_adapter (void *cls,
   struct GNUNET_RPS_Handle *h;
 
   h = GNUNET_RPS_connect (cfg);
+  GNUNET_assert (NULL != h);
 
   if (NULL != cur_test_run.pre_test)
     cur_test_run.pre_test (cls, h);
+  GNUNET_assert (NULL != h);
 
   return h;
 }