Commit in reactos/lib on MAIN
ws2_32/misc/catalog.c+21.13 -> 1.14
           /dllmain.c+22-101.19 -> 1.20
           /sndrcv.c+8-11.11 -> 1.12
           /upcall.c+5-21.6 -> 1.7
msafd/misc/dllmain.c+113-121.22 -> 1.23
+150-25
5 modified files
Added some extra printing.
Fixed numerous places where we assume lpErrno is non-null. 

reactos/lib/ws2_32/misc
catalog.c 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- catalog.c	15 Jul 2004 02:03:07 -0000	1.13
+++ catalog.c	18 Dec 2004 23:09:25 -0000	1.14
@@ -22,6 +22,8 @@
     //EnterCriticalSection(&Provider->Lock);
     Provider->ReferenceCount++;
     //LeaveCriticalSection(&Provider->Lock);
+
+    WS_DbgPrint(MAX_TRACE, ("Leaving\n"));
 }
 
 

reactos/lib/ws2_32/misc
dllmain.c 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- dllmain.c	25 Nov 2004 23:32:54 -0000	1.19
+++ dllmain.c	18 Dec 2004 23:09:25 -0000	1.20
@@ -239,18 +239,25 @@
 
   assert(Provider->ProcTable.lpWSPSocket);
 
+  WS_DbgPrint(MAX_TRACE,("About to call provider socket fn\n"));
+
   Socket = Provider->ProcTable.lpWSPSocket(
-    af,
-    type,
-    protocol,
-    lpProtocolInfo,
-    g,
-    dwFlags,
-    &Status);
-	if (Status != NO_ERROR) {
-    WSASetLastError(Status);
-    return INVALID_SOCKET;
+      af,
+      type,
+      protocol,
+      lpProtocolInfo,
+      g,
+      dwFlags,
+      &Status);
+
+  WS_DbgPrint(MAX_TRACE,("Socket: %x, Status: %x\n", Socket, Status));
+
+  if (Status != NO_ERROR) {
+      WSASetLastError(Status);
+      return INVALID_SOCKET;
   }
+  
+  WS_DbgPrint(MAX_TRACE,("Status: %x\n", Status));
 
   return Socket;
 }
@@ -531,9 +538,14 @@
     return SOCKET_ERROR;
   }
 
+  WS_DbgPrint(MAX_TRACE,("Calling provider accept\n"));
+
   Socket = Provider->ProcTable.lpWSPAccept(
     s, addr, addrlen, lpfnCondition, dwCallbackData, &Errno);
 
+  WS_DbgPrint(MAX_TRACE,("Calling provider accept -> Socket %x, Errno %x\n",
+			 Socket, Errno));
+
   DereferenceProviderByPointer(Provider);
 
   if (Socket == INVALID_SOCKET) {

reactos/lib/ws2_32/misc
sndrcv.c 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- sndrcv.c	23 Sep 2004 08:16:16 -0000	1.11
+++ sndrcv.c	18 Dec 2004 23:09:25 -0000	1.12
@@ -8,6 +8,7 @@
  *   CSH 01/09-2000 Created
  */
 
+#include <roscfg.h>
 #include <w32api.h>
 #include <ws2_32.h>
 #include <catalog.h>
@@ -93,7 +94,13 @@
 
   Error = WSASend(s, &WSABuf, 1, &BytesSent, flags, NULL, NULL);
 
-  if( Error ) return -1; else return BytesSent;
+  if( Error ) {
+      WS_DbgPrint(MAX_TRACE,("Reporting error %d\n", Error));
+      return -1; 
+  } else {
+      WS_DbgPrint(MAX_TRACE,("Read %d bytes\n", BytesSent));
+      return BytesSent;
+  }
 }
 
 

reactos/lib/ws2_32/misc
upcall.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- upcall.c	15 Jul 2004 02:03:07 -0000	1.6
+++ upcall.c	18 Dec 2004 23:09:25 -0000	1.7
@@ -7,6 +7,7 @@
  * REVISIONS:
  *   CSH 01/09-2000 Created
  */
+#include <roscfg.h>
 #include <ws2_32.h>
 #include <catalog.h>
 #include <handle.h>
@@ -138,7 +139,8 @@
   if (!Provider) {
     WS_DbgPrint(MIN_TRACE, ("Provider with catalog entry id (%d) was not found.\n",
       dwCatalogEntryId));
-    *lpErrno = WSAEINVAL;
+    if( lpErrno ) *lpErrno = WSAEINVAL;
+    WS_DbgPrint(MID_TRACE, ("Returning invalid socket\n"));
     return INVALID_SOCKET;
   }
 
@@ -146,8 +148,9 @@
     (HANDLE)ProposedHandle,
     Provider);
 
-  *lpErrno = NO_ERROR;
+  if( lpErrno ) *lpErrno = NO_ERROR;
 
+  WS_DbgPrint(MID_TRACE, ("Socket: %x\n", Socket));
   return Socket;
 }
 

reactos/lib/msafd/misc
dllmain.c 1.22 -> 1.23
diff -u -r1.22 -r1.23
--- dllmain.c	11 Dec 2004 14:59:32 -0000	1.22
+++ dllmain.c	18 Dec 2004 23:09:30 -0000	1.23
@@ -253,7 +253,7 @@
 error:
 	AFD_DbgPrint(MID_TRACE,("Ending\n"));
 
-        *lpErrno = Status;
+        if( lpErrno ) *lpErrno = Status;
 
 	return INVALID_SOCKET;
 }
@@ -269,7 +269,10 @@
 	if( ReturnedBytes ) *ReturnedBytes = Received; break;
     case STATUS_PENDING: *Errno = WSA_IO_PENDING; break;
     case STATUS_BUFFER_OVERFLOW: *Errno = WSAEMSGSIZE; break;
-    default: *Errno = WSAEINVAL; break;
+    default: {
+	DbgPrint("MSAFD: Error %d is unknown\n", Errno);
+	*Errno = WSAEINVAL; break;
+    } break;
     }
 
     /* Success */
@@ -545,6 +548,8 @@
 					PollInfo->Handles[i].Handle));
 		OutCount++;
 		if( readfds ) FD_SET(PollInfo->Handles[i].Handle, readfds);
+		break;
+
 	    case AFD_EVENT_SEND: case AFD_EVENT_CONNECT:
 		AFD_DbgPrint(MID_TRACE,("Event %x on handle %x\n",
 					PollInfo->Handles[i].Events,
@@ -566,10 +571,14 @@
 
     NtClose( SockEvent );
 
-    switch( IOSB.Status ) {
-    case STATUS_SUCCESS: 
-    case STATUS_TIMEOUT: *lpErrno = 0; break;
-    default: *lpErrno = WSAEINVAL;
+    AFD_DbgPrint(MID_TRACE,("lpErrno = %x\n", lpErrno));
+
+    if( lpErrno ) {
+	switch( IOSB.Status ) {
+	case STATUS_SUCCESS: 
+	case STATUS_TIMEOUT: *lpErrno = 0; break;
+	default: *lpErrno = WSAEINVAL; break;
+	}
     }
 
     AFD_DbgPrint(MID_TRACE,("%d events\n", OutCount));
@@ -608,25 +617,43 @@
 	UCHAR						ReceiveBuffer[0x1A];
 	HANDLE                                  SockEvent;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+	
 	Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
 				NULL, 1, FALSE );
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	if( !NT_SUCCESS(Status) ) return -1;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Dynamic Structure...ugh */
 	ListenReceiveData = (PAFD_RECEIVED_ACCEPT_DATA)ReceiveBuffer;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Get the Socket Structure associate to this Socket*/
 	Socket = GetSocketStructure(Handle);
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* If this is non-blocking, make sure there's something for us to accept */
 	FD_ZERO(&ReadSet);
 	FD_SET(Socket->Handle, &ReadSet);
 	Timeout.tv_sec=0;
 	Timeout.tv_usec=0;
+
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	WSPSelect(0, &ReadSet, NULL, NULL, &Timeout, NULL);
+
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	if (ReadSet.fd_array[0] != Socket->Handle) return 0;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Send IOCTL */
 	Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
 					SockEvent,
@@ -639,14 +666,24 @@
 					ListenReceiveData,
 					0xA + sizeof(*ListenReceiveData));
 	
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	if (lpfnCondition != NULL) {
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		if ((Socket->SharedData.ServiceFlags1 & XP1_CONNECT_DATA) != 0) {
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			/* Find out how much data is pending */
 			PendingAcceptData.SequenceNumber = ListenReceiveData->SequenceNumber;
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			PendingAcceptData.ReturnSize = TRUE;
 
 			/* Send IOCTL */
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
 							SockEvent,
 							NULL,
@@ -658,18 +695,28 @@
 							&PendingAcceptData,
 							sizeof(PendingAcceptData));
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			/* How much data to allocate */
 			PendingDataLength = IOSB.Information;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			if (PendingDataLength) {
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 				/* Allocate needed space */
 				PendingData = HeapAlloc(GlobalHeap, 0, PendingDataLength);
 
 				/* We want the data now */
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 				PendingAcceptData.ReturnSize = FALSE;
 
 				/* Send IOCTL */
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 				Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
 								SockEvent,
 								NULL,
@@ -680,46 +727,70 @@
 								sizeof(PendingAcceptData),
 								PendingData,
 								PendingDataLength);
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			}
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		}
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
 		
 		if ((Socket->SharedData.ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) {
 			/* I don't support this yet */
+	AFD_DbgPrint(MID_TRACE,("\n"));
 		}
 		
 		/* Build Callee ID */
 		CalleeID.buf = (PVOID)Socket->LocalAddress;
 		CalleeID.len = Socket->SharedData.SizeOfLocalAddress;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		/* Set up Address in SOCKADDR Format */
 		RtlCopyMemory (RemoteAddress, 
 						&ListenReceiveData->Address.Address[0].AddressType, 
 						sizeof(RemoteAddress));
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		/* Build Caller ID */
 		CallerID.buf = (PVOID)RemoteAddress;
 		CallerID.len = sizeof(RemoteAddress);
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		/* Build Caller Data */
 		CallerData.buf = PendingData;
 		CallerData.len = PendingDataLength;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		/* Check if socket supports Conditional Accept */
 		if (Socket->SharedData.UseDelayedAcceptance != 0) {
 			
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			/* Allocate Buffer for Callee Data */
 			CalleeDataBuffer = HeapAlloc(GlobalHeap, 0, 4096);
 			CalleeData.buf = CalleeDataBuffer;
 			CalleeData.len = 4096;
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		} else {
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			/* Nothing */
 			CalleeData.buf = 0;
 			CalleeData.len = 0;
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		}
 	
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		/* Call the Condition Function */
 		CallBack = (lpfnCondition)( &CallerID,
 						CallerData.buf == NULL
@@ -733,26 +804,35 @@
 						: & CalleeData,
 						&GroupID,
 						dwCallbackData);
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 
 		if (((CallBack == CF_ACCEPT) && GroupID) != 0) {
 			/* TBD: Check for Validity */
+	AFD_DbgPrint(MID_TRACE,("\n"));
 		}
 
 		if (CallBack == CF_ACCEPT) {
 
 			if ((Socket->SharedData.ServiceFlags1 & XP1_QOS_SUPPORTED) != 0) {
 				/* I don't support this yet */
+	AFD_DbgPrint(MID_TRACE,("\n"));
 			}
 
 			if (CalleeData.buf) {
 				// SockSetConnectData Sockets(SocketID), IOCTL_AFD_SET_CONNECT_DATA, CalleeData.Buffer, CalleeData.BuffSize, 0
+	AFD_DbgPrint(MID_TRACE,("\n"));
 			}
 		
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 		} else {
 			/* Callback rejected. Build Defer Structure */
 			DeferData.SequenceNumber = ListenReceiveData->SequenceNumber;
 			DeferData.RejectConnection = (CallBack == CF_REJECT);
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			/* Send IOCTL */
 			Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
 							SockEvent,
@@ -765,32 +845,47 @@
 							NULL,
 							0);
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			NtClose( SockEvent );
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 			if (CallBack == CF_REJECT ) {
+	AFD_DbgPrint(MID_TRACE,("\n"));
 				return WSAECONNREFUSED;
 			} else {
+	AFD_DbgPrint(MID_TRACE,("\n"));
 				return WSATRY_AGAIN;
 			}
 		}
 	}
 	
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Create a new Socket */
 	ProtocolInfo.dwCatalogEntryId = Socket->SharedData.CatalogEntryId;
 	ProtocolInfo.dwServiceFlags1 = Socket->SharedData.ServiceFlags1;
 	ProtocolInfo.dwProviderFlags = Socket->SharedData.ProviderFlags;
+
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	AcceptSocket = WSPSocket (Socket->SharedData.AddressFamily,
-								Socket->SharedData.SocketType, 
-								Socket->SharedData.Protocol, 
-								&ProtocolInfo,
-								GroupID, 
-								Socket->SharedData.CreateFlags, 
-								NULL);
+				  Socket->SharedData.SocketType, 
+				  Socket->SharedData.Protocol, 
+				  &ProtocolInfo,
+				  GroupID, 
+				  Socket->SharedData.CreateFlags, 
+				  NULL);
+
+	AFD_DbgPrint(MID_TRACE,("\n"));
 
 	/* Set up the Accept Structure */
    	AcceptData.ListenHandle = AcceptSocket;
 	AcceptData.SequenceNumber = ListenReceiveData->SequenceNumber;
     
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Send IOCTL to Accept */
 	Status = NtDeviceIoControlFile( (HANDLE)Socket->Handle,
 					SockEvent,
@@ -803,13 +898,19 @@
 					NULL,
 					0);
 	
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	/* Return Address in SOCKADDR FORMAT */
 	RtlCopyMemory (SocketAddress, 
 					&ListenReceiveData->Address.Address[0].AddressType, 
 					sizeof(RemoteAddress));
 
+	AFD_DbgPrint(MID_TRACE,("\n"));
+
 	NtClose( SockEvent );
 
+	AFD_DbgPrint(MID_TRACE,("Socket %x\n", AcceptSocket));
+
 	/* Return Socket */
 	return AcceptSocket;
 }
CVSspam 0.2.8