-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
fix SendTo with SocketAsyncEventArgs #98134
Changes from all commits
50ac1c6
9b1a4a9
dc1453e
e95b2fb
412b66f
27ce02f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -923,7 +923,12 @@ internal void FinishOperationSyncSuccess(int bytesTransferred, SocketFlags flags | |
case SocketAsyncOperation.ReceiveFrom: | ||
// Deal with incoming address. | ||
UpdateReceivedSocketAddress(_socketAddress!); | ||
if (_remoteEndPoint != null && !SocketAddressExtensions.Equals(_socketAddress!, _remoteEndPoint)) | ||
if (_remoteEndPoint == null) | ||
{ | ||
// detach user provided SA as it was updated in place. | ||
_socketAddress = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only two operations it would be set for are ReceiveFrom and SendTo, and we already handled the SendTo case on the synchronous start path? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. For SendTo we clear it when operation starts, for ReceiveFrom we do it when the operation is finished. |
||
} | ||
else if (!SocketAddressExtensions.Equals(_socketAddress!, _remoteEndPoint)) | ||
{ | ||
try | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to null it here because it's only used synchronously as part of the send operation and not asynchronously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. We will make
_socketAddress
before first try. f we do not finish synchronously on Unix, it would be copied to queued*SendOperation
. For Windows, theconst sockaddr *lpTo
is IN forWSASendTo
and AFAIK it does not need to be preserved until the overlapped IO is completed.