Commit faa93ae9 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[master] Merge branch 'trac2160'

parents eedd7668 edeea179
......@@ -114,6 +114,18 @@ private:
MessageRenderer& renderer_;
};
// Similar to Renderer holder, this is a very basic RAII-style class
// that calls clear(Message::PARSE) on the given Message upon destruction
class MessageHolder {
public:
MessageHolder(Message& message) : message_(message) {}
~MessageHolder() {
message_.clear(Message::PARSE);
}
private:
Message& message_;
};
// A helper container of socket session forwarder.
//
// This class provides a simple wrapper interface to SocketSessionForwarder
......@@ -344,6 +356,11 @@ public:
OutputBufferPtr buffer,
DNSServer* server) const
{
// Keep a holder on the message, so that it is automatically
// cleared if processMessage() is done
// This is not done in processMessage itself (which would be
// equivalent), to allow tests to inspect the message handling.
MessageHolder message_holder(*message);
server_->processMessage(io_message, *message, *buffer, server);
}
private:
......
......@@ -104,10 +104,6 @@ protected:
}
~AuthSrvTest() {
// Clear the message now; depending on the RTTI implementation,
// type information may be lost if the message is cleared
// automatically later, so as a precaution we do it now.
parse_message->clear(Message::PARSE);
server.destroyDDNSForwarder();
}
......@@ -833,6 +829,9 @@ TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
response_obuffer->getData(),
response_obuffer->getLength(),
&response_data[0], response_data.size());
// After it has been run, the message should be cleared
EXPECT_EQ(0, parse_message->getRRCount(Message::SECTION_QUESTION));
}
// In the following tests we confirm the response data is rendered in
......
......@@ -114,9 +114,13 @@ SyncUDPServer::handleRead(const asio::error_code& ec, const size_t length) {
return;
}
// Make sure the buffers are fresh
// Make sure the buffers are fresh. Note that we don't touch query_
// because it's supposed to be cleared in lookup_callback_. We should
// eventually even remove this member variable (and remove it from
// the lookup_callback_ interface, but until then, any callback
// implementation should be careful that it's the responsibility of
// the callback implementation. See also #2239).
output_buffer_->clear();
query_->clear(isc::dns::Message::PARSE);
answer_->clear(isc::dns::Message::RENDER);
// Mark that we don't have an answer yet.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment