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

Making LookupClient disposable and improved TCP client pool #220

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

MichaCo
Copy link
Owner

@MichaCo MichaCo commented Mar 17, 2024

Making LookupClient and DnsMessageHandlers disposable.
Primarily to dispose the TcpClient-pool.
The pool could be empty if the TCP fallback was either disabled or never used, so it is not always necessary to dispose the LookupClient owning that resource.

Making LookupClient disposable.
Disposing tcp client pool properly.
Copy link
Contributor

@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.

A couple of remarks. Since this is a significant breaking change, I would recommend to signal it to the package consumers by a major version bump.

src/DnsClient/LookupClient.cs Outdated Show resolved Hide resolved
src/DnsClient/LookupClient.cs Outdated Show resolved Hide resolved
src/DnsClient/DnsMessageHandler.cs Outdated Show resolved Hide resolved
src/DnsClient/DnsTcpMessageHandler.cs Outdated Show resolved Hide resolved
}
catch (Exception) when (gotCanceled)
{
throw new TimeoutException("Connection timed out.");
Copy link
Contributor

Choose a reason for hiding this comment

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

The caller Query method doesn't seem to translate cancellations to TimeoutException.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not exactly sure what you mean by that.
What I want to do here is allowing LookupClient does handle OperationCanceled- and Timeout-Exceptions and retry the request if possible.
For TCP, if the connection attempt takes longer then the configured timeout for a query, I want to handle it the same way and maybe have LookupClient retry.

Copy link
Owner Author

Choose a reason for hiding this comment

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

changed both, sync and async version to throw new OperationCanceledException("Connection timed out.", cancellationToken);
Still, its mostly a signal for LookupClient to retry

}
catch (Exception) when (gotCanceled)
{
throw new TimeoutException("Connection timed out.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this method is async, it shouldn't be translated to TimeoutException.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll change both, the sync and async version to throw new OperationCanceledException("Connection timed out.", cancellationToken);

src/DnsClient/DnsTcpMessageHandler.cs Outdated Show resolved Hide resolved
src/DnsClient/DnsTcpMessageHandler.cs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants