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

Adds synchronous span APIs for datagram sockets. #51956

Merged
merged 4 commits into from
May 10, 2021

Conversation

PJB3005
Copy link
Contributor

@PJB3005 PJB3005 commented Apr 27, 2021

Hope I did this right.

Part of #33418/#938

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Apr 27, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Hope I did this right.

Part of #33418/#938

Author: PJB3005
Assignees: -
Labels:

area-System.Net.Sockets, new-api-needs-documentation

Milestone: -

@geoffkizer
Copy link
Contributor

Thanks, this looks good to me.

@antonfirsov should review and approve. (I think he's out today but should be back.)

To be clear -- the ReceiveMessageFrom API is already done, right? I see it listed in #33418, but I think that's incorrect, right?

@PJB3005
Copy link
Contributor Author

PJB3005 commented Apr 28, 2021

#46285 did ReceiveMessageFrom.

@antonfirsov is the way I did the tests correct? I didn't test manually (since I don't know how to compile against a local runtime like this).

Also the failing test seems to be a timeout in some HTTP API which I don't think I could have broken with these changes?

@geoffkizer
Copy link
Contributor

Also the failing test seems to be a timeout in some HTTP API which I don't think I could have broken with these changes?

Yeah, don't worry about the failing test. Test results look fine.

@antonfirsov
Copy link
Member

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product code looks good, although I have some questions to the team regarding NetEventSource.

Can we add 0-byte send tests similarly to #51473?

}

ValidateBlockingMode();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(...); has been omitted here, and at other places, because it's also missing from the Send(ROS) overload.

@geoffkizer (and maybe @MihaZupan) is NetEventSource an obsolete thing we are leaving behind in (functionally identical) span overloads on purpose, or is this a mistake? If it's a mistake is this something we care about and want to fix?

Here's how the same code looks like on the byte[] path:

public int SendTo(byte[] buffer, int offset, int size, SocketFlags socketFlags, EndPoint remoteEP)
{
ThrowIfDisposed();
ValidateBufferArguments(buffer, offset, size);
if (remoteEP == null)
{
throw new ArgumentNullException(nameof(remoteEP));
}
ValidateBlockingMode();
if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"SRC:{LocalEndPoint} size:{size} remoteEP:{remoteEP}");
Internals.SocketAddress socketAddress = Serialize(ref remoteEP);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetEventSource is whatever we want for internal logging purposes. It's not intended to be public, ever. To the extent that it duplicates our public telemetry, we should remove it. But there's a lot of internal logging code that has proven useful in the past, and we don't want to just blindly rip this out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, from what you said it feels like it's not worth opening an issue for it, but we should keep it in mind. A dedupe refactor across the span/array overloads should fix this anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

A dedupe refactor across the span/array overloads should fix this anyways.

This is blocked on #46600 right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, with #46600 we would get rid of synchronous byte[] overloads on SocketAsyncContext, and rebuild byte[] overloads on top of Span<byte> overloads in Socket.cs.

@geoffkizer
Copy link
Contributor

What else needs to happen here before we merge? @antonfirsov?

@antonfirsov
Copy link
Member

In my #51956 (review) I recommended to add tests for the 0-byte send tests similarly to #51473. Not essential, but would be nice to have.

@PJB3005
Copy link
Contributor Author

PJB3005 commented May 3, 2021

Ah, my bad, didn't realize that was something I should do.

@PJB3005
Copy link
Contributor Author

PJB3005 commented May 7, 2021

I added 0-byte send tests. Do these look good @antonfirsov?

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Test failures are unrelated.

Thanks!

@antonfirsov antonfirsov merged commit dcb42e8 into dotnet:main May 10, 2021
@PJB3005 PJB3005 deleted the 21-04-28-socket-span-sync branch May 10, 2021 15:33
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants