From 4fdec4d1f3c8a2ace89f7bea2ebcbee319dd5afe Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 13 Aug 2018 13:33:23 +0300 Subject: [PATCH] MXS-2004 Replace pthread_self() with std::this_thread::get_id() --- server/modules/routing/binlogrouter/blr.h | 4 +++- .../modules/routing/binlogrouter/blr_master.cc | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/server/modules/routing/binlogrouter/blr.h b/server/modules/routing/binlogrouter/blr.h index 641861463..6a10ec0dc 100644 --- a/server/modules/routing/binlogrouter/blr.h +++ b/server/modules/routing/binlogrouter/blr.h @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include @@ -534,7 +536,7 @@ typedef struct router_slave /*< lsi: Last Sent Information */ blr_thread_role_t lsi_sender_role; /*< Master or slave code sent */ - uint64_t lsi_sender_tid; + std::thread::id lsi_sender_tid; /*< Who sent */ char lsi_binlog_name[BINLOG_FNAMELEN + 1]; /*< Which binlog file */ diff --git a/server/modules/routing/binlogrouter/blr_master.cc b/server/modules/routing/binlogrouter/blr_master.cc index 753e8e930..4347c569e 100644 --- a/server/modules/routing/binlogrouter/blr_master.cc +++ b/server/modules/routing/binlogrouter/blr_master.cc @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -1732,18 +1732,23 @@ bool blr_send_event(blr_thread_role_t role, if ((strcmp(slave->lsi_binlog_name, binlog_name) == 0) && (slave->lsi_binlog_pos == binlog_pos)) { + std::stringstream t1; + std::stringstream t2; + t1 << std::this_thread::get_id(); + t2 << slave->lsi_sender_tid; + MXS_ERROR("Slave %s:%i, server-id %d, binlog '%s', position %u: " - "thread %lu in the role of %s could not send the event, " - "the event has already been sent by thread %lu in the role of %s. " + "thread %s in the role of %s could not send the event, " + "the event has already been sent by thread %s in the role of %s. " "%u bytes buffered for writing in DCB %p. %lu events received from master.", slave->dcb->remote, dcb_get_port(slave->dcb), slave->serverid, binlog_name, binlog_pos, - (uint64_t)pthread_self(), + t1.str().c_str(), ROLETOSTR(role), - (uint64_t)slave->lsi_sender_tid, + t2.str().c_str(), ROLETOSTR(slave->lsi_sender_role), gwbuf_length(slave->dcb->writeq), slave->dcb, slave->router->stats.n_binlogs); @@ -1794,7 +1799,7 @@ bool blr_send_event(blr_thread_role_t role, strcpy(slave->lsi_binlog_name, binlog_name); slave->lsi_binlog_pos = binlog_pos; slave->lsi_sender_role = role; - slave->lsi_sender_tid = pthread_self(); + slave->lsi_sender_tid = std::this_thread::get_id(); } else {