[dns-client] simplify SendQuery() and add comment (#6357)

This commit contains two small changes in `Dns::Client`: simplifying
the `SendQuery()` call and adding a comment about reason for parsing
the response in a separate method.
This commit is contained in:
Abtin Keshavarzian
2021-03-26 16:03:37 -07:00
committed by GitHub
parent a6be70f296
commit d0bbfe6e4c
2 changed files with 6 additions and 11 deletions
+6 -10
View File
@@ -564,7 +564,7 @@ Error Client::StartQuery(QueryInfo & aInfo,
SuccessOrExit(error = AllocateQuery(aInfo, aLabel, aName, query));
mQueries.Enqueue(*query);
SendQuery(*query);
SendQuery(*query, aInfo, /* aUpdateTimer */ true);
exit:
return error;
@@ -597,15 +597,6 @@ void Client::FreeQuery(Query &aQuery)
aQuery.Free();
}
void Client::SendQuery(Query &aQuery)
{
QueryInfo info;
info.ReadFrom(aQuery);
SendQuery(aQuery, info, /* aUpdateTimer */ true);
}
void Client::SendQuery(Query &aQuery, QueryInfo &aInfo, bool aUpdateTimer)
{
// This method prepares and sends a query message represented by
@@ -788,6 +779,11 @@ void Client::ProcessResponse(const Message &aMessage)
response.mMessage = &aMessage;
// We intentionally parse the response in a separate method
// `ParseResponse()` to free all the stack allocated variables
// (e.g., `QueryInfo`) used during parsing of the message before
// finalizing the query and invoking the user's callback.
SuccessOrExit(ParseResponse(response, type, responseError));
FinalizeQuery(response, type, responseError);
-1
View File
@@ -655,7 +655,6 @@ private:
Error AllocateQuery(const QueryInfo &aInfo, const char *aLabel, const char *aName, Query *&aQuery);
void FreeQuery(Query &aQuery);
void UpdateQuery(Query &aQuery, const QueryInfo &aInfo) { aQuery.Write(0, aInfo); }
void SendQuery(Query &aQuery);
void SendQuery(Query &aQuery, QueryInfo &aInfo, bool aUpdateTimer);
void FinalizeQuery(Query &aQuery, Error aError);
void FinalizeQuery(Response &Response, QueryType aType, Error aError);