Author: cgutman
Date: Mon Jul 4 17:37:45 2011
New Revision: 52537
URL:
http://svn.reactos.org/svn/reactos?rev=52537&view=rev
Log:
[MSAFD/AFD]
- Pass the non-blocking information as a boolean (mswsock_new does this too)
[AFD]
- Don't block waiting for a connection to accept on a non-blocking listener
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
trunk/reactos/dll/win32/msafd/misc/event.c
trunk/reactos/dll/win32/msafd/misc/sndrcv.c
trunk/reactos/dll/win32/msafd/msafd.h
trunk/reactos/drivers/network/afd/afd/info.c
trunk/reactos/drivers/network/afd/afd/listen.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/write.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -264,7 +264,7 @@
/* Save Group Info */
if (g != 0)
{
- GetSocketInformation(Socket, AFD_INFO_GROUP_ID_TYPE, 0, &GroupData);
+ GetSocketInformation(Socket, AFD_INFO_GROUP_ID_TYPE, NULL, NULL,
&GroupData);
Socket->SharedData.GroupID = GroupData.u.LowPart;
Socket->SharedData.GroupType = GroupData.u.HighPart;
}
@@ -272,11 +272,13 @@
/* Get Window Sizes and Save them */
GetSocketInformation (Socket,
AFD_INFO_SEND_WINDOW_SIZE,
+ NULL,
&Socket->SharedData.SizeOfSendBuffer,
NULL);
GetSocketInformation (Socket,
AFD_INFO_RECEIVE_WINDOW_SIZE,
+ NULL,
&Socket->SharedData.SizeOfRecvBuffer,
NULL);
@@ -467,6 +469,7 @@
/* Find out how many Sends are in Progress */
if (GetSocketInformation(Socket,
AFD_INFO_SENDS_IN_PROGRESS,
+ NULL,
&SendsInProgress,
NULL))
{
@@ -1951,6 +1954,7 @@
{
PSOCKET_INFORMATION Socket = NULL;
BOOLEAN NeedsCompletion;
+ BOOLEAN NonBlocking;
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
@@ -1970,8 +1974,9 @@
*lpErrno = WSAEFAULT;
return SOCKET_ERROR;
}
- Socket->SharedData.NonBlocking = *((PULONG)lpvInBuffer) ? 1 : 0;
- *lpErrno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE,
(PULONG)lpvInBuffer, NULL);
+ NonBlocking = *((PULONG)lpvInBuffer) ? TRUE : FALSE;
+ Socket->SharedData.NonBlocking = NonBlocking ? 1 : 0;
+ *lpErrno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE,
&NonBlocking, NULL, NULL);
if (*lpErrno != NO_ERROR)
return SOCKET_ERROR;
else
@@ -1982,7 +1987,7 @@
*lpErrno = WSAEFAULT;
return SOCKET_ERROR;
}
- *lpErrno = GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE,
(PULONG)lpvOutBuffer, NULL);
+ *lpErrno = GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, NULL,
(PULONG)lpvOutBuffer, NULL);
if (*lpErrno != NO_ERROR)
return SOCKET_ERROR;
else
@@ -2258,6 +2263,7 @@
int
GetSocketInformation(PSOCKET_INFORMATION Socket,
ULONG AfdInformationClass,
+ PBOOLEAN Boolean OPTIONAL,
PULONG Ulong OPTIONAL,
PLARGE_INTEGER LargeInteger OPTIONAL)
{
@@ -2309,6 +2315,10 @@
{
*LargeInteger = InfoData.Information.LargeInteger;
}
+ if (Boolean != NULL)
+ {
+ *Boolean = InfoData.Information.Boolean;
+ }
NtClose( SockEvent );
@@ -2319,7 +2329,8 @@
int
SetSocketInformation(PSOCKET_INFORMATION Socket,
- ULONG AfdInformationClass,
+ ULONG AfdInformationClass,
+ PBOOLEAN Boolean OPTIONAL,
PULONG Ulong OPTIONAL,
PLARGE_INTEGER LargeInteger OPTIONAL)
{
@@ -2348,6 +2359,10 @@
if (LargeInteger != NULL)
{
InfoData.Information.LargeInteger = *LargeInteger;
+ }
+ if (Boolean != NULL)
+ {
+ InfoData.Information.Boolean = *Boolean;
}
AFD_DbgPrint(MID_TRACE,("XXX Info %x (Data %x)\n",
Modified: trunk/reactos/dll/win32/msafd/misc/event.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/event…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/event.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/event.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -26,7 +26,7 @@
AFD_EVENT_SELECT_INFO EventSelectInfo;
PSOCKET_INFORMATION Socket = NULL;
NTSTATUS Status;
- ULONG BlockMode;
+ BOOLEAN BlockMode;
HANDLE SockEvent;
Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
@@ -44,8 +44,8 @@
}
/* Set Socket to Non-Blocking */
- BlockMode = 1;
- SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL);
+ BlockMode = TRUE;
+ SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL);
Socket->SharedData.NonBlocking = TRUE;
/* Deactivate Async Select if there is one */
Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/sndrc…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -25,7 +25,7 @@
PSOCKET_INFORMATION Socket = NULL;
PASYNC_DATA AsyncData;
NTSTATUS Status;
- ULONG BlockMode;
+ BOOLEAN BlockMode;
/* Get the Socket Structure associated to this Socket */
Socket = GetSocketStructure(Handle);
@@ -44,8 +44,8 @@
}
/* Change the Socket to Non Blocking */
- BlockMode = 1;
- SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL);
+ BlockMode = TRUE;
+ SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL);
Socket->SharedData.NonBlocking = TRUE;
/* Deactive WSPEventSelect */
Modified: trunk/reactos/dll/win32/msafd/msafd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?re…
==============================================================================
--- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -417,14 +417,16 @@
int GetSocketInformation(
PSOCKET_INFORMATION Socket,
ULONG AfdInformationClass,
- PULONG Ulong OPTIONAL,
+ PBOOLEAN Boolean OPTIONAL,
+ PULONG Ulong OPTIONAL,
PLARGE_INTEGER LargeInteger OPTIONAL
);
int SetSocketInformation(
PSOCKET_INFORMATION Socket,
ULONG AfdInformationClass,
- PULONG Ulong OPTIONAL,
+ PBOOLEAN Boolean OPTIONAL,
+ PULONG Ulong OPTIONAL,
PLARGE_INTEGER LargeInteger OPTIONAL
);
Modified: trunk/reactos/drivers/network/afd/afd/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/in…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -48,7 +48,7 @@
break;
case AFD_INFO_BLOCKING_MODE:
- InfoReq->Information.Ulong = FCB->BlockingMode;
+ InfoReq->Information.Boolean = FCB->NonBlocking;
break;
case AFD_INFO_RECEIVE_CONTENT_SIZE:
@@ -115,8 +115,8 @@
_SEH2_TRY {
switch (InfoReq->InformationClass) {
case AFD_INFO_BLOCKING_MODE:
- AFD_DbgPrint(MID_TRACE,("Blocking mode set to %d\n",
InfoReq->Information.Ulong));
- FCB->BlockingMode = InfoReq->Information.Ulong;
+ AFD_DbgPrint(MID_TRACE,("Blocking mode set to %d\n",
InfoReq->Information.Boolean));
+ FCB->NonBlocking = InfoReq->Information.Boolean;
break;
default:
AFD_DbgPrint(MIN_TRACE,("Unknown request %d\n",
InfoReq->InformationClass));
Modified: trunk/reactos/drivers/network/afd/afd/listen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/li…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -315,6 +315,10 @@
SocketStateUnlock( FCB );
return Status;
+ } else if (FCB->NonBlocking) {
+ AFD_DbgPrint(MID_TRACE,("No connection ready on a non-blocking
socket\n"));
+
+ return UnlockAndMaybeComplete(FCB, STATUS_CANT_WAIT, Irp, 0);
} else {
AFD_DbgPrint(MID_TRACE,("Holding\n"));
Modified: trunk/reactos/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -346,7 +346,8 @@
Status = ReceiveActivity( FCB, Irp );
- if( Status == STATUS_PENDING && (RecvReq->AfdFlags & AFD_IMMEDIATE) )
{
+ if( Status == STATUS_PENDING &&
+ ((RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking)) ) {
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
TotalBytesCopied = 0;
@@ -690,7 +691,7 @@
return UnlockAndMaybeComplete
( FCB, Status, Irp, Irp->IoStatus.Information );
}
- } else if( RecvReq->AfdFlags & AFD_IMMEDIATE ) {
+ } else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) {
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
FCB->PollState &= ~AFD_EVENT_RECEIVE;
Modified: trunk/reactos/drivers/network/afd/afd/write.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/wr…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -340,7 +340,7 @@
AFD_DbgPrint(MID_TRACE,("Socket state %d\n", FCB->State));
if( FCB->State != SOCKET_STATE_CONNECTED ) {
- if( SendReq->AfdFlags & AFD_IMMEDIATE ) {
+ if( (SendReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) {
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
return UnlockAndMaybeComplete
@@ -404,7 +404,7 @@
else
{
FCB->PollState &= ~AFD_EVENT_SEND;
- if( SendReq->AfdFlags & AFD_IMMEDIATE ) {
+ if( (SendReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) {
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
return UnlockAndMaybeComplete
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Mon Jul 4 17:37:45 2011
@@ -173,8 +173,8 @@
} AFD_STORED_DATAGRAM, *PAFD_STORED_DATAGRAM;
typedef struct _AFD_FCB {
- BOOLEAN Locked, Critical, Overread;
- UINT State, Flags, BlockingMode, GroupID, GroupType;
+ BOOLEAN Locked, Critical, Overread, NonBlocking;
+ UINT State, Flags, GroupID, GroupType;
KIRQL OldIrql;
UINT LockCount;
PVOID CurrentThread;