mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
[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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user