diff --git a/cmake/check.cmake b/cmake/check.cmake index e1ea471e8..a520ac720 100644 --- a/cmake/check.cmake +++ b/cmake/check.cmake @@ -24,6 +24,12 @@ if (GALERA_HAVE_SUBUNIT_LIB) list(APPEND GALERA_UNIT_TEST_LIBS "${GALERA_HAVE_SUBUNIT_LIB}") endif() +# needed on old systems with glibc < 2.17 for timer_create() in libcheck. +CHECK_LIBRARY_EXISTS(rt timer_create "" HAVE_TIMER_CREATE) +IF (HAVE_TIMER_CREATE) + LIST(APPEND GALERA_UNIT_TEST_LIBS rt) +ENDIF(HAVE_TIMER_CREATE) + list(APPEND GALERA_UNIT_TEST_LIBS m) list(APPEND GALERA_UNIT_TEST_LIBS ${GALERA_SYSTEM_LIBS}) diff --git a/cmake/os.cmake b/cmake/os.cmake index 75d3a44d1..6d039a2c6 100644 --- a/cmake/os.cmake +++ b/cmake/os.cmake @@ -5,8 +5,8 @@ # find_library(PTHREAD_LIB pthread) -find_library(RT_LIB rt) -set(GALERA_SYSTEM_LIBS ${PTHREAD_LIB} ${RT_LIB}) + +set(GALERA_SYSTEM_LIBS ${PTHREAD_LIB}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # Check if linkage with atomic library is needed for 8 byte atomics diff --git a/galera/src/CMakeLists.txt b/galera/src/CMakeLists.txt index 56971717e..d6f01482c 100644 --- a/galera/src/CMakeLists.txt +++ b/galera/src/CMakeLists.txt @@ -104,6 +104,7 @@ target_compile_options(galera_smm ) if (GALERA_VERSION_SCRIPT) +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # Limit symbols visible from Galera DSO. # Doing this allows to: # - make the ABI more clean and concise @@ -113,6 +114,7 @@ if (GALERA_VERSION_SCRIPT) set(GALERA_LINK_OPTIONS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/galera-sym.map) endif() +endif() target_link_libraries(galera_smm galera ${GALERA_LINK_OPTIONS}) diff --git a/galerautils/src/gu_asio.hpp b/galerautils/src/gu_asio.hpp index c1254d04b..decc92a9c 100644 --- a/galerautils/src/gu_asio.hpp +++ b/galerautils/src/gu_asio.hpp @@ -27,6 +27,102 @@ #include #include +#ifdef __APPLE__ + +struct tcp_info { + uint8_t tcpi_state; + uint8_t tcpi_ca_state; + uint8_t tcpi_retransmits; + uint8_t tcpi_probes; + uint8_t tcpi_backoff; + uint8_t tcpi_options; + uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; + uint8_t tcpi_delivery_rate_app_limited:1, tcpi_fastopen_client_fail:2; + + uint32_t tcpi_rto; + uint32_t tcpi_ato; + uint32_t tcpi_snd_mss; + uint32_t tcpi_rcv_mss; + + uint32_t tcpi_unacked; + uint32_t tcpi_sacked; + uint32_t tcpi_lost; + uint32_t tcpi_retrans; + uint32_t tcpi_fackets; + + /* Times. */ + uint32_t tcpi_last_data_sent; + uint32_t tcpi_last_ack_sent; /* Not remembered, sorry. */ + uint32_t tcpi_last_data_recv; + uint32_t tcpi_last_ack_recv; + + /* Metrics. */ + uint32_t tcpi_pmtu; + uint32_t tcpi_rcv_ssthresh; + uint32_t tcpi_rtt; + uint32_t tcpi_rttvar; + uint32_t tcpi_snd_ssthresh; + uint32_t tcpi_snd_cwnd; + uint32_t tcpi_advmss; + uint32_t tcpi_reordering; + + uint32_t tcpi_rcv_rtt; + uint32_t tcpi_rcv_space; + + uint32_t tcpi_total_retrans; + + uint64_t tcpi_pacing_rate; + uint64_t tcpi_max_pacing_rate; + uint64_t tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */ + uint64_t tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */ + uint32_t tcpi_segs_out; /* RFC4898 tcpEStatsPerfSegsOut */ + uint32_t tcpi_segs_in; /* RFC4898 tcpEStatsPerfSegsIn */ + + uint32_t tcpi_notsent_bytes; + uint32_t tcpi_min_rtt; + uint32_t tcpi_data_segs_in; /* RFC4898 tcpEStatsDataSegsIn */ + uint32_t tcpi_data_segs_out; /* RFC4898 tcpEStatsDataSegsOut */ + + uint64_t tcpi_delivery_rate; + + uint64_t tcpi_busy_time; /* Time (usec) busy sending data */ + uint64_t tcpi_rwnd_limited; /* Time (usec) limited by receive window */ + uint64_t tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */ + + uint32_t tcpi_delivered; + uint32_t tcpi_delivered_ce; + + uint64_t tcpi_bytes_sent; /* RFC4898 tcpEStatsPerfHCDataOctetsOut */ + uint64_t tcpi_bytes_retrans; /* RFC4898 tcpEStatsPerfOctetsRetrans */ + uint32_t tcpi_dsack_dups; /* RFC4898 tcpEStatsStackDSACKDups */ + uint32_t tcpi_reord_seen; /* reordering events seen */ + + uint32_t tcpi_rcv_ooopack; /* Out-of-order packets received */ + + uint32_t tcpi_snd_wnd; /* peer's advertised receive window after + * scaling (bytes) + */ + uint32_t tcpi_rcv_wnd; /* local advertised receive window after + * scaling (bytes) + */ + + uint32_t tcpi_rehash; /* PLB or timeout triggered rehash attempts */ + + uint16_t tcpi_total_rto; /* Total number of RTO timeouts, including + * SYN/SYN-ACK and recurring timeouts. + */ + uint16_t tcpi_total_rto_recoveries; /* Total number of RTO + * recoveries, including any + * unfinished recovery. + */ + uint32_t tcpi_total_rto_time; /* Total time spent in RTO recoveries + * in milliseconds, including any + * unfinished recovery. + */ +}; + +#endif + namespace gu { // URI schemes for networking diff --git a/galerautils/src/gu_asio_socket_util.hpp b/galerautils/src/gu_asio_socket_util.hpp index 57b78ba59..65062518c 100644 --- a/galerautils/src/gu_asio_socket_util.hpp +++ b/galerautils/src/gu_asio_socket_util.hpp @@ -143,6 +143,40 @@ static void bind(Socket& socket, const gu::AsioIpAddress& addr) } } +#ifdef __APPLE__ + +template +static struct tcp_info get_tcp_info(Socket& socket) +{ + struct tcp_info tcpi; + memset(&tcpi, 0, sizeof(tcpi)); + // struct tcp_connection_info + // https://developer.apple.com/documentation/kernel/tcp_connection_info + // http://git.haproxy.org/?p=haproxy-2.6.git;a=commitdiff_plain;h=7747d465d54a1e367e9bf9c07c263d7f1f7fd481;hp=5c83e3a1563cd7face299bf08037e51f976eb5e3 + // TODO needed fields: + // ret.rtt = tcpi.tcpi_rtt; + // ret.rttvar = tcpi.tcpi_rttvar; + // ret.rto = tcpi.tcpi_rto; +#if defined(__linux__) + // ret.lost = tcpi.tcpi_lost; +#else + // ret.lost = 0; +#endif /* __linux__ */ + // ret.last_data_recv = tcpi.tcpi_last_data_recv; + // ret.cwnd = tcpi.tcpi_snd_cwnd; + // gu::datetime::Date now(gu::datetime::Date::monotonic()); + // Critical crit(net_); + // ret.last_queued_since = (now - last_queued_tstamp_).get_nsecs(); + // ret.last_delivered_since = (now - last_delivered_tstamp_).get_nsecs(); + // ret.send_queue_length = send_q_.size(); + // ret.send_queue_bytes = send_q_.queued_bytes(); + // ret.send_queue_segments = send_q_.segments(); + + return tcpi; +} + +#else + template static struct tcp_info get_tcp_info(Socket& socket) { @@ -165,7 +199,7 @@ static struct tcp_info get_tcp_info(Socket& socket) #endif /* __linux__ || __FreeBSD__ */ return tcpi; } - +#endif static inline std::string uri_string (const std::string& scheme, const std::string& addr, diff --git a/galerautils/src/gu_threads.c b/galerautils/src/gu_threads.c index e30af5bc1..1f1012a54 100644 --- a/galerautils/src/gu_threads.c +++ b/galerautils/src/gu_threads.c @@ -248,11 +248,11 @@ int gu_barrier_init_SYS (gu_barrier_t_SYS *barrier, errno = EINVAL; return -1; } - if(gu_mutex_init_SYS (&barrier->mutex, 0) < 0) + if(gu_mutex_init_SYS (NULL, &barrier->mutex) < 0) { return -1; } - if(gu_cond_init_SYS (&barrier->cond, 0) < 0) + if(gu_cond_init_SYS (NULL, &barrier->cond) < 0) { gu_mutex_destroy_SYS (&barrier->mutex); return -1; @@ -279,13 +279,13 @@ int gu_barrier_wait_SYS (gu_barrier_t_SYS *barrier) barrier->count = 0; gu_cond_broadcast_SYS (&barrier->cond); gu_mutex_unlock_SYS (&barrier->mutex); - return GU_BARRIER_THREAD_SYS; + return GU_BARRIER_SERIAL_THREAD_SYS; } else { gu_cond_wait_SYS (&barrier->cond, &(barrier->mutex)); gu_mutex_unlock_SYS (&barrier->mutex); - return !GU_BARRIER_THREAD_SYS; + return !GU_BARRIER_SERIAL_THREAD_SYS; } } diff --git a/galerautils/src/gu_threads.h b/galerautils/src/gu_threads.h index f55e059bb..6826ff02b 100644 --- a/galerautils/src/gu_threads.h +++ b/galerautils/src/gu_threads.h @@ -11,8 +11,6 @@ #include "gu_types.h" // bool -#if __unix__ - #include #include @@ -318,8 +316,6 @@ typedef pthread_barrier_t gu_barrier_t_SYS; #endif /* native POSIX barriers */ -#endif /* __unix__ */ - /** * Depending on compile-time flags application will either use * normal or debug version of the API calls diff --git a/galerautils/src/gu_time.c b/galerautils/src/gu_time.c index 3e33d1ce1..99b4cfd50 100644 --- a/galerautils/src/gu_time.c +++ b/galerautils/src/gu_time.c @@ -16,179 +16,179 @@ #include // mach_absolute_time, mach_timebase_info #include #include "gu_time.h" - -#define NSEC_PER_SEC 1000000000 -#define NSEC_PER_USEC 1000 - -# if defined(__LP64__) - -// OS X comm page time offsets -// see http://www.opensource.apple.com/source/xnu/xnu-2050.22.13/osfmk/i386/cpu_capabilities.h -#define nt_tsc_base "0x50" -#define nt_scale "0x58" -#define nt_shift "0x5c" -#define nt_ns_base "0x60" -#define nt_generation "0x68" -#define gtod_generation "0x6c" -#define gtod_ns_base "0x70" -#define gtod_sec_base "0x78" - -static inline int64_t nanotime (void) { - int64_t ntime; - __asm volatile ( - "mov $0x7fffffe00000, %%rbx;" /* comm page base */ - "0:" /* Loop trying to take a consistent snapshot of the time parameters. */ - "movl "gtod_generation"(%%rbx), %%r8d;" - "testl %%r8d, %%r8d;" - "jz 1f;" - "movl "nt_generation"(%%rbx), %%r9d;" - "testl %%r9d, %%r9d;" - "jz 0b;" - "rdtsc;" - "movq "nt_tsc_base"(%%rbx), %%r10;" - "movl "nt_scale"(%%rbx), %%r11d;" - "movq "nt_ns_base"(%%rbx), %%r12;" - "cmpl "nt_generation"(%%rbx), %%r9d;" - "jne 0b;" - "movq "gtod_ns_base"(%%rbx), %%r13;" - "movq "gtod_sec_base"(%%rbx), %%r14;" - "cmpl "gtod_generation"(%%rbx), %%r8d;" - "jne 0b;" - - /* Gathered all the data we need. Compute time. */ - /* ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base - gtod_ns_base + gtod_sec_base*1e9 */ - /* The multiply and shift extracts the top 64 bits of the 96-bit product. */ - "shlq $32, %%rdx;" - "addq %%rdx, %%rax;" - "subq %%r10, %%rax;" - "mulq %%r11;" - "shrdq $32, %%rdx, %%rax;" - "addq %%r12, %%rax;" - "subq %%r13, %%rax;" - "imulq $1000000000, %%r14;" - "addq %%r14, %%rax;" - "jmp 2f;" - "1:" /* Fall back to system call (usually first call in this thread). */ - "movq %%rsp, %%rdi;" /* rdi must be non-nil, unused */ - "movq $0, %%rsi;" - "movl $(0x2000000+116), %%eax;" /* SYS_gettimeofday */ - "syscall; /* may destroy rcx and r11 */" - /* sec is in rax, usec in rdx */ - /* return nsec in rax */ - "imulq $1000000000, %%rax;" - "imulq $1000, %%rdx;" - "addq %%rdx, %%rax;" - "2:" - : "=a"(ntime) - : /* no input parameters */ - : "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14" - ); - return ntime; -} - -static inline int64_t nanouptime (void) { - int64_t ntime; - __asm volatile ( - "movabs $0x7fffffe00000, %%rbx;" /* comm page base */ - "0:" /* Loop trying to take a consistent snapshot of the time parameters. */ - "movl "nt_generation"(%%rbx), %%r9d;" - "testl %%r9d, %%r9d;" - "jz 0b;" - "rdtsc;" - "movq "nt_tsc_base"(%%rbx), %%r10;" - "movl "nt_scale"(%%rbx), %%r11d;" - "movq "nt_ns_base"(%%rbx), %%r12;" - "cmpl "nt_generation"(%%rbx), %%r9d;" - "jne 0b;" - - /* Gathered all the data we need. Compute time. */ - /* ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base */ - /* The multiply and shift extracts the top 64 bits of the 96-bit product. */ - "shlq $32, %%rdx;" - "addq %%rdx, %%rax;" - "subq %%r10, %%rax;" - "mulq %%r11;" - "shrdq $32, %%rdx, %%rax;" - "addq %%r12, %%rax;" - : "=a"(ntime) - : /* no input parameters */ - : "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%r9", "%r10", "%r11", "%r12" - ); - return ntime; -} - -int -clock_gettime (clockid_t clk_id, struct timespec * tp) -{ - int64_t abstime = 0; - if (tp == NULL) { - return EFAULT; - } - switch (clk_id) { - case CLOCK_REALTIME: - abstime = nanotime (); - break; - case CLOCK_MONOTONIC: - abstime = nanouptime (); - break; - default: - errno = EINVAL; - return -1; - } - tp->tv_sec = abstime / (uint64_t)NSEC_PER_SEC; - tp->tv_nsec = (uint32_t)(abstime % (uint64_t)NSEC_PER_SEC); - return 0; -} - -#else /* !__LP64__ */ - -static struct mach_timebase_info g_mti; - -int -clock_gettime (clockid_t clk_id, struct timespec * tp) -{ - int64_t abstime = 0; - mach_timebase_info_data_t mti; /* {uint32_t numer, uint32_t denom} */ - if (tp == NULL) { - return EFAULT; - } - switch (clk_id) { - case CLOCK_REALTIME: - struct timeval tv; - if (gettimeofday (&tv, NULL) != 0) { - return -1; - } - tp->tv_sec = tv.tv_sec; - tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC; - return 0; - case CLOCK_MONOTONIC: - abstime = mach_absolute_time (); - break; - default: - errno = EINVAL; - return -1; - } - if (g_mti.denom == 0) { - struct mach_timebase_info mti; - mach_timebase_info (&mti); - g_mti.numer = mti.numer; - OSMemoryBarrier (); - g_mti.denom = mti.denom; - } - nanos = (uint64_t)(abstime * (((double)g_mti.numer) / ((double)g_mti.denom))); - tp->tv_sec = nanos / (uint64_t)NSEC_PER_SEC; - tp->tv_nsec = (uint32_t)(nanos % (uint64_t)NSEC_PER_SEC); - return 0; -} - -#endif /* !__LP64__ */ - -#else /* !__APPLE__ */ - -#ifdef __GNUC__ -// error: ISO C forbids an empty translation unit -int dummy_var_gu_time; -#endif - +// +// #define NSEC_PER_SEC 1000000000 +// #define NSEC_PER_USEC 1000 +// +// // # if defined(__LP64__) +// // +// // // OS X comm page time offsets +// // // see http://www.opensource.apple.com/source/xnu/xnu-2050.22.13/osfmk/i386/cpu_capabilities.h +// // #define nt_tsc_base "0x50" +// // #define nt_scale "0x58" +// // #define nt_shift "0x5c" +// // #define nt_ns_base "0x60" +// // #define nt_generation "0x68" +// // #define gtod_generation "0x6c" +// // #define gtod_ns_base "0x70" +// // #define gtod_sec_base "0x78" +// // +// // static inline int64_t nanotime (void) { +// // int64_t ntime; +// // __asm volatile ( +// // "mov $0x7fffffe00000, %%rbx;" /* comm page base */ +// // "0:" /* Loop trying to take a consistent snapshot of the time parameters. */ +// // "movl "gtod_generation"(%%rbx), %%r8d;" +// // "testl %%r8d, %%r8d;" +// // "jz 1f;" +// // "movl "nt_generation"(%%rbx), %%r9d;" +// // "testl %%r9d, %%r9d;" +// // "jz 0b;" +// // "rdtsc;" +// // "movq "nt_tsc_base"(%%rbx), %%r10;" +// // "movl "nt_scale"(%%rbx), %%r11d;" +// // "movq "nt_ns_base"(%%rbx), %%r12;" +// // "cmpl "nt_generation"(%%rbx), %%r9d;" +// // "jne 0b;" +// // "movq "gtod_ns_base"(%%rbx), %%r13;" +// // "movq "gtod_sec_base"(%%rbx), %%r14;" +// // "cmpl "gtod_generation"(%%rbx), %%r8d;" +// // "jne 0b;" +// // +// // /* Gathered all the data we need. Compute time. */ +// // /* ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base - gtod_ns_base + gtod_sec_base*1e9 */ +// // /* The multiply and shift extracts the top 64 bits of the 96-bit product. */ +// // "shlq $32, %%rdx;" +// // "addq %%rdx, %%rax;" +// // "subq %%r10, %%rax;" +// // "mulq %%r11;" +// // "shrdq $32, %%rdx, %%rax;" +// // "addq %%r12, %%rax;" +// // "subq %%r13, %%rax;" +// // "imulq $1000000000, %%r14;" +// // "addq %%r14, %%rax;" +// // "jmp 2f;" +// // "1:" /* Fall back to system call (usually first call in this thread). */ +// // "movq %%rsp, %%rdi;" /* rdi must be non-nil, unused */ +// // "movq $0, %%rsi;" +// // "movl $(0x2000000+116), %%eax;" /* SYS_gettimeofday */ +// // "syscall; /* may destroy rcx and r11 */" +// // /* sec is in rax, usec in rdx */ +// // /* return nsec in rax */ +// // "imulq $1000000000, %%rax;" +// // "imulq $1000, %%rdx;" +// // "addq %%rdx, %%rax;" +// // "2:" +// // : "=a"(ntime) +// // : /* no input parameters */ +// // : "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14" +// // ); +// // return ntime; +// // } +// // +// // static inline int64_t nanouptime (void) { +// // int64_t ntime; +// // __asm volatile ( +// // "movabs $0x7fffffe00000, %%rbx;" /* comm page base */ +// // "0:" /* Loop trying to take a consistent snapshot of the time parameters. */ +// // "movl "nt_generation"(%%rbx), %%r9d;" +// // "testl %%r9d, %%r9d;" +// // "jz 0b;" +// // "rdtsc;" +// // "movq "nt_tsc_base"(%%rbx), %%r10;" +// // "movl "nt_scale"(%%rbx), %%r11d;" +// // "movq "nt_ns_base"(%%rbx), %%r12;" +// // "cmpl "nt_generation"(%%rbx), %%r9d;" +// // "jne 0b;" +// // +// // /* Gathered all the data we need. Compute time. */ +// // /* ((tsc - nt_tsc_base) * nt_scale) >> 32 + nt_ns_base */ +// // /* The multiply and shift extracts the top 64 bits of the 96-bit product. */ +// // "shlq $32, %%rdx;" +// // "addq %%rdx, %%rax;" +// // "subq %%r10, %%rax;" +// // "mulq %%r11;" +// // "shrdq $32, %%rdx, %%rax;" +// // "addq %%r12, %%rax;" +// // : "=a"(ntime) +// // : /* no input parameters */ +// // : "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%r9", "%r10", "%r11", "%r12" +// // ); +// // return ntime; +// // } +// // +// // int +// // clock_gettime (clockid_t clk_id, struct timespec * tp) +// // { +// // int64_t abstime = 0; +// // if (tp == NULL) { +// // return EFAULT; +// // } +// // switch (clk_id) { +// // case CLOCK_REALTIME: +// // abstime = nanotime (); +// // break; +// // case CLOCK_MONOTONIC: +// // abstime = nanouptime (); +// // break; +// // default: +// // errno = EINVAL; +// // return -1; +// // } +// // tp->tv_sec = abstime / (uint64_t)NSEC_PER_SEC; +// // tp->tv_nsec = (uint32_t)(abstime % (uint64_t)NSEC_PER_SEC); +// // return 0; +// // } +// // +// // #else /* !__LP64__ */ +// +// static struct mach_timebase_info g_mti; +// +// int +// clock_gettime (clockid_t clk_id, struct timespec * tp) +// { +// int64_t abstime = 0; +// mach_timebase_info_data_t mti; /* {uint32_t numer, uint32_t denom} */ +// if (tp == NULL) { +// return EFAULT; +// } +// switch (clk_id) { +// case CLOCK_REALTIME: +// struct timeval tv; +// if (gettimeofday (&tv, NULL) != 0) { +// return -1; +// } +// tp->tv_sec = tv.tv_sec; +// tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC; +// return 0; +// case CLOCK_MONOTONIC: +// abstime = mach_absolute_time (); +// break; +// default: +// errno = EINVAL; +// return -1; +// } +// if (g_mti.denom == 0) { +// struct mach_timebase_info mti; +// mach_timebase_info (&mti); +// g_mti.numer = mti.numer; +// OSMemoryBarrier (); +// g_mti.denom = mti.denom; +// } +// nanos = (uint64_t)(abstime * (((double)g_mti.numer) / ((double)g_mti.denom))); +// tp->tv_sec = nanos / (uint64_t)NSEC_PER_SEC; +// tp->tv_nsec = (uint32_t)(nanos % (uint64_t)NSEC_PER_SEC); +// return 0; +// } +// +// // #endif /* !__LP64__ */ +// +// #else /* !__APPLE__ */ +// +// #ifdef __GNUC__ +// // error: ISO C forbids an empty translation unit +// int dummy_var_gu_time; +// #endif + #endif /* __APPLE__ */ diff --git a/galerautils/src/gu_time.h b/galerautils/src/gu_time.h index 7cdcf1c14..43ca512e2 100644 --- a/galerautils/src/gu_time.h +++ b/galerautils/src/gu_time.h @@ -54,12 +54,12 @@ gu_clock_diff (clock_t left, clock_t right) /* Maximum date representable by long long and compatible with timespec */ #define GU_TIME_ETERNITY 9223372035999999999LL -#if defined(__APPLE__) /* synced with linux/time.h */ -# define CLOCK_REALTIME 0 -# define CLOCK_MONOTONIC 1 -typedef int clockid_t; -int clock_gettime (clockid_t clk_id, struct timespec * tp); -#endif /* __APPLE__ */ +// #if defined(__APPLE__) /* synced with linux/time.h */ +// # define CLOCK_REALTIME 0 +// # define CLOCK_MONOTONIC 1 +// typedef int clockid_t; +// int clock_gettime (clockid_t clk_id, struct timespec * tp); +// #endif /* __APPLE__ */ static inline long long gu_time_getres() diff --git a/galerautils/tests/CMakeLists.txt b/galerautils/tests/CMakeLists.txt index a44b2d6b3..36522a7d3 100644 --- a/galerautils/tests/CMakeLists.txt +++ b/galerautils/tests/CMakeLists.txt @@ -102,7 +102,7 @@ target_compile_options(deqmap_bench PRIVATE -Wno-conversion) -target_link_libraries(deqmap_bench galerautilsxx rt) +target_link_libraries(deqmap_bench galerautilsxx) # # CRC32C micro benchmark. diff --git a/gcache/src/CMakeLists.txt b/gcache/src/CMakeLists.txt index e518c89d1..f174f6b4d 100644 --- a/gcache/src/CMakeLists.txt +++ b/gcache/src/CMakeLists.txt @@ -33,7 +33,7 @@ target_link_libraries(gcache galerautilsxx) add_executable(gcache_test test.cpp) -target_link_libraries(gcache_test gcache pthread rt) +target_link_libraries(gcache_test gcache pthread) target_compile_options(gcache_test PRIVATE diff --git a/gcs/src/gcs_group.cpp b/gcs/src/gcs_group.cpp index a46b8ca57..bb355cd98 100644 --- a/gcs/src/gcs_group.cpp +++ b/gcs/src/gcs_group.cpp @@ -61,6 +61,7 @@ gcs_group_init (gcs_group_t* group, gu::Config* const cnf, gcache_t* const cache int const appl_proto_ver) { // here we also create default node instance. + new (&group->memb_mtx_) gu::Mutex(NULL); group->cache = cache; group->act_id_ = GCS_SEQNO_ILL; group->conf_id = GCS_SEQNO_ILL; @@ -185,8 +186,13 @@ gcs_group_free (gcs_group_t* group) if (group->my_address) free ((char*)group->my_address); delete group->vote_history; - gu::Lock lock(group->memb_mtx_); - group_nodes_free (group); + { + gu::Lock lock(group->memb_mtx_); + group_nodes_free (group); + } + + // manually release memb_mtx_ after placement-new. + group->memb_mtx_.~Mutex(); } /* Reset nodes array without breaking the statistics */