Author: zhu
Date: Wed Aug  3 22:00:57 2016
New Revision: 72106

URL: http://svn.reactos.org/svn/reactos?rev=72106&view=rev
Log:
Mostly fully working TCP. Occasional crash due to faulty mbox implementation in 
sys_arch.c.

Modified:
    branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c
    branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c
    branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h
    branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/tcp.c
    branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/lwip/src/include/lwip/tcp.h

Modified: 
branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c?rev=72106&r1=72105&r2=72106&view=diff
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c    
[iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/base/applications/network/tcpclient/main.c    
[iso-8859-1] Wed Aug  3 22:00:57 2016
@@ -3,7 +3,7 @@
 #include <winsock2.h>
 
 #define LENGTH 255
-#define NUM_CLIENTS 1
+#define NUM_CLIENTS 32
 
 DWORD WINAPI ClientThreadMain(LPVOID lpParam) {
     SOCKET Sock;

Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c?rev=72106&r1=72105&r2=72106&view=diff
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c       
[iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c       
[iso-8859-1] Wed Aug  3 22:00:57 2016
@@ -16,9 +16,9 @@
 volatile long int GlContextCount;
 volatile long int PcbCount;
 
-PADDRESS_FILE AddrFileArray[16];
-PTCP_CONTEXT ContextArray[16];
-struct tcp_pcb *PCBArray[16];
+PADDRESS_FILE AddrFileArray[128];
+PTCP_CONTEXT ContextArray[128];
+struct tcp_pcb *PCBArray[128];
 
 KSPIN_LOCK AddrFileArrayLock;
 KSPIN_LOCK ContextArrayLock;
@@ -237,7 +237,7 @@
  * ADDRESS_FILE. This mutex guards against concurrent access from multiple 
execution contexts if and
  * only if the Context is associated with an Address File. If 
TcpIpAssociateAddress has been called
  * on a TCP_CONTEXT struct, this mutex should be held when reading from or 
writing to any and all
- * fields in the struct until TcpIpDisassociateAddress is call on the same 
struct. 
+ * fields in the struct until TcpIpDisassociateAddress is called on the same 
struct. 
  * 
  * Mutex acquisition returns TRUE if the mutex has been acquired. Returns 
FALSE if the mutex could
  * not be acquired due to the Context having no association to any Address 
File.
@@ -374,10 +374,10 @@
 {
     NTSTATUS Status;
 
-    /* Check that the IRP was not already cancelled */
+    /* Check that the IRP was not already canceled */
     if (Irp->Cancel)
     {
-        DPRINT("IRP already cancelled\n");
+        DPRINT("IRP already canceled\n");
         Irp->IoStatus.Status = STATUS_CANCELLED;
         Irp->IoStatus.Information = 0;
         return STATUS_CANCELLED;
@@ -495,7 +495,7 @@
             }
             goto COMPLETE_IRP;
         case TCP_REQUEST_CANCEL_MODE_PRESERVE :
-            /* For requests that do not deallocate the PCB when cancelled, 
determine and clear the
+            /* For requests that do not deallocate the PCB when canceled, 
determine and clear the
              * appropriate TCP State bit */
             switch (Request->PendingMode)
             {
@@ -549,7 +549,15 @@
     PTCP_CONTEXT Context;
     PTCP_REQUEST Request;
 
+    /* Check that the IRP isn't already being canceled */
+    if (Irp->Cancel == TRUE)
+    {
+        IoReleaseCancelSpinLock(Irp->CancelIrql);
+        return;
+    }
+    
     /* Block potential repeated cancellations */
+    Irp->Cancel = TRUE;
     IoSetCancelRoutine(Irp, NULL);
 
     /* This function is always called with the Cancel lock held */
@@ -2085,6 +2093,7 @@
 
         /* Block potential cancellations */
         Irp = Request->Payload.PendingIrp;
+        Irp->Cancel = TRUE;
         IoSetCancelRoutine(Irp, NULL);
 
         /* Dequeue Request and increment list walk */
@@ -2199,6 +2208,7 @@
     Irp = Request->Payload.PendingIrp;
 
     /* Block cancellations */
+    Irp->Cancel = TRUE;
     IoSetCancelRoutine(Irp, NULL);
 
     /* One last sanity check */
@@ -2448,6 +2458,7 @@
             /* Found a matching request. Block cancellations, dequeue,
              * and break out of the list walk. */
             Irp = Request->Payload.PendingIrp;
+            Irp->Cancel = TRUE;
             IoSetCancelRoutine(Irp, NULL);
             RemoveEntryList(&Request->ListEntry);
             goto FOUND;
@@ -2563,6 +2574,7 @@
         {
             /* Immediately block any cancellations */
             Irp = Request->Payload.PendingIrp;
+            Irp->Cancel = TRUE;
             IoSetCancelRoutine(Irp, NULL);
 
             /* Dequeue the entry and jump to handler */

Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h?rev=72106&r1=72105&r2=72106&view=diff
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h       
[iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h       
[iso-8859-1] Wed Aug  3 22:00:57 2016
@@ -31,7 +31,7 @@
 //#define TCPIP_NDEBUG
 #ifndef TCPIP_NDEBUG
 KSPIN_LOCK IRPArrayLock;
-PIRP IRPArray[16];
+PIRP IRPArray[256];
 volatile long int IRPCount;
 
 #define ADD_IRP(Irp) \
@@ -81,7 +81,7 @@
     KeReleaseSpinLockFromDpcLevel(&IRPArrayLock)
 
 KSPIN_LOCK IRPSPArrayLock;
-PIO_STACK_LOCATION IRPSPArray[16];
+PIO_STACK_LOCATION IRPSPArray[256];
 volatile long int IRPSPCount;
 
 #define ADD_IRPSP(IrpSp) \
@@ -255,4 +255,4 @@
 AddressSetTtl(
     _In_ TDIEntityID ID,
     _In_ PVOID InBuffer,
-    _In_ ULONG BufferSize);
+    _In_ ULONG BufferSize);

Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/tcp.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/tcp.c?rev=72106&r1=72105&r2=72106&view=diff
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/tcp.c   [iso-8859-1] 
(original)
+++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/tcp.c   [iso-8859-1] 
Wed Aug  3 22:00:57 2016
@@ -59,6 +59,7 @@
     else
         *PortNumber = Bit;
     PortNumberHint = *PortNumber;
+       KeReleaseSpinLock(&PortBitmapSpinlock, OldIrql);
     return FALSE;
 }
 

Modified: 
branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/lwip/src/include/lwip/tcp.h
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/lwip/src/include/lwip/tcp.h?rev=72106&r1=72105&r2=72106&view=diff
==============================================================================
--- branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/lwip/src/include/lwip/tcp.h   
[iso-8859-1] (original)
+++ branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/lwip/src/include/lwip/tcp.h   
[iso-8859-1] Wed Aug  3 22:00:57 2016
@@ -373,7 +373,12 @@
  * Serializes all kernel network activity to circumvent lwIP core's lack of 
thread-safety.
  */
 KMUTEX MTSerialMutex;
-
+#define ACQUIRE_SERIAL_MUTEX() \
+    KeWaitForMutexObject(&MTSerialMutex, Executive, KernelMode, FALSE, NULL)
+
+#define RELEASE_SERIAL_MUTEX() \
+    KeReleaseMutex(&MTSerialMutex, FALSE)
+/*
 #define ACQUIRE_SERIAL_MUTEX() \
     DPRINT("Acquiring MTSerialMutex on thread %p\n", PsGetCurrentThreadId()); \
     KeWaitForMutexObject(&MTSerialMutex, Executive, KernelMode, FALSE, NULL); \
@@ -383,7 +388,7 @@
     DPRINT("Releasing MTSerialMutex on thread %p\n", PsGetCurrentThreadId()); \
     KeReleaseMutex(&MTSerialMutex, FALSE); \
     DPRINT("MTSerialMutex released on thread %p\n", PsGetCurrentThreadId())
-
+*/
 const char* tcp_debug_state_str(enum tcp_state s);
 
 #ifdef __cplusplus


Reply via email to