error msg
[oweals/gnunet.git] / src / transport / plugin_transport_unix.c
index d9badf38030365eb9bbdead54d04d1b158ef1570..6e9d920ba06ce9445a1c79f24e742167437ef360 100644 (file)
@@ -548,8 +548,14 @@ resend:
 
   if (GNUNET_SYSERR == sent)
   {
-    if ((errno == EAGAIN) || (errno == ENOBUFS))
+    if (errno == EAGAIN)
+    {
+      return RETRY; /* We have to retry later  */
+    }
+    if (errno == ENOBUFS)
+    {
       return RETRY; /* We have to retry later  */
+    }
     if (errno == EMSGSIZE)
     {
       socklen_t size = 0;
@@ -584,6 +590,7 @@ resend:
       }
     }
   }
+
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "UNIX transmit %u-byte message to %s (%d: %s)\n",
               (unsigned int) msgbuf_size, GNUNET_a2s (sb, sbs), (int) sent,
@@ -734,7 +741,7 @@ unix_plugin_send (void *cls,
     return GNUNET_SYSERR;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u bytes with session for peer `%s' `%s'\n",
-               msgbuf_size,
+                msgbuf_size,
         GNUNET_i2s (&session->target),
         (char *) session->addr);
 
@@ -894,10 +901,8 @@ unix_plugin_select_read (struct Plugin * plugin)
 static void
 unix_plugin_select_write (struct Plugin * plugin)
 {
-  static int retry_counter = 0;
   int sent = 0;
 
-
   struct UNIXMessageWrapper * msgw = plugin->msg_tail;
   while (NULL != msgw)
   {
@@ -906,6 +911,8 @@ unix_plugin_select_write (struct Plugin * plugin)
       else
       {
           /* Message has a timeout */
+            LOG (GNUNET_ERROR_TYPE_DEBUG,
+              "Timeout for message with %llu bytes \n", msgw->msgsize);
           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);
@@ -938,21 +945,13 @@ unix_plugin_select_write (struct Plugin * plugin)
                          msgw->payload,
                          msgw->cont, msgw->cont_cls);
 
-  if (0 == sent)
+  if (RETRY == sent)
   {
-      retry_counter ++;
-      if (retry_counter <= MAX_RETRIES)
-      {
-        GNUNET_STATISTICS_update (plugin->env->stats,"# UNIX retry attempts",
-              1, GNUNET_NO);
-        return; /* retry */
-      }
-      else
-        sent = GNUNET_SYSERR; /* abort */
-  }
-  retry_counter = 0;
+    GNUNET_STATISTICS_update (plugin->env->stats,"# UNIX retry attempts",
+          1, GNUNET_NO);
 
-  if (GNUNET_SYSERR == sent)
+  }
+  else if (GNUNET_SYSERR == sent)
   {
     /* failed and no retry */
     if (NULL != msgw->cont)
@@ -972,8 +971,7 @@ unix_plugin_select_write (struct Plugin * plugin)
     GNUNET_free (msgw);
     return;
   }
-
-  else if (sent >= 0)
+  else if (sent > 0)
   {
     /* successfully sent bytes */
     if (NULL != msgw->cont)
@@ -1332,8 +1330,6 @@ libgnunet_plugin_transport_unix_init (void *cls)
     api->string_to_address = &unix_string_to_address;
     return api;
   }
-  GNUNET_assert( NULL != env->stats);
-
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-unix", "PORT",
                                              &port))