Check that you are not present in trail twice
[oweals/gnunet.git] / src / transport / gnunet-service-transport_manipulation.c
index 4521047c9f2d793ab15dbcdf1d7fc5e78d249fc5..bfd2594a8e131376cfde621b12f2f09e2c9ab564 100644 (file)
@@ -521,17 +521,16 @@ GST_manipulation_manipulate_metrics(const struct GNUNET_PeerIdentity *peer,
  * manipulation delays for next send.
  *
  * @param cls the closure for transport
- * @param peer the peer the message was received from
+ * @param address the address and the peer the message was received from
  * @param message the message received
  * @param session the session the message was received on
- * @param sender_address the sender address
- * @param sender_address_len the length of the sender address
  * @return manipulated delay for next receive
  */
 struct GNUNET_TIME_Relative
-GST_manipulation_recv(void *cls, const struct GNUNET_PeerIdentity *peer,
-    const struct GNUNET_MessageHeader *message, struct Session *session,
-    const char *sender_address, uint16_t sender_address_len)
+GST_manipulation_recv (void *cls,
+    const struct GNUNET_HELLO_Address *address,
+    struct Session *session,
+    const struct GNUNET_MessageHeader *message)
 {
   struct TM_Peer *tmp;
   uint32_t p_recv_delay;
@@ -547,7 +546,7 @@ GST_manipulation_recv(void *cls, const struct GNUNET_PeerIdentity *peer,
   else
     m_delay = GNUNET_TIME_UNIT_ZERO;
 
-  if (NULL != (tmp = GNUNET_CONTAINER_multipeermap_get(man_handle.peers, peer)))
+  if (NULL != (tmp = GNUNET_CONTAINER_multipeermap_get(man_handle.peers, &address->peer)))
     {
       /* Manipulate receive delay */
       p_recv_delay = find_metric(tmp, GNUNET_ATS_QUALITY_NET_DELAY, TM_RECEIVE);
@@ -555,14 +554,15 @@ GST_manipulation_recv(void *cls, const struct GNUNET_PeerIdentity *peer,
         m_delay.rel_value_us = p_recv_delay; /* Peer specific delay */
     }
 
-  quota_delay = GST_receive_callback(cls, peer, message, session,
-      sender_address, sender_address_len);
+  quota_delay = GST_receive_callback(cls, address, session, message);
 
   if (quota_delay.rel_value_us > m_delay.rel_value_us)
     m_delay = quota_delay;
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-      "Delaying next receive for peer `%s' for %s\n", GNUNET_i2s (peer), GNUNET_STRINGS_relative_time_to_string (m_delay, GNUNET_YES));
+      "Delaying next receive for peer `%s' for %s\n",
+      GNUNET_i2s (&address->peer),
+      GNUNET_STRINGS_relative_time_to_string (m_delay, GNUNET_YES));
   return m_delay;
 
 }
@@ -696,6 +696,7 @@ GST_manipulation_peer_disconnect(const struct GNUNET_PeerIdentity *peer)
       if (GNUNET_SCHEDULER_NO_TASK != generic_send_delay_task)
         {
           GNUNET_SCHEDULER_cancel(generic_send_delay_task);
+          generic_send_delay_task = GNUNET_SCHEDULER_NO_TASK;
           if (NULL != generic_dqe_head)
             generic_send_delay_task = GNUNET_SCHEDULER_add_delayed(
                 GNUNET_TIME_absolute_get_remaining(generic_dqe_head->sent_at),