sf_binlog_writer_rotate_file can skip empty file
parent
e9e33883bf
commit
14a783fd6f
|
|
@ -168,6 +168,7 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
|||
SFBinlogWriterBuffer *wb_head, uint32_t *last_timestamp)
|
||||
{
|
||||
int result;
|
||||
bool skip_empty_file;
|
||||
SFBinlogWriterBuffer *wbuffer;
|
||||
SFBinlogWriterBuffer *current;
|
||||
|
||||
|
|
@ -196,12 +197,15 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
|||
thread->mblock, current);
|
||||
break;
|
||||
case SF_BINLOG_BUFFER_TYPE_ROTATE_FILE:
|
||||
skip_empty_file = current->version.first;
|
||||
if (!(skip_empty_file && current->writer->fw.file.size == 0)) {
|
||||
if ((result=sf_file_writer_set_binlog_write_index(¤t->
|
||||
writer->fw, current->writer->fw.binlog.
|
||||
last_index + 1)) != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
fast_mblock_free_object(¤t->writer->
|
||||
thread->mblock, current);
|
||||
break;
|
||||
|
|
@ -623,10 +627,12 @@ int sf_binlog_writer_change_write_index(SFBinlogWriterInfo *writer,
|
|||
SF_BINLOG_BUFFER_TYPE_SET_WRITE_INDEX, write_index);
|
||||
}
|
||||
|
||||
int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer)
|
||||
int sf_binlog_writer_rotate_file_ex(SFBinlogWriterInfo *writer,
|
||||
const bool skip_empty_file)
|
||||
{
|
||||
return sf_binlog_writer_push_directive(writer,
|
||||
SF_BINLOG_BUFFER_TYPE_ROTATE_FILE, 0);
|
||||
SF_BINLOG_BUFFER_TYPE_ROTATE_FILE,
|
||||
skip_empty_file ? 1 : 0);
|
||||
}
|
||||
|
||||
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer)
|
||||
|
|
|
|||
|
|
@ -235,7 +235,14 @@ static inline int sf_binlog_writer_get_thread_waiting_count(
|
|||
return waiting_count;
|
||||
}
|
||||
|
||||
int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer);
|
||||
int sf_binlog_writer_rotate_file_ex(SFBinlogWriterInfo *writer,
|
||||
const bool skip_empty_file);
|
||||
|
||||
static inline int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer)
|
||||
{
|
||||
const bool skip_empty_file = false;
|
||||
return sf_binlog_writer_rotate_file_ex(writer, skip_empty_file);
|
||||
}
|
||||
|
||||
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue