gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r35300 - gnunet/src/rps
Date: Tue, 24 Feb 2015 00:48:36 +0100

Author: ch3
Date: 2015-02-24 00:48:36 +0100 (Tue, 24 Feb 2015)
New Revision: 35300

Modified:
   gnunet/src/rps/gnunet-service-rps.c
Log:
- sending act malicious message

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-02-23 14:35:02 UTC (rev 35299)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-02-23 23:48:36 UTC (rev 35300)
@@ -668,50 +668,30 @@
 get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
              const struct GNUNET_PeerIdentity *peer)
 {
-  struct PeerContext *ctx;
+  struct PeerContext *peer_ctx;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Trying to establish channel to peer %s\n",
        GNUNET_i2s (peer));
 
-  ctx = get_peer_ctx (peer_map, peer);
-  if (NULL == ctx->send_channel)
+  peer_ctx = get_peer_ctx (peer_map, peer);
+  if (NULL == peer_ctx->send_channel)
   {
-    ctx->send_channel = GNUNET_CADET_channel_create (cadet_handle,
-                                                     NULL,
-                                                     peer,
-                                                     GNUNET_RPS_CADET_PORT,
-                                                     
GNUNET_CADET_OPTION_RELIABLE);
+    peer_ctx->send_channel =
+      GNUNET_CADET_channel_create (cadet_handle,
+                                   NULL,
+                                   peer,
+                                   GNUNET_RPS_CADET_PORT,
+                                   GNUNET_CADET_OPTION_RELIABLE);
 
-    /* If we don't know whether peer is live,
-     * get notified when we know it is live. */
-    if (GNUNET_YES != get_peer_flag (ctx, VALID)
-        && NULL != ctx->is_live_task
-        && NULL == ctx->recv_channel
-        && NULL == ctx->is_live_task)
-    {
-      ctx->peer_id = *peer;
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Get informed about peer %s getting live\n",
-           GNUNET_i2s (peer));
-      ctx->is_live_task =
-          GNUNET_CADET_notify_transmit_ready (ctx->send_channel,
-                                              GNUNET_NO,
-                                              GNUNET_TIME_UNIT_FOREVER_REL,
-                                              sizeof (struct 
GNUNET_MessageHeader),
-                                              cadet_ntfy_tmt_rdy_cb,
-                                              ctx);
-    }
-    // FIXME check whether this is NULL
-
     // do I have to explicitly put it in the peer_map?
     (void) GNUNET_CONTAINER_multipeermap_put
       (peer_map,
        peer,
-       ctx,
+       peer_ctx,
        GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
   }
-  return ctx->send_channel;
+  return peer_ctx->send_channel;
 }
 
 
@@ -729,8 +709,6 @@
 
   peer_ctx = get_peer_ctx (peer_map, peer_id);
 
-  GNUNET_assert (NULL == peer_ctx->is_live_task);
-
   if (NULL == peer_ctx->mq)
   {
     (void) get_channel (peer_map, peer_id);
@@ -744,6 +722,29 @@
 
 
 /**
+ * Issue check whether peer is live
+ *
+ * @param peer_ctx the context of the peer
+ */
+void
+check_peer_live (struct PeerContext *peer_ctx)
+{
+  (void) get_channel (peer_map, &peer_ctx->peer_id);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Get informed about peer %s getting live\n",
+       GNUNET_i2s (&peer_ctx->peer_id));
+  peer_ctx->is_live_task =
+      GNUNET_CADET_notify_transmit_ready (peer_ctx->send_channel,
+                                          GNUNET_NO,
+                                          GNUNET_TIME_UNIT_FOREVER_REL,
+                                          sizeof (struct GNUNET_MessageHeader),
+                                          cadet_ntfy_tmt_rdy_cb,
+                                          peer_ctx);
+  // FIXME check whether this is NULL
+}
+
+
+/**
  * Sum all time relatives of an array.
   */
   struct GNUNET_TIME_Relative
@@ -1312,6 +1313,7 @@
       GNUNET_array_append (peer_ctx->outstanding_ops,
                            peer_ctx->num_outstanding_ops,
                            out_op);
+      check_peer_live (peer_ctx);
     }
   }
 
@@ -1654,7 +1656,7 @@
       }
 
       /* Trigger livelyness test on peer */
-      (void) get_channel (peer_map, peer);
+      check_peer_live (peer_ctx);
     }
 
     // send push/pull to each of those peers?
@@ -1884,7 +1886,7 @@
       /* Cast to void is ok, because it's used as void in peer_remove_cb */
       (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
     }
-    else
+    else /* Other peer doesn't want to send us messages anymore */
       peer_ctx->recv_channel = NULL;
   }
 }




reply via email to

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