[enet-cvs] CVS: enet host.c,1.4,1.5 peer.c,1.5,1.6 protocol.c,1.4,1.5 unix.c,1.2,1.3

Lee Salzman enet-discuss@lists.puremagic.com
Sun, 28 Jul 2002 15:26:10 -0600


Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv3508

Modified Files:
	host.c peer.c protocol.c unix.c 
Log Message:
Disable throttle if connection variable is too high.



Index: host.c
===================================================================
RCS file: /home/enet/cvsroot/enet/host.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- host.c	2002/06/11 00:22:02	1.4
+++ host.c	2002/07/28 21:26:06	1.5
@@ -168,8 +168,8 @@
            dataTotal = 0,
            peersRemaining,
            bandwidth,
-           throttle,
-           bandwidthLimit;
+           throttle = 0,
+           bandwidthLimit = 0;
     int needsAdjustment;
     ENetPeer * peer;
     ENetProtocol command;

Index: peer.c
===================================================================
RCS file: /home/enet/cvsroot/enet/peer.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- peer.c	2002/06/11 00:22:02	1.5
+++ peer.c	2002/07/28 21:26:06	1.6
@@ -23,20 +23,24 @@
 }
 
 int
-enet_peer_throttle (ENetPeer * peer, uint32 statistic, uint32 mean, uint32 variance)
+enet_peer_throttle (ENetPeer * peer, uint32 rtt)
 {
-    if (mean > variance &&
-        statistic < mean - variance)
+    if (peer -> bestRoundTripTime <= peer -> roundTripTimeVariance)
     {
+        peer -> packetThrottle = peer -> packetThrottleLimit;
+    }
+    else
+    if (rtt < peer -> bestRoundTripTime - peer -> roundTripTimeVariance)
+    {
         peer -> packetThrottle += peer -> packetThrottleAcceleration;
 
         if (peer -> packetThrottle > peer -> packetThrottleLimit)
           peer -> packetThrottle = peer -> packetThrottleLimit;
-        
+
         return 1;
     }
     else
-    if (statistic > mean + variance)
+    if (rtt > peer -> bestRoundTripTime + peer -> roundTripTimeVariance)
     {
         if (peer -> packetThrottle > peer -> packetThrottleDeceleration)
           peer -> packetThrottle -= peer -> packetThrottleDeceleration;
@@ -44,7 +48,7 @@
           peer -> packetThrottle = 0;
 
         return -1;
-    }    
+    }
 
     return 0;
 }

Index: protocol.c
===================================================================
RCS file: /home/enet/cvsroot/enet/protocol.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- protocol.c	2002/06/11 00:22:02	1.4
+++ protocol.c	2002/07/28 21:26:06	1.5
@@ -394,7 +394,7 @@
     if (peer -> roundTripTime < peer -> bestRoundTripTime)
       peer -> bestRoundTripTime = peer -> roundTripTime;
 
-    enet_peer_throttle (peer, roundTripTime, peer -> bestRoundTripTime, peer -> roundTripTimeVariance);
+    enet_peer_throttle (peer, roundTripTime);
          
     receivedReliableSequenceNumber = ENET_NET_TO_HOST_32 (command -> acknowledge.receivedReliableSequenceNumber);
 
@@ -437,8 +437,6 @@
 {
     uint16 packetSize;
     uint32 windowSize;
-    size_t channelCount;
-    
 
     if (command -> header.commandLength < sizeof (ENetProtocolVerifyConnect))
       return;

Index: unix.c
===================================================================
RCS file: /home/enet/cvsroot/enet/unix.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- unix.c	2002/06/08 02:29:12	1.2
+++ unix.c	2002/07/28 21:26:06	1.3
@@ -92,8 +92,10 @@
 enet_socket_create (ENetSocketType type, const ENetAddress * address)
 {
     ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0);
-    int nonBlocking = 1,
-        receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE;
+    int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE;
+#ifndef HAS_FCNTL
+    int nonBlocking = 1;
+#endif
     struct sockaddr_in sin;
 
     if (newSocket == ENET_SOCKET_NULL)