[ros-diffs] [tfaber] 53957: [MSAFD] - More consistent error handling in WSPConnect - Fix a DPRINT

tfaber at svn.reactos.org tfaber at svn.reactos.org
Mon Oct 3 15:01:48 UTC 2011


Author: tfaber
Date: Mon Oct  3 15:01:48 2011
New Revision: 53957

URL: http://svn.reactos.org/svn/reactos?rev=53957&view=rev
Log:
[MSAFD]
- More consistent error handling in WSPConnect
- Fix a DPRINT

Modified:
    trunk/reactos/dll/win32/msafd/misc/dllmain.c
    trunk/reactos/dll/win32/msafd/msafd.h

Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllmain.c?rev=53957&r1=53956&r2=53957&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Oct  3 15:01:48 2011
@@ -1434,6 +1434,7 @@
     PAFD_CONNECT_INFO       ConnectInfo;
     PSOCKET_INFORMATION     Socket = NULL;
     NTSTATUS                Status;
+    INT                     Errno;
     UCHAR                   ConnectBuffer[0x22];
     ULONG                   ConnectDataLength;
     ULONG                   InConnectDataLength;
@@ -1447,8 +1448,8 @@
                            1,
                            FALSE);
 
-    if( !NT_SUCCESS(Status) )
-        return -1;
+    if (!NT_SUCCESS(Status))
+        return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
 
     AFD_DbgPrint(MID_TRACE,("Called\n"));
 
@@ -1456,9 +1457,9 @@
     Socket = GetSocketStructure(Handle);
     if (!Socket)
     {
-       NtClose(SockEvent);
-       *lpErrno = WSAENOTSOCK;
-       return SOCKET_ERROR;
+        NtClose(SockEvent);
+        if (lpErrno) *lpErrno = WSAENOTSOCK;
+        return SOCKET_ERROR;
     }
 
     /* Bind us First */
@@ -1469,15 +1470,15 @@
         BindAddress = HeapAlloc(GetProcessHeap(), 0, BindAddressLength);
         if (!BindAddress)
         {
-            MsafdReturnWithErrno( STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL );
-            return INVALID_SOCKET;
+            NtClose(SockEvent);
+            return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL);
         }
         Socket->HelperData->WSHGetWildcardSockaddr (Socket->HelperContext,
                                                     BindAddress,
                                                     &BindAddressLength);
         /* Bind it */
         if (WSPBind(Handle, BindAddress, BindAddressLength, lpErrno) == SOCKET_ERROR)
-            return INVALID_SOCKET;
+            return SOCKET_ERROR;
     }
 
     /* Set the Connect Data */
@@ -1618,38 +1619,38 @@
     /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
     SockReenableAsyncSelectEvent(Socket, FD_CONNECT);
 
-    NtClose( SockEvent );
+    NtClose(SockEvent);
 
     if (Status == STATUS_SUCCESS && (Socket->HelperEvents & WSH_NOTIFY_CONNECT))
     {
-        Status = Socket->HelperData->WSHNotify(Socket->HelperContext,
-                                               Socket->Handle,
-                                               Socket->TdiAddressHandle,
-                                               Socket->TdiConnectionHandle,
-                                               WSH_NOTIFY_CONNECT);
-
-        if (Status)
-        {
-            if (lpErrno) *lpErrno = Status;
+        Errno = Socket->HelperData->WSHNotify(Socket->HelperContext,
+                                              Socket->Handle,
+                                              Socket->TdiAddressHandle,
+                                              Socket->TdiConnectionHandle,
+                                              WSH_NOTIFY_CONNECT);
+
+        if (Errno)
+        {
+            if (lpErrno) *lpErrno = Errno;
             return SOCKET_ERROR;
         }
     }
     else if (Status != STATUS_SUCCESS && (Socket->HelperEvents & WSH_NOTIFY_CONNECT_ERROR))
     {
-        Status = Socket->HelperData->WSHNotify(Socket->HelperContext,
-                                               Socket->Handle,
-                                               Socket->TdiAddressHandle,
-                                               Socket->TdiConnectionHandle,
-                                               WSH_NOTIFY_CONNECT_ERROR);
-
-        if (Status)
-        {
-            if (lpErrno) *lpErrno = Status;
+        Errno = Socket->HelperData->WSHNotify(Socket->HelperContext,
+                                              Socket->Handle,
+                                              Socket->TdiAddressHandle,
+                                              Socket->TdiConnectionHandle,
+                                              WSH_NOTIFY_CONNECT_ERROR);
+
+        if (Errno)
+        {
+            if (lpErrno) *lpErrno = Errno;
             return SOCKET_ERROR;
         }
     }
 
-    return MsafdReturnWithErrno( Status, lpErrno, 0, NULL );
+    return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
 }
 int
 WSPAPI

Modified: trunk/reactos/dll/win32/msafd/msafd.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?rev=53957&r1=53956&r2=53957&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Mon Oct  3 15:01:48 2011
@@ -495,7 +495,7 @@
     }
     else
     {
-        DbgPrint("%s: Received invalid lpErrno pointer! %s\n", __FUNCTION__);
+        DbgPrint("%s: Received invalid lpErrno pointer!\n", __FUNCTION__);
 
         if (ReturnedBytes)
             *ReturnedBytes = (Status == STATUS_SUCCESS) ? Received : 0;




More information about the Ros-diffs mailing list