Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor old APM [Begin/End]Accept methods on top of Task APIs, and enable for Unix as well #51212

Merged
merged 7 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<Compile Include="System\Net\Sockets\TransmitFileOptions.cs" />
<Compile Include="System\Net\Sockets\UDPClient.cs" />
<Compile Include="System\Net\Sockets\UdpReceiveResult.cs" />
<Compile Include="System\Net\Sockets\AcceptOverlappedAsyncResult.cs" />
<Compile Include="System\Net\Sockets\BaseOverlappedAsyncResult.cs" />
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
<!-- Logging -->
Expand Down Expand Up @@ -89,7 +88,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<!-- Windows: CoreCLR -->
<Compile Include="System\Net\Sockets\AcceptOverlappedAsyncResult.Windows.cs" />
<Compile Include="System\Net\Sockets\BaseOverlappedAsyncResult.Windows.cs" />
<Compile Include="System\Net\Sockets\DynamicWinsockMethods.cs" />
<Compile Include="System\Net\Sockets\SafeSocketHandle.Windows.cs" />
Expand Down Expand Up @@ -184,7 +182,6 @@
Link="Common\System\Net\CompletionPortHelper.Windows.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="System\Net\Sockets\AcceptOverlappedAsyncResult.Unix.cs" />
<Compile Include="System\Net\Sockets\BaseOverlappedAsyncResult.Unix.cs" />
<Compile Include="System\Net\Sockets\SafeSocketHandle.Unix.cs" />
<Compile Include="System\Net\Sockets\Socket.Unix.cs" />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@ public SocketInformation DuplicateAndClose(int targetProcessId)
throw new PlatformNotSupportedException(SR.net_sockets_duplicateandclose_notsupported);
}

public IAsyncResult BeginAccept(int receiveSize, AsyncCallback? callback, object? state)
{
throw new PlatformNotSupportedException(SR.net_sockets_accept_receive_apm_notsupported);
}

public IAsyncResult BeginAccept(Socket? acceptSocket, int receiveSize, AsyncCallback? callback, object? state)
{
throw new PlatformNotSupportedException(SR.net_sockets_accept_receive_apm_notsupported);
}

public Socket EndAccept(out byte[] buffer, IAsyncResult asyncResult)
{
throw new PlatformNotSupportedException(SR.net_sockets_accept_receive_apm_notsupported);
}

public Socket EndAccept(out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult)
{
throw new PlatformNotSupportedException(SR.net_sockets_accept_receive_apm_notsupported);
}

internal bool PreferInlineCompletions
{
get => _handle.PreferInlineCompletions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.Versioning;

namespace System.Net.Sockets
Expand Down Expand Up @@ -145,30 +146,6 @@ public SocketInformation DuplicateAndClose(int targetProcessId)
return info;
}

public IAsyncResult BeginAccept(int receiveSize, AsyncCallback? callback, object? state)
{
return BeginAccept(acceptSocket: null, receiveSize, callback, state);
}

// This is the truly async version that uses AcceptEx.
public IAsyncResult BeginAccept(Socket? acceptSocket, int receiveSize, AsyncCallback? callback, object? state)
{
return BeginAcceptCommon(acceptSocket, receiveSize, callback, state);
}

public Socket EndAccept(out byte[] buffer, IAsyncResult asyncResult)
{
Socket socket = EndAccept(out byte[] innerBuffer, out int bytesTransferred, asyncResult);
buffer = new byte[bytesTransferred];
Buffer.BlockCopy(innerBuffer, 0, buffer, 0, bytesTransferred);
return socket;
}

public Socket EndAccept(out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult)
{
return EndAcceptCommon(out buffer!, out bytesTransferred, asyncResult);
}

private DynamicWinsockMethods GetDynamicWinsockMethods()
{
return _dynamicWinsockMethods ??= DynamicWinsockMethods.GetMethods(_addressFamily, _socketType, _protocolType);
Expand Down Expand Up @@ -439,7 +416,7 @@ private IAsyncResult BeginSendFileInternal(string? fileName, byte[]? preBuffer,
throw new SocketException((int)errorCode);
}

asyncResult.FinishPostingAsyncOp(ref Caches.SendClosureCache);
asyncResult.FinishPostingAsyncOp();

return asyncResult;
}
Expand Down
Loading