+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
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.
/// 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());
/// 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());
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"
/// 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());
/// 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());
/// 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());
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);
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)) {
bool
WatchSocket::isReady() {
// Report it as not ready rather than error here.
- if (sink_ == INVALID_SOCKET) {
+ if (sink_ == SOCKET_NOT_VALID) {
return (false);
}
// 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;
}
}
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.
/// 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();
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.
}
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.
/// @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();