Send delayed ACKs after 200ms instead of 2500ms
[reactos.git] / reactos / drivers / lib / ip / transport / tcp / event.c
index fe2d8e0..182f20a 100644 (file)
 
 #include "precomp.h"
 
-extern VOID DrainSignals();
-
 int TCPSocketState(void *ClientData,
-                  void *WhichSocket, 
+                  void *WhichSocket,
                   void *WhichConnection,
                   OSK_UINT NewState ) {
     PCONNECTION_ENDPOINT Connection = WhichConnection;
 
-    TI_DbgPrint(DEBUG_TCP,("Called: NewState %x (Conn %x) (Change %x)\n", 
+    TI_DbgPrint(MID_TRACE,("Flags: %c%c%c%c\n",
+                          NewState & SEL_CONNECT ? 'C' : 'c',
+                          NewState & SEL_READ    ? 'R' : 'r',
+                          NewState & SEL_FIN     ? 'F' : 'f',
+                          NewState & SEL_ACCEPT  ? 'A' : 'a'));
+
+    TI_DbgPrint(DEBUG_TCP,("Called: NewState %x (Conn %x) (Change %x)\n",
                           NewState, Connection,
-                          Connection ? Connection->State ^ NewState : 
+                          Connection ? Connection->State ^ NewState :
                           NewState));
 
     if( !Connection ) {
        TI_DbgPrint(DEBUG_TCP,("Socket closing.\n"));
        Connection = FileFindConnectionByContext( WhichSocket );
-       if( !Connection ) {
-           TcpipRecursiveMutexLeave( &TCPLock );
+       if( !Connection )
            return 0;
-       } else 
+       else
            TI_DbgPrint(DEBUG_TCP,("Found socket %x\n", Connection));
     }
 
+    TI_DbgPrint(MID_TRACE,("Connection signalled: %d\n",
+                          Connection->Signalled));
+
+    Connection->SignalState |= NewState;
     if( !Connection->Signalled ) {
        Connection->Signalled = TRUE;
-       Connection->SignalState = NewState;
        InsertTailList( &SignalledConnections, &Connection->SignalList );
     }
 
@@ -78,15 +84,15 @@ int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len ) {
        return OSK_EADDRNOTAVAIL;
     }
 
-    NdisStatus = AllocatePacketWithBuffer( &Packet.NdisPacket, NULL, 
+    NdisStatus = AllocatePacketWithBuffer( &Packet.NdisPacket, NULL,
                                           MaxLLHeaderSize + len );
-    
+
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
        TI_DbgPrint(DEBUG_TCP, ("Error from NDIS: %08x\n", NdisStatus));
-       return STATUS_NO_MEMORY;
+       return OSK_ENOBUFS;
     }
 
-    GetDataPtr( Packet.NdisPacket, MaxLLHeaderSize, 
+    GetDataPtr( Packet.NdisPacket, MaxLLHeaderSize,
                (PCHAR *)&Packet.Header, &Packet.ContigSize );
 
     RtlCopyMemory( Packet.Header, data, len );
@@ -97,7 +103,7 @@ int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len ) {
     Packet.DstAddr = RemoteAddress;
 
     IPSendDatagram( &Packet, NCE, TCPPacketSendComplete, NULL );
-    
+
     if( !NT_SUCCESS(NdisStatus) ) return OSK_EINVAL;
     else return 0;
 }
@@ -118,7 +124,7 @@ void TCPFree( void *ClientData,
 int TCPSleep( void *ClientData, void *token, int priority, char *msg,
              int tmio ) {
     PSLEEPING_THREAD SleepingThread;
-    
+
     TI_DbgPrint(DEBUG_TCP,
                ("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n",
                 token, priority, msg, tmio));