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
[Async TestKit] Modernize TcpStage and TcpListener #5989
[Async TestKit] Modernize TcpStage and TcpListener #5989
Conversation
…ocking by running them in their own thread
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.
Missing API approval
public static WritingResumed Instance = new WritingResumed(); | ||
public static readonly WritingResumed Instance = new WritingResumed(); | ||
|
||
private WritingResumed() |
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.
These are breaking API changes, but no big deal. Need to be able to do stuff like this in Akka.NET v1.5.
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.
Left some feedback
try | ||
{ | ||
bind.Options.ForEach(x => x.BeforeServerSocketBind(_socket)); | ||
_socket.Bind(bind.LocalAddress); |
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.
Good idea, moving this out of the constructor
_binding = true; | ||
_bind = bind; | ||
_acceptLimit = bind.PullMode ? 0 : _tcp.Settings.BatchAcceptLimit; | ||
BindAsync().PipeTo(Self); |
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.
LGTM
if (!_socket.AcceptAsync(saea)) | ||
Self.Tell(new SocketEvent(saea)); | ||
return true; | ||
|
||
case Tcp.ResumeAccepting resumeAccepting: | ||
_acceptLimit = resumeAccepting.BatchSize; | ||
// TODO: this is dangerous, previous async args are not disposed and there's no guarantee that they're not still receiving data |
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.
Previous socket async event args?
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.
_saeas
is an array of SocketAsyncEventArgs
, assigned by the Accept
method.
In this case, the old code actually discarded all of the old args while most of them still active accepting connections, we would lose all reference to those event args.
- They cause a memory leak, or
- They can get finalized and disposed and something breaks.
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.
aren't these SAEA only handling bind events though, which have no buffers?
Changes:
Make TcpListener binding and unbinding code non-blocking by running them on another thread.