From 2052f2bc2f553f2607a0cc7f15d990b0394cbdf4 Mon Sep 17 00:00:00 2001 From: Sandeep Tamhankar Date: Mon, 16 Jan 2017 11:20:17 -0800 Subject: [PATCH 1/3] 354 - Add pid to node hash --- src/utils.cpp | 11 +++++++++++ src/utils.hpp | 2 ++ src/uuids.cpp | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/src/utils.cpp b/src/utils.cpp index 9b589a0b2..d6f275419 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -23,6 +23,8 @@ #include #include +#include + namespace cass { std::string opcode_to_string(int opcode) { @@ -157,4 +159,13 @@ std::string& to_cql_id(std::string& str) { return str; } +int32_t get_pid() +{ +#if defined(_MSC_VER) + return reinterpret_cast(GetCurrentProcessId()); +#else + return reinterpret_cast(getpid()); +#endif +} + } // namespace cass diff --git a/src/utils.hpp b/src/utils.hpp index 17e353127..9b4110203 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -91,6 +91,8 @@ std::string& to_cql_id(std::string& str); std::string& escape_id(std::string& str); +int32_t get_pid(); + } // namespace cass #endif diff --git a/src/uuids.cpp b/src/uuids.cpp index d70f893e1..f8767c086 100644 --- a/src/uuids.cpp +++ b/src/uuids.cpp @@ -213,6 +213,10 @@ UuidGen::UuidGen() uv_free_cpu_info(cpu_infos, cpu_count); } + // Tack on the pid + int32_t pid = get_pid(); + md5.update(reinterpret_cast(&pid), 4); + uint8_t hash[16]; md5.final(hash); From e619e1638fd4cd180ef7800e87437a92aec84550 Mon Sep 17 00:00:00 2001 From: Sandeep Tamhankar Date: Mon, 16 Jan 2017 11:47:03 -0800 Subject: [PATCH 2/3] 354 - Add pid to node hash * Speculative fix for Linux build failure * Speculative fix for Windows build failure. --- src/utils.cpp | 10 ++++++---- src/utils.hpp | 2 +- src/uuids.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index d6f275419..53ff13823 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -23,7 +23,9 @@ #include #include -#include +#if !defined(_MSC_VER) + #include +#endif namespace cass { @@ -159,12 +161,12 @@ std::string& to_cql_id(std::string& str) { return str; } -int32_t get_pid() +cass_int32_t get_pid() { #if defined(_MSC_VER) - return reinterpret_cast(GetCurrentProcessId()); + return reinterpret_cast(GetCurrentProcessId()); #else - return reinterpret_cast(getpid()); + return reinterpret_cast(getpid()); #endif } diff --git a/src/utils.hpp b/src/utils.hpp index 9b4110203..af27a1b3f 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -91,7 +91,7 @@ std::string& to_cql_id(std::string& str); std::string& escape_id(std::string& str); -int32_t get_pid(); +cass_int32_t get_pid(); } // namespace cass diff --git a/src/uuids.cpp b/src/uuids.cpp index f8767c086..fd0087715 100644 --- a/src/uuids.cpp +++ b/src/uuids.cpp @@ -214,7 +214,7 @@ UuidGen::UuidGen() } // Tack on the pid - int32_t pid = get_pid(); + cass_int32_t pid = get_pid(); md5.update(reinterpret_cast(&pid), 4); uint8_t hash[16]; From f8f53138f094cc080ea804889b9ca1726b34c390 Mon Sep 17 00:00:00 2001 From: Sandeep Tamhankar Date: Mon, 16 Jan 2017 13:04:37 -0800 Subject: [PATCH 3/3] 354 - Add pid to node hash * Another speculative fix for platform build errors. --- src/utils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 53ff13823..f8abf378e 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -23,7 +23,9 @@ #include #include -#if !defined(_MSC_VER) +#if defined(_MSC_VER) + #include +#else #include #endif @@ -164,9 +166,9 @@ std::string& to_cql_id(std::string& str) { cass_int32_t get_pid() { #if defined(_MSC_VER) - return reinterpret_cast(GetCurrentProcessId()); + return static_cast(GetCurrentProcessId()); #else - return reinterpret_cast(getpid()); + return static_cast(getpid()); #endif }