[ros-diffs] [cgutman] 44199: - Implement OskitTCPGetSocketError which retreives so->so_error - Use OskitTCPGetSocketError to get the actual socket error which occurred when get SEL_FIN - Add more cases to TCPTranslateError

cgutman at svn.reactos.org cgutman at svn.reactos.org
Mon Nov 16 08:39:52 CET 2009


Author: cgutman
Date: Mon Nov 16 08:39:52 2009
New Revision: 44199

URL: http://svn.reactos.org/svn/reactos?rev=44199&view=rev
Log:
 - Implement OskitTCPGetSocketError which retreives so->so_error
 - Use OskitTCPGetSocketError to get the actual socket error which occurred when get SEL_FIN
 - Add more cases to TCPTranslateError

Modified:
    trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
    trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h
    trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c

Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c?rev=44199&r1=44198&r2=44199&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Mon Nov 16 08:39:52 2009
@@ -27,6 +27,7 @@
     PLIST_ENTRY Entry;
     PIRP Irp;
     PMDL Mdl;
+    ULONG SocketError;
 
     KeAcquireSpinLock(&ConnectionEndpointListLock, &OldIrql);
     CurrentEntry = ConnectionEndpointListHead.Flink;
@@ -44,8 +45,19 @@
                                Connection, Connection->SocketContext));
 
         if( !Connection->SocketContext || Connection->SignalState & SEL_FIN ) {
+            TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
+
+            Connection->SignalState = 0;
+
+            /* If OskitTCP initiated the disconnect, try to read the socket error that occurred */
+            if (Connection->SocketContext)
+                SocketError = TCPTranslateError(OskitTCPGetSocketError(Connection->SocketContext));
+
+            /* Default to STATUS_CANCELLED if we initiated the disconnect or no socket error was reported */
+            if (!Connection->SocketContext || !SocketError)
+                SocketError = STATUS_CANCELLED;
+
             KeReleaseSpinLock(&Connection->Lock, OldIrql);
-            TI_DbgPrint(DEBUG_TCP, ("EOF From socket\n"));
 
             while ((Entry = ExInterlockedRemoveHeadList( &Connection->ReceiveRequest,
                                                          &Connection->Lock )) != NULL)
@@ -53,7 +65,7 @@
                Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
                Complete = Bucket->Request.RequestNotifyObject;
 
-               Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+               Complete( Bucket->Request.RequestContext, SocketError, 0 );
 
                exFreePool(Bucket);
             }
@@ -64,7 +76,7 @@
                Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
                Complete = Bucket->Request.RequestNotifyObject;
 
-               Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+               Complete( Bucket->Request.RequestContext, SocketError, 0 );
 
                exFreePool(Bucket);
             }
@@ -75,7 +87,7 @@
                Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
                Complete = Bucket->Request.RequestNotifyObject;
 
-               Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+               Complete( Bucket->Request.RequestContext, SocketError, 0 );
 
                exFreePool(Bucket);
             }
@@ -86,7 +98,7 @@
                Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry );
                Complete = Bucket->Request.RequestNotifyObject;
 
-               Complete( Bucket->Request.RequestContext, STATUS_CANCELLED, 0 );
+               Complete( Bucket->Request.RequestContext, SocketError, 0 );
 
                exFreePool(Bucket);
             }
@@ -573,8 +585,9 @@
     case 0: Status = STATUS_SUCCESS; break;
     case OSK_EADDRNOTAVAIL: Status = STATUS_INVALID_ADDRESS; break;
     case OSK_EAFNOSUPPORT: Status = STATUS_INVALID_CONNECTION; break;
-    case OSK_ECONNREFUSED:
-    case OSK_ECONNRESET: Status = STATUS_REMOTE_NOT_LISTENING; break;
+    case OSK_ECONNREFUSED: Status = STATUS_REMOTE_NOT_LISTENING; break;
+    case OSK_ECONNRESET:
+    case OSK_ECONNABORTED: Status = STATUS_REMOTE_DISCONNECT; break;
     case OSK_EWOULDBLOCK:
     case OSK_EINPROGRESS: Status = STATUS_PENDING; break;
     case OSK_EINVAL: Status = STATUS_INVALID_PARAMETER; break;

Modified: trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h?rev=44199&r1=44198&r2=44199&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/include/oskittcp.h [iso-8859-1] Mon Nov 16 08:39:52 2009
@@ -164,6 +164,8 @@
 
 int OskitTCPDisconnect(void *socket);
 
+int OskitTCPGetSocketError(void *socket);
+
 #undef errno
 
 void *fbsd_malloc( unsigned int bytes, char *file, unsigned line, ... );

Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c?rev=44199&r1=44198&r2=44199&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] Mon Nov 16 08:39:52 2009
@@ -595,6 +595,20 @@
     return 0;
 }
 
+int OskitTCPGetSocketError(void *socket) {
+    struct socket *so = socket;
+    int error;
+
+    if (!socket)
+        return OSK_ESHUTDOWN;
+
+    OSKLock();
+    error = so->so_error;
+    OSKUnlock();
+
+    return error;
+}
+
 struct ifaddr *ifa_iffind(struct sockaddr *addr, int type)
 {
     if( OtcpEvent.FindInterface )




More information about the Ros-diffs mailing list