[svn] commit: r2466 - in /branches/trac221b/src/bin/auth: asio_link.cc asio_link.h main.cc tests/asio_link_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Jul 10 00:18:14 UTC 2010


Author: jinmei
Date: Sat Jul 10 00:18:14 2010
New Revision: 2466

Log:
changed interface of the IOService constructor so that it's impossible
to pass NULL port string, which simplifies validation.

Modified:
    branches/trac221b/src/bin/auth/asio_link.cc
    branches/trac221b/src/bin/auth/asio_link.h
    branches/trac221b/src/bin/auth/main.cc
    branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc

Modified: branches/trac221b/src/bin/auth/asio_link.cc
==============================================================================
--- branches/trac221b/src/bin/auth/asio_link.cc (original)
+++ branches/trac221b/src/bin/auth/asio_link.cc Sat Jul 10 00:18:14 2010
@@ -483,7 +483,7 @@
 
 class IOServiceImpl {
 public:
-    IOServiceImpl(AuthSrv* auth_server, const char* address, const char* port,
+    IOServiceImpl(AuthSrv* auth_server, const char* address, const char& port,
                   const bool use_ipv4, const bool use_ipv6);
     asio::io_service io_service_;
     AuthSrv* auth_server_;
@@ -500,7 +500,7 @@
 };
 
 IOServiceImpl::IOServiceImpl(AuthSrv* auth_server, const char* const address,
-                             const char* const port, const bool use_ipv4,
+                             const char& port, const bool use_ipv4,
                              const bool use_ipv6) :
     auth_server_(auth_server),
     udp4_server_(UDPServerPtr()), udp6_server_(UDPServerPtr()),
@@ -509,7 +509,7 @@
     uint16_t portnum;
 
     try {
-        portnum = boost::lexical_cast<uint16_t>(port);
+        portnum = boost::lexical_cast<uint16_t>(&port);
     } catch (const boost::bad_lexical_cast& ex) {
         isc_throw(IOError, "[b10-auth] Invalid port number '" << port << "'");
     }
@@ -555,7 +555,7 @@
 }
 
 IOService::IOService(AuthSrv* auth_server, const char* const address,
-                     const char* const port, const bool use_ipv4,
+                     const char& port, const bool use_ipv4,
                      const bool use_ipv6) {
     impl_ = new IOServiceImpl(auth_server, address, port, use_ipv4, use_ipv6);
 }

Modified: branches/trac221b/src/bin/auth/asio_link.h
==============================================================================
--- branches/trac221b/src/bin/auth/asio_link.h (original)
+++ branches/trac221b/src/bin/auth/asio_link.h Sat Jul 10 00:18:14 2010
@@ -390,7 +390,7 @@
     /// \brief The constructor.  Currently very specific to the authoritative
     /// server implementation.
     IOService(AuthSrv* auth_server, const char* const address,
-              const char* const port, bool use_ipv4, bool use_ipv6);
+              const char& port, bool use_ipv4, bool use_ipv6);
     /// \brief The destructor.
     ~IOService();
     //@}

Modified: branches/trac221b/src/bin/auth/main.cc
==============================================================================
--- branches/trac221b/src/bin/auth/main.cc (original)
+++ branches/trac221b/src/bin/auth/main.cc Sat Jul 10 00:18:14 2010
@@ -162,7 +162,7 @@
         auth_server->setVerbose(verbose_mode);
         cout << "[b10-auth] Server created." << endl;
 
-        io_service = new asio_link::IOService(auth_server, address, port,
+        io_service = new asio_link::IOService(auth_server, address, *port,
                                               use_ipv4, use_ipv6);
         cout << "[b10-auth] IOService created." << endl;
 

Modified: branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc
==============================================================================
--- branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc (original)
+++ branches/trac221b/src/bin/auth/tests/asio_link_unittest.cc Sat Jul 10 00:18:14 2010
@@ -90,10 +90,10 @@
 }
 
 TEST(IOServiceTest, badPort) {
-    EXPECT_THROW(IOService(NULL, NULL, "65536", true, false), IOError);
-    EXPECT_THROW(IOService(NULL, NULL, "5300.0", true, false), IOError);
-    EXPECT_THROW(IOService(NULL, NULL, "-1", true, false), IOError);
-    EXPECT_THROW(IOService(NULL, NULL, "domain", true, false), IOError);
+    EXPECT_THROW(IOService(NULL, NULL, *"65536", true, false), IOError);
+    EXPECT_THROW(IOService(NULL, NULL, *"5300.0", true, false), IOError);
+    EXPECT_THROW(IOService(NULL, NULL, *"-1", true, false), IOError);
+    EXPECT_THROW(IOService(NULL, NULL, *"domain", true, false), IOError);
 }
 
 struct addrinfo*
@@ -191,7 +191,7 @@
 };
 
 ASIOLinkTest::ASIOLinkTest() :
-    io_service_(NULL, NULL, TEST_PORT, true, true),
+    io_service_(NULL, NULL, *TEST_PORT, true, true),
     sock_(-1), res_(NULL)
 {
     io_service_.setCallBack(ASIOCallBack(this));




More information about the bind10-changes mailing list