From ed1e1d70bbcf8b1ee1d5b38c2b8efb973752f8b8 Mon Sep 17 00:00:00 2001 From: Yohan Bainier Date: Fri, 16 Oct 2015 10:23:31 +0200 Subject: [PATCH 1/2] Address::compare() fixed Some IPv4 addresses could not be found in IOWorker::PoolMap instance because Address::compare() method was broken on Windows x64. --- src/address.cpp | 4 ++-- src/address.hpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/address.cpp b/src/address.cpp index 1d61cfab8..55b0e4f96 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -139,12 +139,12 @@ std::string Address::to_string(bool with_port) const { return ss.str(); } -int Address::compare(const Address& a) const { +std::int64_t Address::compare(const Address& a) const { if (family() != a.family()) { return family() - a.family(); } if (family() == AF_INET) { - return (addr_in()->sin_addr.s_addr - a.addr_in()->sin_addr.s_addr); + return (static_cast< std::int64_t >(addr_in()->sin_addr.s_addr) - static_cast< std::int64_t >(a.addr_in()->sin_addr.s_addr)); } else if (family() == AF_INET6) { return memcmp(&(addr_in6()->sin6_addr), &(a.addr_in6()->sin6_addr), sizeof(addr_in6()->sin6_addr)); diff --git a/src/address.hpp b/src/address.hpp index f414dd878..11be7053c 100644 --- a/src/address.hpp +++ b/src/address.hpp @@ -20,6 +20,7 @@ #include "utils.hpp" #include +#include #include #include #include @@ -68,7 +69,7 @@ class Address { std::string to_string(bool with_port = false) const; - int compare(const Address& a) const; + std::int64_t compare(const Address& a) const; private: void init() { memset(&addr_, 0, sizeof(addr_)); } From dd40c12341fd15d180b52596b67a23286a69b0ea Mon Sep 17 00:00:00 2001 From: Yohan Bainier Date: Fri, 16 Oct 2015 11:30:32 +0200 Subject: [PATCH 2/2] prefering int64_t from stdint.h instead of std::int64_t from cstdint which is a C++11 type --- src/address.cpp | 4 ++-- src/address.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/address.cpp b/src/address.cpp index 55b0e4f96..f9507c766 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -139,12 +139,12 @@ std::string Address::to_string(bool with_port) const { return ss.str(); } -std::int64_t Address::compare(const Address& a) const { +int64_t Address::compare(const Address& a) const { if (family() != a.family()) { return family() - a.family(); } if (family() == AF_INET) { - return (static_cast< std::int64_t >(addr_in()->sin_addr.s_addr) - static_cast< std::int64_t >(a.addr_in()->sin_addr.s_addr)); + return (static_cast< int64_t >(addr_in()->sin_addr.s_addr) - static_cast< int64_t >(a.addr_in()->sin_addr.s_addr)); } else if (family() == AF_INET6) { return memcmp(&(addr_in6()->sin6_addr), &(a.addr_in6()->sin6_addr), sizeof(addr_in6()->sin6_addr)); diff --git a/src/address.hpp b/src/address.hpp index 11be7053c..aa23d5113 100644 --- a/src/address.hpp +++ b/src/address.hpp @@ -20,7 +20,7 @@ #include "utils.hpp" #include -#include +#include #include #include #include @@ -69,7 +69,7 @@ class Address { std::string to_string(bool with_port = false) const; - std::int64_t compare(const Address& a) const; + int64_t compare(const Address& a) const; private: void init() { memset(&addr_, 0, sizeof(addr_)); }