You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added DnsResolver class to manage DNS queries and responses.
- Introduced DnsQueryToken for tracking individual queries.
- Implemented asynchronous handling of DNS queries using c-ares library.
- Created structures for DNS addresses and nameservers to encapsulate relevant data.
- Added error handling for various DNS operations and responses.
- Implemented tests for DNS resolver functionality, including success, failure, and timeout scenarios.
- Ensured that all new structures are trivially copyable where applicable.
closes: #62closes: #59
Adds an asynchronous c-ares DNS resolver adapter with bounded queries, socket/timer integration, TTL results, normalized errors, and test/build support.
Changes:
Introduces DNS adapter contracts and c-ares implementation.
Adds resolver lifecycle, nameserver configuration, cancellation, and query tests.
- Added new fields to QuerySlot for better channel management.
- Improved cancellation logic to handle native query states.
- Updated address_complete and socket_state functions to manage query lifecycle more effectively.
- Enhanced tests to cover new cancellation scenarios and ensure proper query exhaustion handling.
Check expected error before accessing Result::value()
tests/adapters/dns.cpp:403
This expression calls value() on the Result returned for the 254-byte hostname. That result is intentionally an error, so the test invokes std::expected::value() without checking it and can throw/terminate instead of validating the input error. Call has_value() directly (and, ideally, assert invalid_range).
- Added logic to handle socket capacity failures in the DNS resolver.
- Introduced a new flag in QuerySlot to track socket capacity issues.
- Updated the completion callback to check for inactive tokens during resolution.
- Added tests to validate behavior when socket capacity is exceeded.
- Improved overall robustness of DNS query handling under load.
Reclaim completed slots before allowing reentrant submissions
src/adapters/dns.cpp:210
When all 64 query slots are occupied, a completion decrements outstanding but leaves its slot active/native_done until the surrounding process_events() or process_timeout() call returns. A completion sink that immediately submits a replacement query therefore sees available outstanding capacity but gets exhaustion because the slot scan below skips the completed slot. Finalize/reclaim the completed slot before allowing reentrant submissions, while ensuring the outer event-loop path cannot retire a newly reused slot.
Make timeout test deterministic and assert native timeout status
tests/adapters/dns.cpp:368
This purported timeout test targets 127.0.0.1:9, which commonly fails immediately with ARES_ECONNREFUSED, and only checks the broad io error. On a host where the port is closed it never exercises ARES_ETIMEOUT, process_timeout(), or timeout normalization; on a filtered host the result changes. Use a fixture that receives and drops the DNS packet (or otherwise assert the native timeout status) so this coverage is deterministic.
- Added support for asynchronous DNS resolution by introducing new properties in QuerySlot.
- Implemented completion handling for queries to allow reentrant submissions.
- Updated tests to validate the new asynchronous behavior and ensure proper handling of query results.
- Changed the type of the channel member in QuerySlot from ares_channel_t* to ares_channel.
- This change simplifies the management of the DNS channel within the QuerySlot structure.
This says completion callbacks are synchronous with destruction, but release() sets shutting_down and drops outstanding c-ares queries without calling DnsQuerySink::complete. Consumers following this contract may wait for callbacks that never arrive; document the destruction behavior explicitly or dispatch cancellation results during teardown.
- Updated comments to clarify that destruction of the resolver abandons outstanding queries without invoking their completion callbacks.
- Modified `process_events` and `process_timeout` methods to return early if the query is done or if socket capacity fails, improving clarity and flow.
- Added tests to verify that the resolver can be destroyed during event and timeout callbacks, ensuring proper resource management.
This only constructs a resolver with an empty nameserver list; every actual lookup in query_fixture supplies an explicit server. Consequently the nameservers.empty() path is never exercised through ares_getaddrinfo, so system resolver configuration can regress without detection despite being an adapter acceptance criterion. Add a lookup that drives the system configuration path (or a controllable system-resolver fixture).
- Introduced a new test case for system resolver lookup.
- Validates the resolver's ability to resolve "localhost" to the correct IPv4 address.
- Ensures that the resolver functions correctly under expected conditions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #62
closes: #59