authoritative: Prevent a potential race condition in cache cleaning
Clean query cache before cleaning packet cache. Otherwise the following
situation is possible:
* thread A cleans packet cache
* thread B answers a question for the same name that is being cleaned by A
* since there is no packet cache it populates a packet cache entry from the
query cache (which has not yet been cleaned by thread A
* thread A cleans query cache
* the server will return the old packet cache entry until its TTL expires or
cache is cleaned again
Switching which cache is cleaned first fixes this race condition.
Signed-off-by: Deyan Doychev <deyan@siteground.com>
(cherry picked from commit
fdcc9ab427f8deb73a4b5603ec2cb5233ec8bd78)