BIND 10 trac1595, updated. cb2af9730fdf9f0a9488c1197f29dec90b31c19d [1595] Docs update
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Feb 7 12:03:04 UTC 2012
The branch, trac1595 has been updated
via cb2af9730fdf9f0a9488c1197f29dec90b31c19d (commit)
via bf8c9216523617f5834b4acf9f876587995f5078 (commit)
via 013e14c7d9c84f00510aa8f7a99955aa47c018ad (commit)
from 33ff861b4cd62e8d2e6063452cc14e980d35bbaf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cb2af9730fdf9f0a9488c1197f29dec90b31c19d
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Feb 7 12:32:09 2012 +0100
[1595] Docs update
commit bf8c9216523617f5834b4acf9f876587995f5078
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Feb 7 12:15:41 2012 +0100
[1595] Use constants for the names
commit 013e14c7d9c84f00510aa8f7a99955aa47c018ad
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Feb 7 11:57:49 2012 +0100
[1595] Use EXPECT_ instead of ASSERT_ if possible
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/common.cc | 2 +
src/bin/auth/common.h | 5 +
src/bin/auth/main.cc | 4 +-
src/bin/resolver/Makefile.am | 1 +
.../asiodns/logger.cc => bin/resolver/common.cc} | 12 +--
.../asiodns/logger.cc => bin/resolver/common.h} | 16 ++--
src/bin/resolver/main.cc | 5 +-
src/lib/server_common/socket_request.h | 13 +++-
.../server_common/tests/socket_requestor_test.cc | 90 ++++++++++----------
9 files changed, 79 insertions(+), 69 deletions(-)
copy src/{lib/asiodns/logger.cc => bin/resolver/common.cc} (85%)
copy src/{lib/asiodns/logger.cc => bin/resolver/common.h} (79%)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/common.cc b/src/bin/auth/common.cc
index a7031f3..623aca1 100644
--- a/src/bin/auth/common.cc
+++ b/src/bin/auth/common.cc
@@ -37,3 +37,5 @@ getXfroutSocketPath() {
}
}
}
+
+const char* auth_name = "b10-auth";
diff --git a/src/bin/auth/common.h b/src/bin/auth/common.h
index b913593..ae093eb 100644
--- a/src/bin/auth/common.h
+++ b/src/bin/auth/common.h
@@ -38,6 +38,11 @@ public:
/// The logic should be the same as in b10-xfrout, so they find each other.
std::string getXfroutSocketPath();
+/// \brief The name used when identifieng the process
+///
+/// This is currently b10-auth, but it can be changed easily in one place.
+extern const char* auth_name;
+
#endif // __COMMON_H
// Local Variables:
diff --git a/src/bin/auth/main.cc b/src/bin/auth/main.cc
index a980db9..bb12f4e 100644
--- a/src/bin/auth/main.cc
+++ b/src/bin/auth/main.cc
@@ -116,7 +116,7 @@ main(int argc, char* argv[]) {
}
// Initialize logging. If verbose, we'll use maximum verbosity.
- isc::log::initLogger("b10-auth",
+ isc::log::initLogger(auth_name,
(verbose ? isc::log::DEBUG : isc::log::INFO),
isc::log::MAX_DEBUG_LEVEL, NULL);
@@ -154,7 +154,7 @@ main(int argc, char* argv[]) {
cc_session = new Session(io_service.get_io_service());
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_CREATED);
// Initialize the Socket Requestor
- isc::server_common::initSocketRequestor(*cc_session, "auth");
+ isc::server_common::initSocketRequestor(*cc_session, auth_name);
// We delay starting listening to new commands/config just before we
// go into the main loop to avoid confusion due to mixture of
diff --git a/src/bin/resolver/Makefile.am b/src/bin/resolver/Makefile.am
index faa166f..2bb3768 100644
--- a/src/bin/resolver/Makefile.am
+++ b/src/bin/resolver/Makefile.am
@@ -51,6 +51,7 @@ b10_resolver_SOURCES += resolver_log.cc resolver_log.h
b10_resolver_SOURCES += response_scrubber.cc response_scrubber.h
b10_resolver_SOURCES += $(top_builddir)/src/bin/auth/common.h
b10_resolver_SOURCES += main.cc
+b10_resolver_SOURCES += common.cc common.h
nodist_b10_resolver_SOURCES = resolver_messages.cc resolver_messages.h
diff --git a/src/bin/resolver/common.cc b/src/bin/resolver/common.cc
new file mode 100644
index 0000000..7ed30ca
--- /dev/null
+++ b/src/bin/resolver/common.cc
@@ -0,0 +1,17 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include "common.h"
+
+const char* resolver_name = "b10-resolver";
diff --git a/src/bin/resolver/common.h b/src/bin/resolver/common.h
new file mode 100644
index 0000000..3a07139
--- /dev/null
+++ b/src/bin/resolver/common.h
@@ -0,0 +1,23 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef RESOLVER_COMMON_H
+#define RESOLVER_COMMON_H
+
+/// \brief The name used to identify the resolver between modules.
+///
+/// It is currently set to b10-resolver.
+extern const char* resolver_name;
+
+#endif
diff --git a/src/bin/resolver/main.cc b/src/bin/resolver/main.cc
index c9c7e23..38e52db 100644
--- a/src/bin/resolver/main.cc
+++ b/src/bin/resolver/main.cc
@@ -56,6 +56,7 @@
#include <log/logger_support.h>
#include <log/logger_level.h>
#include "resolver_log.h"
+#include "common.h"
using namespace std;
using namespace isc::cc;
@@ -121,7 +122,7 @@ main(int argc, char* argv[]) {
// Until proper logging comes along, initialize the logging with the
// temporary initLogger() code. If verbose, we'll use maximum verbosity.
- isc::log::initLogger("b10-resolver",
+ isc::log::initLogger(resolver_name,
(verbose ? isc::log::DEBUG : isc::log::INFO),
isc::log::MAX_DEBUG_LEVEL, NULL);
@@ -202,7 +203,7 @@ main(int argc, char* argv[]) {
LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_SERVICE_CREATED);
cc_session = new Session(io_service.get_io_service());
- isc::server_common::initSocketRequestor(*cc_session, "resolver");
+ isc::server_common::initSocketRequestor(*cc_session, resolver_name);
// We delay starting listening to new commands/config just before we
// go into the main loop. See auth/main.cc for the rationale.
diff --git a/src/lib/server_common/socket_request.h b/src/lib/server_common/socket_request.h
index ceef2d3..a6a5ebb 100644
--- a/src/lib/server_common/socket_request.h
+++ b/src/lib/server_common/socket_request.h
@@ -167,7 +167,7 @@ public:
/// the app_name parameter of initSocketRequestor is used. If that one
/// is empty as well, it is accepted, but not recommended, as such
/// a non-descriptive name has a high chance of collisions between
- /// applications. nOTE THat you should provide a name (by share_name
+ /// applications. Note that you should provide a name (by share_name
/// or app_name) even when you set it to DONT_SHARE (for logs and
/// debugging) and you need to provide one with SHARE_SAME (to know
/// what is same) and SHARE_ANY (someone else might want SHARE_SAME,
@@ -175,6 +175,17 @@ public:
/// \return the socket, as a file descriptor and token representing it on
/// the socket creator side.
///
+ /// To understand the modes better:
+ /// - If mode is DONT_SHARE, it succeeds if no one else has opened an FD
+ /// for requested protocol, address and port.
+ /// - If mode is SHARE_SAME, it succeeds if all applications who opened a
+ /// FD for the requested protocol, address and port provided the same
+ /// share_name as this one and none of them had mode DONT_SHARE.
+ /// - If mode is SHARE_ANY, it succeeds if no applications who requested
+ /// the same potocol, address and port provided DONT_SHARE and all the
+ /// applications who provided SHARE_SAME also provided the same
+ /// share_name as we.
+ ///
/// \throw InvalidParameter protocol or share_mode is invalid
/// \throw CCSessionError when we have a problem talking over the CC
/// session.
diff --git a/src/lib/server_common/tests/socket_requestor_test.cc b/src/lib/server_common/tests/socket_requestor_test.cc
index 28048ae..829b6d9 100644
--- a/src/lib/server_common/tests/socket_requestor_test.cc
+++ b/src/lib/server_common/tests/socket_requestor_test.cc
@@ -158,46 +158,46 @@ TEST_F(SocketRequestorTest, testSocketRequestMessages) {
expected_request = createExpectedRequest("192.0.2.1", 12345, "UDP",
"NO", "test");
- ASSERT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
- "192.0.2.1", 12345,
- SocketRequestor::DONT_SHARE,
- "test"),
+ EXPECT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
+ "192.0.2.1", 12345,
+ SocketRequestor::DONT_SHARE,
+ "test"),
CCSessionError);
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
clearMsgQueue();
expected_request = createExpectedRequest("192.0.2.2", 1, "TCP",
"ANY", "test2");
- ASSERT_THROW(socketRequestor().requestSocket(SocketRequestor::TCP,
- "192.0.2.2", 1,
- SocketRequestor::SHARE_ANY,
- "test2"),
+ EXPECT_THROW(socketRequestor().requestSocket(SocketRequestor::TCP,
+ "192.0.2.2", 1,
+ SocketRequestor::SHARE_ANY,
+ "test2"),
CCSessionError);
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
clearMsgQueue();
expected_request = createExpectedRequest("::1", 2, "UDP",
"SAMEAPP", "test3");
- ASSERT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
- "::1", 2,
- SocketRequestor::SHARE_SAME,
- "test3"),
+ EXPECT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
+ "::1", 2,
+ SocketRequestor::SHARE_SAME,
+ "test3"),
CCSessionError);
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
// A default share name equal to the app name passed on construction
clearMsgQueue();
expected_request = createExpectedRequest("::1", 2, "UDP",
"SAMEAPP", "tests");
- ASSERT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
- "::1", 2,
+ EXPECT_THROW(socketRequestor().requestSocket(SocketRequestor::UDP,
+ "::1", 2,
SocketRequestor::SHARE_SAME),
CCSessionError);
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_request, *(session.getMsgQueue()->get(0)));
}
TEST_F(SocketRequestorTest, invalidParameterForSocketRequest) {
@@ -222,19 +222,19 @@ TEST_F(SocketRequestorTest, testBadRequestAnswers) {
// Test various scenarios where the requestor gets back bad answers
// Should raise CCSessionError if there is no answer
- ASSERT_THROW(doRequest(), CCSessionError);
+ EXPECT_THROW(doRequest(), CCSessionError);
// Also if the answer does not match the format
session.getMessages()->add(createAnswer());
- ASSERT_THROW(doRequest(), CCSessionError);
+ EXPECT_THROW(doRequest(), CCSessionError);
// Now a 'real' answer, should fail on socket connect (no such file)
addAnswer("foo", "/does/not/exist");
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
// Another failure (domain socket path too long)
addAnswer("foo", std::string(1000, 'x'));
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
// Test values around path boundary
struct sockaddr_un sock_un;
@@ -247,7 +247,7 @@ TEST_F(SocketRequestorTest, testBadRequestAnswers) {
doRequest();
FAIL() << "doRequest did not throw an exception";
} catch (const SocketRequestor::SocketError& se) {
- ASSERT_EQ(std::string::npos, std::string(se.what()).find("too long"));
+ EXPECT_EQ(std::string::npos, std::string(se.what()).find("too long"));
}
const std::string too_long(sizeof(sock_un.sun_path), 'x');
@@ -257,18 +257,18 @@ TEST_F(SocketRequestorTest, testBadRequestAnswers) {
doRequest();
FAIL() << "doRequest did not throw an exception";
} catch (const SocketRequestor::SocketError& se) {
- ASSERT_NE(std::string::npos, std::string(se.what()).find("too long"));
+ EXPECT_NE(std::string::npos, std::string(se.what()).find("too long"));
}
// Send back an error response
// A generic one first
session.getMessages()->add(createAnswer(1, "error"));
- ASSERT_THROW(doRequest(), CCSessionError);
+ EXPECT_THROW(doRequest(), CCSessionError);
// Now some with specific exceptions
session.getMessages()->add(createAnswer(2, "error"));
- ASSERT_THROW(doRequest(), SocketRequestor::SocketAllocateError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketAllocateError);
session.getMessages()->add(createAnswer(3, "error"));
- ASSERT_THROW(doRequest(), SocketRequestor::ShareError);
+ EXPECT_THROW(doRequest(), SocketRequestor::ShareError);
}
// Helper function to create the release commands as we expect
@@ -297,24 +297,24 @@ TEST_F(SocketRequestorTest, testSocketReleaseMessages) {
expected_release = createExpectedRelease("foo");
socketRequestor().releaseSocket("foo");
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_release, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_release, *(session.getMsgQueue()->get(0)));
session.getMessages()->add(createAnswer());
clearMsgQueue();
expected_release = createExpectedRelease("bar");
socketRequestor().releaseSocket("bar");
ASSERT_EQ(1, session.getMsgQueue()->size());
- ASSERT_EQ(*expected_release, *(session.getMsgQueue()->get(0)));
+ EXPECT_EQ(*expected_release, *(session.getMsgQueue()->get(0)));
}
TEST_F(SocketRequestorTest, testBadSocketReleaseAnswers) {
// Should fail if there is no answer at all
- ASSERT_THROW(socketRequestor().releaseSocket("bar"),
+ EXPECT_THROW(socketRequestor().releaseSocket("bar"),
CCSessionError);
// Should also fail if the answer is an error
session.getMessages()->add(createAnswer(1, "error"));
- ASSERT_THROW(socketRequestor().releaseSocket("bar"),
+ EXPECT_THROW(socketRequestor().releaseSocket("bar"),
SocketRequestor::SocketError);
}
@@ -525,20 +525,20 @@ TEST_F(SocketRequestorTest, testSocketPassing) {
// 1 should be ok
addAnswer("foo", ts.getPath());
socket_id = doRequest();
- ASSERT_EQ("foo", socket_id.second);
- ASSERT_EQ(0, close(socket_id.first));
+ EXPECT_EQ("foo", socket_id.second);
+ EXPECT_EQ(0, close(socket_id.first));
// 2 should be ok too
addAnswer("bar", ts.getPath());
socket_id = doRequest();
- ASSERT_EQ("bar", socket_id.second);
- ASSERT_EQ(0, close(socket_id.first));
+ EXPECT_EQ("bar", socket_id.second);
+ EXPECT_EQ(0, close(socket_id.first));
// 3 should be ok too (reuse earlier token)
addAnswer("foo", ts.getPath());
socket_id = doRequest();
- ASSERT_EQ("foo", socket_id.second);
- ASSERT_EQ(0, close(socket_id.first));
+ EXPECT_EQ("foo", socket_id.second);
+ EXPECT_EQ(0, close(socket_id.first));
}
// Create a second socket server, to test that multiple different
@@ -553,35 +553,35 @@ TEST_F(SocketRequestorTest, testSocketPassing) {
// 1 should be ok
addAnswer("foo", ts2.getPath());
socket_id = doRequest();
- ASSERT_EQ("foo", socket_id.second);
- ASSERT_EQ(0, close(socket_id.first));
+ EXPECT_EQ("foo", socket_id.second);
+ EXPECT_EQ(0, close(socket_id.first));
}
if (timo_ok) {
// Now use first socket again
addAnswer("foo", ts.getPath());
socket_id = doRequest();
- ASSERT_EQ("foo", socket_id.second);
- ASSERT_EQ(0, close(socket_id.first));
+ EXPECT_EQ("foo", socket_id.second);
+ EXPECT_EQ(0, close(socket_id.first));
// -1 is a "normal" error
addAnswer("foo", ts.getPath());
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
// -2 is an unexpected error. After this point it's not guaranteed the
// connection works as intended.
addAnswer("foo", ts.getPath());
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
}
// Vector is of first socket is now empty, so the socket should be gone
addAnswer("foo", ts.getPath());
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
// Vector is of second socket is now empty too, so the socket should be
// gone
addAnswer("foo", ts2.getPath());
- ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
+ EXPECT_THROW(doRequest(), SocketRequestor::SocketError);
}
}
More information about the bind10-changes
mailing list