gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19633 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r19633 - gnunet/src/transport
Date: Thu, 2 Feb 2012 15:41:20 +0100

Author: wachs
Date: 2012-02-02 15:41:20 +0100 (Thu, 02 Feb 2012)
New Revision: 19633

Modified:
   gnunet/src/transport/plugin_transport_udp_new.c
Log:
- minor


Modified: gnunet/src/transport/plugin_transport_udp_new.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_new.c     2012-02-02 13:57:36 UTC 
(rev 19632)
+++ gnunet/src/transport/plugin_transport_udp_new.c     2012-02-02 14:41:20 UTC 
(rev 19633)
@@ -100,18 +100,19 @@
   size_t addrlen;
 
   /**
+   * Desired delay for next sending we send to other peer
+   */
+  struct GNUNET_TIME_Relative flow_delay_for_other_peer;
+
+  /**
    * Desired delay for next sending we received from other peer
    */
   struct GNUNET_TIME_Absolute flow_delay_from_other_peer;
 
-  struct GNUNET_TIME_Relative flow_delay_for_other_peer;
 
   struct GNUNET_ATS_Information ats;
 
   struct FragmentationContext * frag_ctx;
-
-//  struct FragmentationContext * head;
-//  struct FragmentationContext * tail;
 };
 
 
@@ -651,6 +652,8 @@
   s->addrlen = len;
   s->target = *target;
   s->sock_addr = (const struct sockaddr *) &s[1];
+  s->flow_delay_for_other_peer = GNUNET_TIME_relative_get_zero();
+  s->flow_delay_from_other_peer = GNUNET_TIME_absolute_get_zero();
 
   return s;
 }
@@ -843,7 +846,6 @@
   struct Plugin *plugin = cls;
   size_t mlen = msgbuf_size + sizeof (struct UDPMessage);
 
-  struct GNUNET_TIME_Relative delta;
   struct UDPMessageWrapper * udpw;
   struct UDPMessage *udp;
   char mbuf[mlen];
@@ -917,8 +919,6 @@
     s->frag_ctx = frag_ctx;
 
   }
-
-  delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer);
   return mlen;
 }
 
@@ -1163,7 +1163,6 @@
     GNUNET_break (0);
     return;
   }
-  LOG (GNUNET_ERROR_TYPE_ERROR, "Sending fragment_msg_proc ms\n");
   process_udp_message (rc->plugin, (const struct UDPMessage *) msg,
                        rc->src_addr, rc->addr_len);
 }
@@ -1202,7 +1201,6 @@
 ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
 {
   struct DefragContext *rc = cls;
-  LOG (GNUNET_ERROR_TYPE_ERROR, "Sending ACK ms\n");
 
   size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size);
   struct UDP_ACK_Message *udp_ack;
@@ -1295,19 +1293,16 @@
       &lookup_session_by_addr_it,
       &l_ctx);
   s = l_ctx.res;
-  GNUNET_assert (s != NULL);
 
-  if (s != NULL)
-  {
-    flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay);
+  if ((s == NULL) || (s->frag_ctx == NULL))
+    return;
 
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n",
-         flow_delay.rel_value);
+  flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n",
+       flow_delay.rel_value);
+  s->flow_delay_from_other_peer =
+      GNUNET_TIME_relative_to_absolute (flow_delay);
 
-    s->flow_delay_from_other_peer =
-        GNUNET_TIME_relative_to_absolute (flow_delay);
-  }
-
   ack = (const struct GNUNET_MessageHeader *) &udp_ack[1];
   if (ntohs (ack->size) !=
       ntohs (msg->size) - sizeof (struct UDP_ACK_Message))
@@ -1335,6 +1330,17 @@
 #endif
   plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy 
(s->frag_ctx->frag);
 
+  struct UDPMessageWrapper * udpw = plugin->msg_head;
+  while (udpw!= NULL)
+  {
+    if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
+    {
+      GNUNET_CONTAINER_DLL_remove(plugin->msg_head, plugin->msg_tail, udpw);
+      GNUNET_free (udpw);
+    }
+    udpw = udpw->next;
+  }
+
   if (s->frag_ctx->cont != NULL)
     s->frag_ctx->cont
     (s->frag_ctx->cont_cls, &udp_ack->sender, GNUNET_OK);
@@ -1522,7 +1528,24 @@
       udpw = plugin->msg_head;
     }
     else
-      break;
+    {
+      struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_remaining 
(udpw->session->flow_delay_from_other_peer);
+      if (delta.rel_value == 0)
+      {
+        /* this message is not delayed */
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Message is not delayed for %llu 
\n",
+            delta);
+        break;
+      }
+      else
+      {
+        /* this message is delayed, try next */
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Message is delayed for %llu \n",
+            delta);
+        udpw = udpw->next;
+      }
+    }
+
   }
 
   if (udpw == NULL)
@@ -1957,7 +1980,6 @@
 {
   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
   struct Plugin *plugin = api->cls;
-GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "libgnunet_plugin_transport_udp_done\n ");
   stop_broadcast (plugin);
 
   if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)




reply via email to

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