gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r570 - GNUnet/src/transports


From: grothoff
Subject: [GNUnet-SVN] r570 - GNUnet/src/transports
Date: Fri, 1 Apr 2005 22:23:09 -0800 (PST)

Author: grothoff
Date: 2005-04-01 22:23:07 -0800 (Fri, 01 Apr 2005)
New Revision: 570

Modified:
   GNUnet/src/transports/tcp.c
   GNUnet/src/transports/tcp6.c
Log:
msg

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2005-04-02 06:17:42 UTC (rev 569)
+++ GNUnet/src/transports/tcp.c 2005-04-02 06:23:07 UTC (rev 570)
@@ -36,6 +36,8 @@
  */
 #define TCP_TIMEOUT (30 * cronSECONDS)
 
+#define TARGET_BUFFER_SIZE 2048
+
 /**
  * Host-Address in a TCP network.
  */
@@ -1187,9 +1189,16 @@
         size);
   mp->size = htons(size);
   mp->reserved = 0;
-  ok = tcpDirectSend(tsession->internal,
-                    mp,
-                    size + sizeof(TCPMessagePack));
+  /* if we would have less than 2k in buffers,
+     do reliable send */
+  if (((TCPSession*)tsession->internal)->wpos + size < TARGET_BUFFER_SIZE)
+    ok = tcpDirectSendReliable(tsession->internal,
+                              mp,
+                              size + sizeof(TCPMessagePack));
+  else
+    ok = tcpDirectSend(tsession->internal,
+                      mp,
+                      size + sizeof(TCPMessagePack));
   FREE(mp);
   return ok;
 }

Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c        2005-04-02 06:17:42 UTC (rev 569)
+++ GNUnet/src/transports/tcp6.c        2005-04-02 06:23:07 UTC (rev 570)
@@ -36,6 +36,8 @@
  */
 #define TCP6_TIMEOUT 30 * cronSECONDS
 
+#define TARGET_BUFFER_SIZE 2048
+
 /**
  * @brief Host-Address in a TCP6 network.
  */
@@ -851,6 +853,7 @@
     GROW(tcp6Session->wbuff,
         tcp6Session->wpos,
         tcp6Session->wpos + ssize);
+    tcp6Session->wpos += ssize;
     memcpy(&tcp6Session->wbuff[old],
           mp,
           ssize);
@@ -1131,9 +1134,14 @@
         size);
   mp->size = htons(size);
   mp->reserved = 0;
-  ok = tcp6DirectSend(tsession->internal,
-                     mp,
-                     size + sizeof(TCP6MessagePack));
+  if (((TCPSession*)tsession->internal)->wpos + size < TARGET_BUFFER_SIZE)
+    ok = tcp6DirectSendReliable(tsession->internal,
+                               mp,
+                               size + sizeof(TCP6MessagePack));
+  else
+    ok = tcp6DirectSend(tsession->internal,
+                       mp,
+                       size + sizeof(TCP6MessagePack));
   FREE(mp);
   return ok;
 }





reply via email to

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