gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24955 - gnunet/src/transport
Date: Wed, 14 Nov 2012 15:09:43 +0100

Author: wachs
Date: 2012-11-14 15:09:43 +0100 (Wed, 14 Nov 2012)
New Revision: 24955

Modified:
   gnunet/src/transport/plugin_transport_unix.c
   gnunet/src/transport/test_transport_api_unreliability.c
Log:
improve unix timeout behaviour

Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c        2012-11-14 13:57:58 UTC 
(rev 24954)
+++ gnunet/src/transport/plugin_transport_unix.c        2012-11-14 14:09:43 UTC 
(rev 24955)
@@ -108,7 +108,7 @@
   size_t msgsize;
   size_t payload;
 
-  struct GNUNET_TIME_Relative timeout;
+  struct GNUNET_TIME_Absolute timeout;
   unsigned int priority;
 
   struct Session *session;
@@ -495,7 +495,7 @@
                 struct GNUNET_NETWORK_Handle *send_handle,
                 const struct GNUNET_PeerIdentity *target, const char *msgbuf,
                 size_t msgbuf_size, unsigned int priority,
-                struct GNUNET_TIME_Relative timeout,
+                struct GNUNET_TIME_Absolute timeout,
                 const void *addr,
                 size_t addrlen,
                 size_t payload,
@@ -753,7 +753,7 @@
   wrapper->msgsize = ssize;
   wrapper->payload = msgbuf_size;
   wrapper->priority = priority;
-  wrapper->timeout = to;
+  wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), to);
   wrapper->cont = cont;
   wrapper->cont_cls = cont_cls;
   wrapper->session = session;
@@ -896,8 +896,36 @@
 {
   static int retry_counter = 0;
   int sent = 0;
-  struct UNIXMessageWrapper * msgw = plugin->msg_head;
 
+
+  struct UNIXMessageWrapper * msgw = plugin->msg_tail;
+  while (NULL != msgw)
+  {
+      if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value > 0)
+        break; /* Message is ready for sending */
+      else
+      {
+          /* Message has a timeout */
+          GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, 
msgw);
+          if (NULL != msgw->cont)
+            msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR, 
msgw->payload, 0);
+
+          plugin->bytes_in_queue -= msgw->msgsize;
+          GNUNET_STATISTICS_set (plugin->env->stats, "# bytes currently in 
UNIX buffers",
+              plugin->bytes_in_queue, GNUNET_NO);
+
+          plugin->bytes_discarded += msgw->msgsize;
+          GNUNET_STATISTICS_set (plugin->env->stats,"# UNIX bytes discarded",
+              plugin->bytes_discarded, GNUNET_NO);
+
+          GNUNET_free (msgw->msg);
+          GNUNET_free (msgw);
+      }
+      msgw = plugin->msg_tail;
+  }
+  if (NULL == msgw)
+    return; /* Nothing to send at the moment */
+
   sent = unix_real_send (plugin,
                          plugin->unix_sock.desc,
                          &msgw->session->target,
@@ -965,8 +993,6 @@
     GNUNET_free (msgw);
     return;
   }
-
-
 }
 
 

Modified: gnunet/src/transport/test_transport_api_unreliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_unreliability.c     2012-11-14 
13:57:58 UTC (rev 24954)
+++ gnunet/src/transport/test_transport_api_unreliability.c     2012-11-14 
14:09:43 UTC (rev 24955)
@@ -447,7 +447,7 @@
 sendtask ()
 {
   start_time = GNUNET_TIME_absolute_get ();
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Starting to send %u messages\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting to send %u messages\n",
               TOTAL_MSGS);
   th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, get_size (0), 
0,
                                                TIMEOUT_TRANSMIT, &notify_ready,




reply via email to

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