]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] renamed INVALID_SOCKET -> SOCKET_NOT_VALID (#3861)
authorFrancis Dupont <fdupont@isc.org>
Wed, 20 May 2015 13:13:29 +0000 (15:13 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 20 May 2015 13:13:29 +0000 (15:13 +0200)
ChangeLog
src/lib/dhcp/tests/pkt6_unittest.cc [changed mode: 0755->0644]
src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc
src/lib/dhcp_ddns/tests/watch_socket_unittests.cc
src/lib/dhcp_ddns/watch_socket.cc
src/lib/dhcp_ddns/watch_socket.h
src/lib/dhcpsrv/d2_client_mgr.cc
src/lib/dhcpsrv/d2_client_mgr.h

index ab525958d795fe8a486786f558fbc0710101fd8c..b2c4ad72d74cd290e38f253db6c2a1ac648256b8 100644 (file)
--- 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
old mode 100755 (executable)
new mode 100644 (file)
index d1559a98502b7714e78c9fd3216bf589a6964256..b1a463d962c0482e94f54cf37ea2fef54d078de5 100644 (file)
@@ -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.
index 059767f9ca19dc7e73b8f6fb8e901269530a9405..cb10323336dc2b4f31ee4c558168cbb114471aae 100644 (file)
@@ -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);
index fd4027e751957564379e932e71daf22820641933..7139f8270c541d75d39a2ee7958ea30a9e47fdff 100644 (file)
@@ -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;
     }
 }
 
index f067ea62a8c0a1f6a7a34669ad3935f81dc63bb4..85c3799864489c62873e6f076a3cdd5587ccddf2 100644 (file)
@@ -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();
index bebee02ba10175c4f71e95d8f941c75ce6239282..bad5073123e943bcf871feb4213bbdd4cc520283 100644 (file)
@@ -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.
index 21c82c815fafbd8cca2461371fb73f87b9c8da8a..eccccbee4d34b4a630dc3fc2770b21d270d81094 100644 (file)
@@ -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();