sf_binlog_writer removes global variable: g_sf_binlog_data_path

storage_engine
YuQing 2021-09-21 09:26:10 +08:00
parent db858fc048
commit fb7ffa0b1d
2 changed files with 30 additions and 30 deletions

View File

@ -34,8 +34,6 @@
#include "sf_func.h"
#include "sf_binlog_writer.h"
char *g_sf_binlog_data_path = NULL;
static inline void binlog_writer_set_next_version(SFBinlogWriterInfo *writer,
const uint64_t next_version)
{
@ -341,16 +339,18 @@ static int binlog_wbuffer_alloc_init(void *element, void *args)
}
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
const char *subdir_name, const int buffer_size)
const char *data_path, const char *subdir_name,
const int buffer_size)
{
writer->flush.in_queue = false;
return sf_file_writer_init_normal(&writer->fw,
g_sf_binlog_data_path, subdir_name, buffer_size);
data_path, subdir_name, buffer_size);
}
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
const char *subdir_name, const uint64_t next_version,
const int buffer_size, const int ring_size)
const char *data_path, const char *subdir_name,
const uint64_t next_version, const int buffer_size,
const int ring_size)
{
int bytes;
@ -366,7 +366,8 @@ int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
writer->version_ctx.change_count = 0;
binlog_writer_set_next_version(writer, next_version);
return sf_binlog_writer_init_normal(writer, subdir_name, buffer_size);
return sf_binlog_writer_init_normal(writer,
data_path, subdir_name, buffer_size);
}
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,

View File

@ -96,14 +96,14 @@ typedef struct sf_binlog_writer_context {
extern "C" {
#endif
extern char *g_sf_binlog_data_path;
int sf_binlog_writer_init_normal(SFBinlogWriterInfo *writer,
const char *subdir_name, const int buffer_size);
const char *data_path, const char *subdir_name,
const int buffer_size);
int sf_binlog_writer_init_by_version(SFBinlogWriterInfo *writer,
const char *subdir_name, const uint64_t next_version,
const int buffer_size, const int ring_size);
const char *data_path, const char *subdir_name,
const uint64_t next_version, const int buffer_size,
const int ring_size);
int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
const char *name, SFBinlogWriterInfo *writer, const short order_mode,
@ -117,12 +117,12 @@ int sf_binlog_writer_init_thread_ex(SFBinlogWriterThread *thread,
order_by, max_record_size, 1, true)
static inline int sf_binlog_writer_init(SFBinlogWriterContext *context,
const char *subdir_name, const int buffer_size,
const int max_record_size)
const char *data_path, const char *subdir_name,
const int buffer_size, const int max_record_size)
{
int result;
if ((result=sf_binlog_writer_init_normal(&context->writer,
subdir_name, buffer_size)) != 0)
data_path, subdir_name, buffer_size)) != 0)
{
return result;
}
@ -139,18 +139,18 @@ int sf_binlog_writer_change_next_version(SFBinlogWriterInfo *writer,
const int64_t next_version);
#define sf_binlog_writer_set_flags(writer, flags) \
sf_file_writer_set_flags(&writer->fw, flags)
sf_file_writer_set_flags(&(writer)->fw, flags)
#define sf_binlog_writer_get_last_version(writer) \
sf_file_writer_get_last_version(&writer->fw)
sf_file_writer_get_last_version(&(writer)->fw)
void sf_binlog_writer_finish(SFBinlogWriterInfo *writer);
#define sf_binlog_get_current_write_index(writer) \
sf_file_writer_get_current_index(&writer->fw)
sf_file_writer_get_current_index(&(writer)->fw)
#define sf_binlog_get_current_write_position(writer, position) \
sf_file_writer_get_current_position(&writer->fw, position)
sf_file_writer_get_current_position(&(writer)->fw, position)
static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_buffer(
SFBinlogWriterThread *thread)
@ -183,17 +183,16 @@ static inline SFBinlogWriterBuffer *sf_binlog_writer_alloc_versioned_buffer_ex(
return buffer;
}
#define sf_binlog_writer_get_filepath(subdir_name, filename, size) \
sf_file_writer_get_filepath(g_sf_binlog_data_path, \
subdir_name, filename, size)
#define sf_binlog_writer_get_filepath(data_path, subdir_name, filename, size) \
sf_file_writer_get_filepath(data_path, subdir_name, filename, size)
#define sf_binlog_writer_get_filename(subdir_name, \
binlog_index, filename, size) \
sf_file_writer_get_filename(g_sf_binlog_data_path, \
subdir_name, binlog_index, filename, size)
#define sf_binlog_writer_get_filename(data_path, \
subdir_name, binlog_index, filename, size) \
sf_file_writer_get_filename(data_path, subdir_name, \
binlog_index, filename, size)
#define sf_binlog_writer_set_binlog_index(writer, binlog_index) \
sf_file_writer_set_binlog_index(writer, binlog_index)
sf_file_writer_set_binlog_index(&(writer)->fw, binlog_index)
#define sf_push_to_binlog_thread_queue(thread, buffer) \
fc_queue_push(&(thread)->queue, buffer)
@ -205,9 +204,9 @@ static inline void sf_push_to_binlog_write_queue(SFBinlogWriterInfo *writer,
fc_queue_push(&writer->thread->queue, buffer);
}
#define sf_binlog_writer_get_last_lines(subdir_name, current_write_index, \
buff, buff_size, count, length) \
sf_file_writer_get_last_lines(g_sf_binlog_data_path, subdir_name, \
#define sf_binlog_writer_get_last_lines(data_path, subdir_name, \
current_write_index, buff, buff_size, count, length) \
sf_file_writer_get_last_lines(data_path, subdir_name, \
current_write_index, buff, buff_size, count, length)
#ifdef __cplusplus