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

ensure the AcceptSocket is cleared when AcceptAsync completes #61258

Merged
merged 1 commit into from
Nov 6, 2021
Merged
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 @@ -62,7 +62,8 @@ public ValueTask<Socket> AcceptAsync(Socket? acceptSocket, CancellationToken can
Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
new AwaitableSocketAsyncEventArgs(this, isReceiveForCaching: false);

Debug.Assert(saea.BufferList == null);
Debug.Assert(saea.BufferList is null);
Debug.Assert(saea.AcceptSocket is null);
saea.SetBuffer(null, 0, 0);
saea.AcceptSocket = acceptSocket;
saea.WrapExceptionsForNetworkStream = false;
Expand Down Expand Up @@ -1048,6 +1049,8 @@ public ValueTask<Socket> AcceptAsync(Socket socket, CancellationToken cancellati
Socket acceptSocket = AcceptSocket!;
SocketError error = SocketError;

AcceptSocket = null;

Release();

return error == SocketError.Success ?
Expand Down Expand Up @@ -1405,6 +1408,8 @@ Socket IValueTaskSource<Socket>.GetResult(short token)
Socket acceptSocket = AcceptSocket!;
CancellationToken cancellationToken = _cancellationToken;

AcceptSocket = null;

Release();

if (error != SocketError.Success)
Expand Down