| Previous | Next |
| DNS_ERROR_UNSECURE_PACKET | DNS_ERROR_INVALID_TYPE |
DNS_REQUEST_PENDING
A pending request is not a failure
DNS_REQUEST_PENDING is the expected immediate result when DnsQueryEx will finish asynchronously. No final DNS records are available at that moment. The completion routine receives the eventual status and result list, which can be success, no records, an RCODE, cancellation, or another error.
Lifetime is the central implementation issue. Microsoft documents that the query-result and cancel structures must remain valid until the callback is invoked. Freeing stack-backed context, reusing the result object for another query, or destroying an owner during cancellation can turn an ordinary pending operation into a use-after-free or double-completion bug.
Correct handling
- Keep request context, result storage, callback state, and cancel handle alive until completion.
- Ensure that normal completion and cancellation converge on one ownership-release path.
- Read records only after the callback and release returned record lists with the documented DNS API function.
- Do not submit an immediate duplicate merely because the first call returned pending; apply an application-level deadline if required.
References
Looking for a different code? Search another status or error code.