From: Francis Dupont Date: Wed, 20 May 2015 13:13:29 +0000 (+0200) Subject: [master] renamed INVALID_SOCKET -> SOCKET_NOT_VALID (#3861) X-Git-Tag: trac3652_base~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=28205225ceed03ff3126e43cd06cedbaa7d8d657;p=thirdparty%2Fkea.git [master] renamed INVALID_SOCKET -> SOCKET_NOT_VALID (#3861) --- diff --git a/ChangeLog b/ChangeLog index ab525958d7..b2c4ad72d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +934. [bug] fdupont + Renamed the DHCP-DDNS constant INVALID_SOCKET to SOCKET_NOT_VALID + to avoid conflicting with a constant of that name defined on some + operating systems. + (Trac #3861, git xxx) + 933. [func]* marcin DHCPv4 server by default identifies a client using the client-identifier, if present. The new configuration diff --git a/src/lib/dhcp/tests/pkt6_unittest.cc b/src/lib/dhcp/tests/pkt6_unittest.cc old mode 100755 new mode 100644 diff --git a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc index d1559a9850..b1a463d962 100644 --- a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -362,7 +362,7 @@ TEST(NameChangeUDPSenderBasicTest, basicSendTests) { int select_fd = sender.getSelectFd(); // Verify select_fd is valid and currently shows no ready to read. - ASSERT_NE(dhcp_ddns::WatchSocket::INVALID_SOCKET, select_fd); + ASSERT_NE(dhcp_ddns::WatchSocket::SOCKET_NOT_VALID, select_fd); // Make sure select_fd does evaluates to not ready via select and // that ioReady() method agrees. diff --git a/src/lib/dhcp_ddns/tests/watch_socket_unittests.cc b/src/lib/dhcp_ddns/tests/watch_socket_unittests.cc index 059767f9ca..cb10323336 100644 --- a/src/lib/dhcp_ddns/tests/watch_socket_unittests.cc +++ b/src/lib/dhcp_ddns/tests/watch_socket_unittests.cc @@ -41,7 +41,7 @@ TEST(WatchSocketTest, basics) { /// Verify that post-construction the state the select-fd is valid. int select_fd = watch->getSelectFd(); - EXPECT_NE(select_fd, WatchSocket::INVALID_SOCKET); + EXPECT_NE(select_fd, WatchSocket::SOCKET_NOT_VALID); /// Verify that isReady() is false and that a call to select agrees. EXPECT_FALSE(watch->isReady()); @@ -85,7 +85,7 @@ TEST(WatchSocketTest, closedWhileClear) { /// Verify that post-construction the state the select-fd is valid. int select_fd = watch->getSelectFd(); - ASSERT_NE(select_fd, WatchSocket::INVALID_SOCKET); + ASSERT_NE(select_fd, WatchSocket::SOCKET_NOT_VALID); // Verify that socket does not appear ready. ASSERT_EQ(0, watch->isReady()); @@ -106,7 +106,7 @@ TEST(WatchSocketTest, closedWhileClear) { ASSERT_NO_THROW(watch->clearReady()); // Verify that getSelectFd() returns invalid socket. - ASSERT_EQ(WatchSocket::INVALID_SOCKET, watch->getSelectFd()); + ASSERT_EQ(WatchSocket::SOCKET_NOT_VALID, watch->getSelectFd()); } /// @brief Checks behavior when select_fd has closed while in the "ready" @@ -120,7 +120,7 @@ TEST(WatchSocketTest, closedWhileReady) { /// Verify that post-construction the state the select-fd is valid. int select_fd = watch->getSelectFd(); - ASSERT_NE(select_fd, WatchSocket::INVALID_SOCKET); + ASSERT_NE(select_fd, WatchSocket::SOCKET_NOT_VALID); /// Verify that the socket can be marked ready. ASSERT_NO_THROW(watch->markReady()); @@ -150,7 +150,7 @@ TEST(WatchSocketTest, emptyReadySelectFd) { /// Verify that post-construction the state the select-fd is valid. int select_fd = watch->getSelectFd(); - ASSERT_NE(select_fd, WatchSocket::INVALID_SOCKET); + ASSERT_NE(select_fd, WatchSocket::SOCKET_NOT_VALID); /// Verify that the socket can be marked ready. ASSERT_NO_THROW(watch->markReady()); @@ -183,7 +183,7 @@ TEST(WatchSocketTest, badReadOnClear) { /// Verify that post-construction the state the select-fd is valid. int select_fd = watch->getSelectFd(); - ASSERT_NE(select_fd, WatchSocket::INVALID_SOCKET); + ASSERT_NE(select_fd, WatchSocket::SOCKET_NOT_VALID); /// Verify that the socket can be marked ready. ASSERT_NO_THROW(watch->markReady()); @@ -203,7 +203,7 @@ TEST(WatchSocketTest, badReadOnClear) { EXPECT_NE(1, selectCheck(select_fd)); // Verify that getSelectFd() returns INVALID. - ASSERT_EQ(WatchSocket::INVALID_SOCKET, watch->getSelectFd()); + ASSERT_EQ(WatchSocket::SOCKET_NOT_VALID, watch->getSelectFd()); // Verify that subsequent attempt to mark it fails. ASSERT_THROW(watch->markReady(), WatchSocketError); diff --git a/src/lib/dhcp_ddns/watch_socket.cc b/src/lib/dhcp_ddns/watch_socket.cc index fd4027e751..7139f8270c 100644 --- a/src/lib/dhcp_ddns/watch_socket.cc +++ b/src/lib/dhcp_ddns/watch_socket.cc @@ -25,11 +25,11 @@ namespace isc { namespace dhcp_ddns { -const int WatchSocket::INVALID_SOCKET; +const int WatchSocket::SOCKET_NOT_VALID; const uint32_t WatchSocket::MARKER; WatchSocket::WatchSocket() - : source_(INVALID_SOCKET), sink_(INVALID_SOCKET) { + : source_(SOCKET_NOT_VALID), sink_(SOCKET_NOT_VALID) { // Open the pipe. int fds[2]; if (pipe(fds)) { @@ -79,7 +79,7 @@ WatchSocket::markReady() { bool WatchSocket::isReady() { // Report it as not ready rather than error here. - if (sink_ == INVALID_SOCKET) { + if (sink_ == SOCKET_NOT_VALID) { return (false); } @@ -122,24 +122,24 @@ WatchSocket::closeSocket() { // but there's no recovery for it either. If one does fail we log it // and go on. Plus this is called by the destructor and no one likes // destructors that throw. - if (source_ != INVALID_SOCKET) { + if (source_ != SOCKET_NOT_VALID) { if (close(source_)) { const char* errstr = strerror(errno); LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_WATCH_SOURCE_CLOSE_ERROR) .arg(errstr); } - source_ = INVALID_SOCKET; + source_ = SOCKET_NOT_VALID; } - if (sink_ != INVALID_SOCKET) { + if (sink_ != SOCKET_NOT_VALID) { if (close(sink_)) { const char* errstr = strerror(errno); LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_WATCH_SINK_CLOSE_ERROR) .arg(errstr); } - sink_ = INVALID_SOCKET; + sink_ = SOCKET_NOT_VALID; } } diff --git a/src/lib/dhcp_ddns/watch_socket.h b/src/lib/dhcp_ddns/watch_socket.h index f067ea62a8..85c3799864 100644 --- a/src/lib/dhcp_ddns/watch_socket.h +++ b/src/lib/dhcp_ddns/watch_socket.h @@ -54,7 +54,7 @@ public: class WatchSocket { public: /// @brief Value used to signify an invalid descriptor. - static const int INVALID_SOCKET = -1; + static const int SOCKET_NOT_VALID = -1; /// @brief Value written to the source when marking the socket as ready. /// The value itself is arbitrarily chosen as one that is unlikely to occur /// otherwise and easy to debug. @@ -88,7 +88,7 @@ public: /// select_fd. Rather than track what the status "should be" it tests the status. /// This should eliminate conditions where the select-fd appear to be perpetually /// ready. - /// @return Returns true if select_fd is not INVALID_SOCKET and select() reports it + /// @return Returns true if select_fd is not SOCKET_NOT_VALID and select() reports it /// as !EWOULDBLOCK, otherwise it returns false. /// This method is guaranteed NOT to throw. bool isReady(); diff --git a/src/lib/dhcpsrv/d2_client_mgr.cc b/src/lib/dhcpsrv/d2_client_mgr.cc index bebee02ba1..bad5073123 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.cc +++ b/src/lib/dhcpsrv/d2_client_mgr.cc @@ -30,7 +30,7 @@ namespace dhcp { D2ClientMgr::D2ClientMgr() : d2_client_config_(new D2ClientConfig()), name_change_sender_(), private_io_service_(), - registered_select_fd_(dhcp_ddns::WatchSocket::INVALID_SOCKET) { + registered_select_fd_(dhcp_ddns::WatchSocket::SOCKET_NOT_VALID) { // Default constructor initializes with a disabled configuration. } @@ -275,9 +275,9 @@ D2ClientMgr::amSending() const { void D2ClientMgr::stopSender() { /// Unregister sender's select-fd. - if (registered_select_fd_ != dhcp_ddns::WatchSocket::INVALID_SOCKET) { + if (registered_select_fd_ != dhcp_ddns::WatchSocket::SOCKET_NOT_VALID) { IfaceMgr::instance().deleteExternalSocket(registered_select_fd_); - registered_select_fd_ = dhcp_ddns::WatchSocket::INVALID_SOCKET; + registered_select_fd_ = dhcp_ddns::WatchSocket::SOCKET_NOT_VALID; } // If its not null, call stop. diff --git a/src/lib/dhcpsrv/d2_client_mgr.h b/src/lib/dhcpsrv/d2_client_mgr.h index 21c82c815f..eccccbee4d 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.h +++ b/src/lib/dhcpsrv/d2_client_mgr.h @@ -409,7 +409,7 @@ protected: /// @brief Fetches the select-fd that is currently registered. /// /// @return The currently registered select-fd or - /// dhcp_ddns::WatchSocket::INVALID_SOCKET. + /// dhcp_ddns::WatchSocket::SOCKET_NOT_VALID. /// /// @note This is only exposed for testing purposes. int getRegisteredSelectFd();