Network servers should not ignore ServiceError
.
#390
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.
This PR addresses an omission in the
net::server::dgram
andnet::server::stream
modules whereby they iterate over the stream of service responses accepting onlySome(Ok)
results and cease iterating on anything else. To stop onNone
is fine, but to stop onErr
without taking any action is not.Background: The
Service
interface was designed such that services can easily returnErr(ServiceError)
with the inteion that this allows them to easily produce certain standard DNS error responses without doing the work of constructing the response message correclty, keeping their error handling code paths simple. TheServiceError
type has anrcode()
method which the network server was supposed to use to construct the appopriate DNS response message, e.g.ServiceError::InternalError
translates to rcode SERVFAIL.But since the network servers never handle the service error case other than to ignore it that means in such cases the client wouldn't receive any DNS response message at all! This was not the intention, it was simply overlooked and clearly there also aren't any test cases that exercise this.
This PR makes three improvements:
ServiceError
and construct and return the appropriate DNS response error message to the client.ServiceInvoker
base trait with default fn impls, with some network server specific methods to be filled in by the network server impls.Message
object, while the TCP server would defer async task creation till a bit later.This PR does NOT (yet?) address the lack of test cases for this logic.