Skip to content

Commit 7f7bbb2

Browse files
committed
WL#5223: Used std::pair as return type in function sync_binlog_file
as requested in the review process.
1 parent 7cc1a1b commit 7f7bbb2

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

sql/binlog.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,7 +4462,9 @@ bool MYSQL_BIN_LOG::flush_and_sync(const bool force)
44624462
if (flush_io_cache(&log_file))
44634463
return 1;
44644464

4465-
return sync_binlog_file(true, 0);
4465+
std::pair<bool, bool> result= sync_binlog_file(true);
4466+
4467+
return result.first;
44664468
}
44674469

44684470
void MYSQL_BIN_LOG::start_union_events(THD *thd, query_id_t query_id_param)
@@ -6011,21 +6013,19 @@ MYSQL_BIN_LOG::flush_cache_to_file(my_off_t *end_pos_var)
60116013
/**
60126014
Call fsync() to sync the file to disk.
60136015
*/
6014-
int
6015-
MYSQL_BIN_LOG::sync_binlog_file(bool force, bool *synced)
6016+
std::pair<bool, bool>
6017+
MYSQL_BIN_LOG::sync_binlog_file(bool force)
60166018
{
6019+
bool synced= false;
60176020
unsigned int sync_period= get_sync_period();
6018-
if (synced)
6019-
*synced= false;
60206021
if (force || (sync_period && ++sync_counter >= sync_period))
60216022
{
60226023
sync_counter= 0;
60236024
if (mysql_file_sync(log_file.file, MYF(MY_WME)))
6024-
return ER_ERROR_ON_WRITE;
6025-
if (synced)
6026-
*synced= true;
6025+
return std::make_pair(true, synced);
6026+
synced= true;
60276027
}
6028-
return 0;
6028+
return std::make_pair(false, synced);
60296029
}
60306030

60316031

@@ -6182,7 +6182,11 @@ int MYSQL_BIN_LOG::ordered_commit(THD *thd, bool all, bool skip_commit)
61826182
THD *final_queue= stage_manager.fetch_queue_for(Stage_manager::SYNC_STAGE);
61836183
bool synced= false;
61846184
if (flush_error == 0 && total_bytes > 0)
6185-
flush_error= sync_binlog_file(false, &synced);
6185+
{
6186+
std::pair<bool, bool> result= sync_binlog_file(false);
6187+
flush_error= result.first;
6188+
synced= result.second;
6189+
}
61866190

61876191
/*
61886192
If the sync finished successfully, we can call the after_flush

sql/binlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
470470
std::pair<int,my_off_t> flush_thread_caches(THD *thd);
471471
int flush_cache_to_file(my_off_t *flush_end_pos);
472472
int finish_commit(THD *thd);
473-
int sync_binlog_file(bool force, bool *synced);
473+
std::pair<bool, bool> sync_binlog_file(bool force);
474474
void process_commit_stage_queue(THD *thd, THD *queue, int flush_error);
475475
int process_flush_stage_queue(my_off_t *total_bytes_var, bool *rotate_var,
476476
THD **out_queue_var);

0 commit comments

Comments
 (0)