gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36165 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r36165 - gnunet/src/rps
Date: Sun, 2 Aug 2015 19:48:51 +0200

Author: ch3
Date: 2015-08-02 19:48:51 +0200 (Sun, 02 Aug 2015)
New Revision: 36165

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/test_rps.c
Log:
-fixes

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-08-02 17:11:48 UTC (rev 36164)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-08-02 17:48:51 UTC (rev 36165)
@@ -935,6 +935,8 @@
   void
 insert_in_view (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (view, peer))
+      return;
   if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put (view,
         peer,
         NULL,
@@ -2150,16 +2152,20 @@
   { /* Combined attack */
 
     /* Send PUSH to attacked peers */
-    peer_ctx = get_peer_ctx (&attacked_peer);
-    if (GNUNET_YES == get_peer_flag (peer_ctx, VALID))
+    if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map,
+          &attacked_peer))
     {
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "Goding to send push to attacked peer (%s)\n",
-          GNUNET_i2s (&attacked_peer));
-      send_push (&attacked_peer);
+      peer_ctx = get_peer_ctx (&attacked_peer);
+      if (GNUNET_YES == get_peer_flag (peer_ctx, VALID))
+      {
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+            "Goding to send push to attacked peer (%s)\n",
+            GNUNET_i2s (&attacked_peer));
+        send_push (&attacked_peer);
+      }
+      else
+        check_peer_live (peer_ctx);
     }
-    else
-      check_peer_live (peer_ctx);
 
     /* The maximum of pushes we're going to send this round */
     num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1,

Modified: gnunet/src/rps/test_rps.c
===================================================================
--- gnunet/src/rps/test_rps.c   2015-08-02 17:11:48 UTC (rev 36164)
+++ gnunet/src/rps/test_rps.c   2015-08-02 17:48:51 UTC (rev 36165)
@@ -718,7 +718,8 @@
                 i,
                 GNUNET_i2s (&recv_peers[i]));
 
-    GNUNET_array_append (rps_peer->rec_ids, rps_peer->num_rec_ids, 
recv_peers[i]);
+    /* GNUNET_array_append (rps_peer->rec_ids, rps_peer->num_rec_ids, 
recv_peers[i]); */
+    rps_peer->num_rec_ids++;
   }
 
   if (0 == evaluate ())
@@ -821,6 +822,12 @@
   unsigned int i;
   struct PendingRequest *pending_req;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      "Scheduling %u - %u missing requests\n",
+      rps_peer->num_ids_to_request,
+      rps_peer->num_pending_reqs + rps_peer->num_pending_reps);
+  GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <=
+      rps_peer->num_ids_to_request);
   for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps;
        i < rps_peer->num_ids_to_request; i++)
   {
@@ -841,6 +848,8 @@
 void
 cancel_pending_req_rep (struct RPSPeer *rps_peer)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      "Cancelling all (pending) requests.\n");
   while (NULL != rps_peer->pending_req_head)
     cancel_pending_req (rps_peer->pending_req_head);
   GNUNET_assert (0 == rps_peer->num_pending_reqs);
@@ -1072,14 +1081,16 @@
               i,
               j,
               GNUNET_i2s (rps_peers[j].peer_id),
-              (delta < 0)? "online" : "offline");
+              (0 > delta) ? "online" : "offline");
   if (prob < prob_go_on_off * UINT32_MAX)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "%s goes %s\n",
                 GNUNET_i2s (rps_peers[j].peer_id),
-                (delta < 0) ? "offline" : "online");
+                (0 > delta) ? "offline" : "online");
 
+    if (0 > delta)
+      cancel_pending_req_rep (&rps_peers[j]);
     entry = make_oplist_entry ();
     entry->delta = delta;
     entry->index = j;
@@ -1088,7 +1099,7 @@
                                                     "rps",
                                                     &churn_cb,
                                                     entry,
-                                                    (delta < 0) ? 0 : 1);
+                                                    (0 > delta) ? 0 : 1);
   }
 }
 
@@ -1133,7 +1144,6 @@
     /* If online, shut down with certain probability */
     if (GNUNET_YES == rps_peers[j].online)
     {
-      cancel_pending_req_rep (&rps_peers[j]);
       manage_service_wrapper (i, j, -1, prob_go_offline);
     }
 
@@ -1203,11 +1213,7 @@
              "%" PRIu32 "\n",
              (uint32_t) rcv_rps_peer->index);
   }
-  /* Find #PendingReply holding the request handle */
-  GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
-                               rps_peer->pending_rep_tail,
-                               pending_rep);
-  rps_peer->num_pending_reps--;
+  default_reply_handle (cls, n, recv_peers);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]