Revert r73068 and r73070

Current tests are obviously not enough to declare them OK.
I'll add more tests first

svn path=/trunk/; revision=73074
This commit is contained in:
Peter Hater 2016-10-30 05:58:02 +00:00
parent 78ad433718
commit 55d4688b34
3 changed files with 25 additions and 132 deletions

View file

@ -95,33 +95,13 @@ WSPSocket(int AddressFamily,
Protocol = SharedData->Protocol; Protocol = SharedData->Protocol;
} }
if (lpProtocolInfo) if (AddressFamily == AF_UNSPEC && SocketType == 0 && Protocol == 0)
{
if (lpProtocolInfo->iAddressFamily && AddressFamily <= 0)
AddressFamily = lpProtocolInfo->iAddressFamily;
if (lpProtocolInfo->iSocketType && SocketType <= 0)
SocketType = lpProtocolInfo->iSocketType;
if (lpProtocolInfo->iProtocol && Protocol <= 0)
Protocol = lpProtocolInfo->iProtocol;
}
/* FIXME: AF_NETDES should be AF_MAX */
if (AddressFamily < AF_UNSPEC || AddressFamily > AF_NETDES)
return WSAEINVAL;
if (SocketType < 0 && SocketType > SOCK_SEQPACKET)
return WSAEINVAL;
if (Protocol < 0 && Protocol > IPPROTO_MAX)
return WSAEINVAL;
/* when no protocol and socket type are specified the first entry
* from WSAEnumProtocols that has the flag PFL_MATCHES_PROTOCOL_ZERO
* is returned */
if (SocketType == 0 && Protocol == 0 && lpProtocolInfo && (lpProtocolInfo->dwProviderFlags & PFL_MATCHES_PROTOCOL_ZERO) == 0)
return WSAEINVAL; return WSAEINVAL;
/* Set the defaults */ /* Set the defaults */
if (AddressFamily == AF_UNSPEC)
AddressFamily = AF_INET;
if (SocketType == 0) if (SocketType == 0)
{ {
switch (Protocol) switch (Protocol)
@ -137,7 +117,8 @@ WSPSocket(int AddressFamily,
break; break;
default: default:
TRACE("Unknown Protocol (%d). We will try SOCK_STREAM.\n", Protocol); TRACE("Unknown Protocol (%d). We will try SOCK_STREAM.\n", Protocol);
return WSAEINVAL; SocketType = SOCK_STREAM;
break;
} }
} }
@ -156,13 +137,11 @@ WSPSocket(int AddressFamily,
break; break;
default: default:
TRACE("Unknown SocketType (%d). We will try IPPROTO_TCP.\n", SocketType); TRACE("Unknown SocketType (%d). We will try IPPROTO_TCP.\n", SocketType);
return WSAEINVAL; Protocol = IPPROTO_TCP;
break;
} }
} }
if (AddressFamily == AF_UNSPEC)
return WSAEINVAL;
/* Get Helper Data and Transport */ /* Get Helper Data and Transport */
Status = SockGetTdiName (&AddressFamily, Status = SockGetTdiName (&AddressFamily,
&SocketType, &SocketType,
@ -1719,46 +1698,6 @@ WSPAccept(SOCKET Handle,
return AcceptSocket; return AcceptSocket;
} }
VOID
NTAPI
AfdConnectAPC(PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG Reserved)
{
PAFDCONNECTAPCCONTEXT Context = ApcContext;
if (IoStatusBlock->Status == STATUS_SUCCESS)
{
Context->lpSocket->SharedData->State = SocketConnected;
Context->lpSocket->TdiConnectionHandle = (HANDLE)IoStatusBlock->Information;
}
if (Context->lpConnectInfo) HeapFree(GetProcessHeap(), 0, Context->lpConnectInfo);
/* Re-enable Async Event */
SockReenableAsyncSelectEvent(Context->lpSocket, FD_WRITE);
/* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
SockReenableAsyncSelectEvent(Context->lpSocket, FD_CONNECT);
if (IoStatusBlock->Status == STATUS_SUCCESS && (Context->lpSocket->HelperEvents & WSH_NOTIFY_CONNECT))
{
Context->lpSocket->HelperData->WSHNotify(Context->lpSocket->HelperContext,
Context->lpSocket->Handle,
Context->lpSocket->TdiAddressHandle,
Context->lpSocket->TdiConnectionHandle,
WSH_NOTIFY_CONNECT);
}
else if (IoStatusBlock->Status != STATUS_SUCCESS && (Context->lpSocket->HelperEvents & WSH_NOTIFY_CONNECT_ERROR))
{
Context->lpSocket->HelperData->WSHNotify(Context->lpSocket->HelperContext,
Context->lpSocket->Handle,
Context->lpSocket->TdiAddressHandle,
Context->lpSocket->TdiConnectionHandle,
WSH_NOTIFY_CONNECT_ERROR);
}
HeapFree(GlobalHeap, 0, ApcContext);
}
int int
WSPAPI WSPAPI
WSPConnect(SOCKET Handle, WSPConnect(SOCKET Handle,
@ -1781,18 +1720,6 @@ WSPConnect(SOCKET Handle,
PSOCKADDR BindAddress; PSOCKADDR BindAddress;
HANDLE SockEvent; HANDLE SockEvent;
int SocketDataLength; int SocketDataLength;
PVOID APCContext = NULL;
PVOID APCFunction = NULL;
TRACE("Called\n");
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
if (lpErrno) *lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
Status = NtCreateEvent(&SockEvent, Status = NtCreateEvent(&SockEvent,
EVENT_ALL_ACCESS, EVENT_ALL_ACCESS,
@ -1803,6 +1730,17 @@ WSPConnect(SOCKET Handle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return MsafdReturnWithErrno(Status, lpErrno, 0, NULL); return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
TRACE("Called\n");
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
if (lpErrno) *lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Bind us First */ /* Bind us First */
if (Socket->SharedData->State == SocketOpen) if (Socket->SharedData->State == SocketOpen)
{ {
@ -1913,22 +1851,14 @@ WSPConnect(SOCKET Handle,
/* FIXME: Handle Async Connect */ /* FIXME: Handle Async Connect */
if (Socket->SharedData->NonBlocking) if (Socket->SharedData->NonBlocking)
{ {
APCFunction = &AfdConnectAPC; // should be a private io completition function inside us ERR("Async Connect UNIMPLEMENTED!\n");
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDCONNECTAPCCONTEXT));
if (!APCContext)
{
ERR("Not enough memory for APC Context\n");
return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL);
}
((PAFDCONNECTAPCCONTEXT)APCContext)->lpConnectInfo = ConnectInfo;
((PAFDCONNECTAPCCONTEXT)APCContext)->lpSocket = Socket;
} }
/* Send IOCTL */ /* Send IOCTL */
Status = NtDeviceIoControlFile((HANDLE)Handle, Status = NtDeviceIoControlFile((HANDLE)Handle,
SockEvent, SockEvent,
APCFunction, NULL,
APCContext, NULL,
&IOSB, &IOSB,
IOCTL_AFD_CONNECT, IOCTL_AFD_CONNECT,
ConnectInfo, ConnectInfo,
@ -1936,20 +1866,12 @@ WSPConnect(SOCKET Handle,
NULL, NULL,
0); 0);
/* Wait for return */ /* Wait for return */
if (Status == STATUS_PENDING && !Socket->SharedData->NonBlocking) if (Status == STATUS_PENDING)
{ {
WaitForSingleObject(SockEvent, INFINITE); WaitForSingleObject(SockEvent, INFINITE);
Status = IOSB.Status; Status = IOSB.Status;
} }
if (Status == STATUS_PENDING)
{
TRACE("Leaving (Pending)\n");
return MsafdReturnWithErrno(STATUS_CANT_WAIT, lpErrno, 0, NULL);
}
if (APCContext) HeapFree(GetProcessHeap(), 0, APCContext);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
goto notify; goto notify;

View file

@ -135,12 +135,6 @@ typedef struct _AFDAPCCONTEXT
PSOCKET_INFORMATION lpSocket; PSOCKET_INFORMATION lpSocket;
} AFDAPCCONTEXT, *PAFDAPCCONTEXT; } AFDAPCCONTEXT, *PAFDAPCCONTEXT;
typedef struct _AFDCONNECTAPCCONTEXT
{
PAFD_CONNECT_INFO lpConnectInfo;
PSOCKET_INFORMATION lpSocket;
} AFDCONNECTAPCCONTEXT, *PAFDCONNECTAPCCONTEXT;
SOCKET SOCKET
WSPAPI WSPAPI
WSPAccept( WSPAccept(

View file

@ -490,20 +490,6 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
/* Assume failure */ /* Assume failure */
*CatalogEntry = NULL; *CatalogEntry = NULL;
/* Params can't be all wildcards */
if (af == AF_UNSPEC && type == 0 && protocol == 0)
return WSAEINVAL;
/* FIXME: AF_NETDES should be AF_MAX */
if (af < AF_UNSPEC || af > AF_NETDES)
return WSAEINVAL;
if (type < 0 && type > SOCK_SEQPACKET)
return WSAEINVAL;
if (protocol < 0 && protocol > IPPROTO_MAX)
return WSAEINVAL;
/* Lock the catalog */ /* Lock the catalog */
WsTcLock(); WsTcLock();
@ -541,13 +527,6 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
Entry->ProtocolInfo.iProtocolMaxOffset) >= protocol)) || Entry->ProtocolInfo.iProtocolMaxOffset) >= protocol)) ||
(protocol == 0)) (protocol == 0))
{ {
/* Check that if type and protocol are 0 provider entry has PFL_MATCHES_PROTOCOL_ZERO flag set */
if (type == 0 && protocol == 0 && (Entry->ProtocolInfo.dwProviderFlags & PFL_MATCHES_PROTOCOL_ZERO) == 0)
{
ErrorCode = WSAEPROTONOSUPPORT;
continue;
}
/* Check if it doesn't already have a provider */ /* Check if it doesn't already have a provider */
if (!Entry->Provider) if (!Entry->Provider)
{ {
@ -571,14 +550,12 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
} }
else else
{ {
if (ErrorCode != WSAEPROTONOSUPPORT) ErrorCode = WSAESOCKTNOSUPPORT;
ErrorCode = WSAESOCKTNOSUPPORT;
} }
} }
else else
{ {
if (ErrorCode != WSAEPROTONOSUPPORT && ErrorCode != WSAESOCKTNOSUPPORT) ErrorCode = WSAEAFNOSUPPORT;
ErrorCode = WSAEAFNOSUPPORT;
} }
} }