mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[MSAFD] Fix non-blocking sockets support for recv() (#5575) CORE-14486
Currently ReactOS' winsock2 implementation lacks of non-blocking sockets support for recv() apicall, this causes that applications that make use of this feature can lead to unexpected behaviors, one of them is Nginx web server, which uses non-blocking sockets when serving pages through Https protocol. CORE-14486 It also brings us significantly closer in master head to running Firefox 52, Mypal 29.3.0 and New Moon 28 browser, where the latter allows to connect to mattermost from within ReactOS. In master head an additional reg file is needed to stop us from exporting specific NT6+ APIs, but in older releases all that should work out of the box with this brilliant patch. Co-authored-by: Julio Carchi Ruiz <julcar@informaticos.com> Co-authored-by: Stanislav Motylkov <x86corez@gmail.com>
This commit is contained in:
parent
ab3bd82928
commit
442f5dfab5
2 changed files with 25 additions and 14 deletions
|
@ -1495,6 +1495,8 @@ WSPAccept(
|
|||
ListenReceiveData = (PAFD_RECEIVED_ACCEPT_DATA)ReceiveBuffer;
|
||||
|
||||
/* If this is non-blocking, make sure there's something for us to accept */
|
||||
if (Socket->SharedData->NonBlocking)
|
||||
{
|
||||
FD_ZERO(&ReadSet);
|
||||
FD_SET(Socket->Handle, &ReadSet);
|
||||
Timeout.tv_sec=0;
|
||||
|
@ -1512,6 +1514,7 @@ WSPAccept(
|
|||
if (lpErrno) *lpErrno = WSAEWOULDBLOCK;
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Send IOCTL */
|
||||
Status = NtDeviceIoControlFile((HANDLE)Socket->Handle,
|
||||
|
@ -1782,6 +1785,7 @@ WSPAccept(
|
|||
|
||||
AcceptSocketInfo->SharedData->State = SocketConnected;
|
||||
AcceptSocketInfo->SharedData->ConnectTime = GetCurrentTimeInSeconds();
|
||||
AcceptSocketInfo->SharedData->NonBlocking = Socket->SharedData->NonBlocking;
|
||||
|
||||
/* Return Address in SOCKADDR FORMAT */
|
||||
if( SocketAddress )
|
||||
|
|
|
@ -291,6 +291,13 @@ WSPRecv(SOCKET Handle,
|
|||
NULL,
|
||||
0);
|
||||
|
||||
/* Non-blocking sockets must wait until data is available */
|
||||
if (Status == STATUS_PENDING && Socket->SharedData->NonBlocking)
|
||||
{
|
||||
if (lpErrno) *lpErrno = WSAEWOULDBLOCK;
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
/* Wait for completion of not overlapped */
|
||||
if (Status == STATUS_PENDING && lpOverlapped == NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue