Commit 6a84e340 authored by Andrei Elkin's avatar Andrei Elkin Committed by Monty

MDEV-13073. This patch replaces semisync's native function_enter,exit

and its custom trace faciltiy with standard DBUG_ based equivalents.
parent c0ea3056
...@@ -35,32 +35,6 @@ class Trace { ...@@ -35,32 +35,6 @@ class Trace {
unsigned long trace_level_; /* the level for tracing */ unsigned long trace_level_; /* the level for tracing */
inline void function_enter(const char *func_name)
{
if (trace_level_ & kTraceFunction)
sql_print_information("---> %s enter", func_name);
}
inline int function_exit(const char *func_name, int exit_code)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit (%d)", func_name, exit_code);
return exit_code;
}
inline bool function_exit(const char *func_name, bool exit_code)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit (%s)", func_name,
exit_code ? "True" : "False");
return exit_code;
}
inline void function_exit(const char *func_name)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit", func_name);
}
Trace() Trace()
:trace_level_(0L) :trace_level_(0L)
{} {}
......
This diff is collapsed.
...@@ -36,8 +36,7 @@ pthread_handler_t ack_receive_handler(void *arg) ...@@ -36,8 +36,7 @@ pthread_handler_t ack_receive_handler(void *arg)
Ack_receiver::Ack_receiver() Ack_receiver::Ack_receiver()
{ {
const char *kWho = "Ack_receiver::Ack_receiver"; DBUG_ENTER("Ack_receiver::Ack_receiver");
function_enter(kWho);
m_status= ST_DOWN; m_status= ST_DOWN;
mysql_mutex_init(key_ss_mutex_Ack_receiver_mutex, &m_mutex, mysql_mutex_init(key_ss_mutex_Ack_receiver_mutex, &m_mutex,
...@@ -45,25 +44,23 @@ Ack_receiver::Ack_receiver() ...@@ -45,25 +44,23 @@ Ack_receiver::Ack_receiver()
mysql_cond_init(key_ss_cond_Ack_receiver_cond, &m_cond, NULL); mysql_cond_init(key_ss_cond_Ack_receiver_cond, &m_cond, NULL);
m_pid= 0; m_pid= 0;
function_exit(kWho); DBUG_VOID_RETURN;
} }
void Ack_receiver::cleanup() void Ack_receiver::cleanup()
{ {
const char *kWho = "Ack_receiver::~Ack_receiver"; DBUG_ENTER("Ack_receiver::~Ack_receiver");
function_enter(kWho);
stop(); stop();
mysql_mutex_destroy(&m_mutex); mysql_mutex_destroy(&m_mutex);
mysql_cond_destroy(&m_cond); mysql_cond_destroy(&m_cond);
function_exit(kWho); DBUG_VOID_RETURN;
} }
bool Ack_receiver::start() bool Ack_receiver::start()
{ {
const char *kWho = "Ack_receiver::start"; DBUG_ENTER("Ack_receiver::start");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if(m_status == ST_DOWN) if(m_status == ST_DOWN)
...@@ -87,19 +84,18 @@ bool Ack_receiver::start() ...@@ -87,19 +84,18 @@ bool Ack_receiver::start()
m_status= ST_DOWN; m_status= ST_DOWN;
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, true); DBUG_RETURN(true);
} }
(void) pthread_attr_destroy(&attr); (void) pthread_attr_destroy(&attr);
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, false); DBUG_RETURN(false);
} }
void Ack_receiver::stop() void Ack_receiver::stop()
{ {
const char *kWho = "Ack_receiver::stop"; DBUG_ENTER("Ack_receiver::stop");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if (m_status == ST_UP) if (m_status == ST_UP)
...@@ -116,17 +112,16 @@ void Ack_receiver::stop() ...@@ -116,17 +112,16 @@ void Ack_receiver::stop()
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
function_exit(kWho); DBUG_VOID_RETURN;
} }
bool Ack_receiver::add_slave(THD *thd) bool Ack_receiver::add_slave(THD *thd)
{ {
Slave *slave; Slave *slave;
const char *kWho = "Ack_receiver::add_slave"; DBUG_ENTER("Ack_receiver::add_slave");
function_enter(kWho);
if (!(slave= new Slave)) if (!(slave= new Slave))
return function_exit(kWho, true); DBUG_RETURN(true);
slave->thd= thd; slave->thd= thd;
slave->vio= *thd->net.vio; slave->vio= *thd->net.vio;
...@@ -139,15 +134,14 @@ bool Ack_receiver::add_slave(THD *thd) ...@@ -139,15 +134,14 @@ bool Ack_receiver::add_slave(THD *thd)
mysql_cond_broadcast(&m_cond); mysql_cond_broadcast(&m_cond);
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, false); DBUG_RETURN(false);
} }
void Ack_receiver::remove_slave(THD *thd) void Ack_receiver::remove_slave(THD *thd)
{ {
I_List_iterator<Slave> it(m_slaves); I_List_iterator<Slave> it(m_slaves);
Slave *slave; Slave *slave;
const char *kWho = "Ack_receiver::remove_slave"; DBUG_ENTER("Ack_receiver::remove_slave");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
...@@ -161,7 +155,8 @@ void Ack_receiver::remove_slave(THD *thd) ...@@ -161,7 +155,8 @@ void Ack_receiver::remove_slave(THD *thd)
} }
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
function_exit(kWho);
DBUG_VOID_RETURN;
} }
inline void Ack_receiver::set_stage_info(const PSI_stage_info &stage) inline void Ack_receiver::set_stage_info(const PSI_stage_info &stage)
......
...@@ -58,9 +58,8 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -58,9 +58,8 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
const char **payload, const char **payload,
unsigned long *payload_len) unsigned long *payload_len)
{ {
const char *kWho = "ReplSemiSyncSlave::slaveReadSyncHeader";
int read_res = 0; int read_res = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_slave::slave_read_sync_header");
if (rpl_semi_sync_slave_status) if (rpl_semi_sync_slave_status)
{ {
...@@ -71,8 +70,9 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -71,8 +70,9 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
*payload_len = total_len - 2; *payload_len = total_len - 2;
*payload = header + 2; *payload = header + 2;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: reply - %d",
sql_print_information("%s: reply - %d", kWho, semi_sync_need_reply); "Repl_semi_sync_slave::slave_read_sync_header",
semi_sync_need_reply));
if (semi_sync_need_reply) if (semi_sync_need_reply)
*semi_flags |= SEMI_SYNC_NEED_ACK; *semi_flags |= SEMI_SYNC_NEED_ACK;
...@@ -90,7 +90,7 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -90,7 +90,7 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
*payload_len= total_len; *payload_len= total_len;
} }
return function_exit(kWho, read_res); DBUG_RETURN(read_res);
} }
int ReplSemiSyncSlave::slaveStart(Master_info *mi) int ReplSemiSyncSlave::slaveStart(Master_info *mi)
...@@ -203,7 +203,6 @@ int ReplSemiSyncSlave::requestTransmit(Master_info *mi) ...@@ -203,7 +203,6 @@ int ReplSemiSyncSlave::requestTransmit(Master_info *mi)
int ReplSemiSyncSlave::slaveReply(Master_info *mi) int ReplSemiSyncSlave::slaveReply(Master_info *mi)
{ {
const char *kWho = "ReplSemiSyncSlave::slaveReply";
MYSQL* mysql= mi->mysql; MYSQL* mysql= mi->mysql;
const char *binlog_filename= const_cast<char *>(mi->master_log_name); const char *binlog_filename= const_cast<char *>(mi->master_log_name);
my_off_t binlog_filepos= mi->master_log_pos; my_off_t binlog_filepos= mi->master_log_pos;
...@@ -215,7 +214,7 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -215,7 +214,7 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
int reply_res = 0; int reply_res = 0;
int name_len = strlen(binlog_filename); int name_len = strlen(binlog_filename);
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_slave::slave_reply");
if (rpl_semi_sync_slave_status && semi_sync_need_reply) if (rpl_semi_sync_slave_status && semi_sync_need_reply)
{ {
...@@ -226,9 +225,9 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -226,9 +225,9 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
binlog_filename, binlog_filename,
name_len + 1 /* including trailing '\0' */); name_len + 1 /* including trailing '\0' */);
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: reply (%s, %lu)",
sql_print_information("%s: reply (%s, %lu)", kWho, "Repl_semi_sync_slave::slave_reply",
binlog_filename, (ulong)binlog_filepos); binlog_filename, (ulong)binlog_filepos));
net_clear(net, 0); net_clear(net, 0);
/* Send the reply. */ /* Send the reply. */
...@@ -248,5 +247,5 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -248,5 +247,5 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
} }
} }
return function_exit(kWho, reply_res); DBUG_RETURN(reply_res);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment