commit
0a901897e8
13
HISTORY
13
HISTORY
|
|
@ -1,7 +1,18 @@
|
|||
|
||||
Version 5.06 2014-12-04
|
||||
Version 5.07 2015-09-13
|
||||
* schedule task add the "second" field
|
||||
* make.sh changed, you must upgrade libfastcommon to V1.21 or later
|
||||
* bug fixed: storage_disk_recovery.c skip the first file (binlog first line)
|
||||
* bug fixed: should close connection after fetch binlog
|
||||
* fdfs_storaged.c: advance the position of daemon_init
|
||||
* set log rotate time format
|
||||
* bug fixed: must check store_path_index
|
||||
|
||||
Version 5.06 2015-05-12
|
||||
* compile passed in mac OS Darwin
|
||||
* correct scripts in subdir init.d
|
||||
* check item thread_stack_size in storage.conf, you must
|
||||
upgrade libfastcommon to V1.14 or later
|
||||
|
||||
Version 5.05 2014-11-22
|
||||
* tracker_mem.c log more info
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef _OS_BITS_H
|
||||
#define _OS_BITS_H
|
||||
|
||||
#define OS_BITS 64
|
||||
#define OFF_BITS 64
|
||||
|
||||
#endif
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
int g_fdfs_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
int g_fdfs_network_timeout = DEFAULT_NETWORK_TIMEOUT;
|
||||
char g_fdfs_base_path[MAX_PATH_SIZE] = {'/', 't', 'm', 'p', '\0'};
|
||||
Version g_fdfs_version = {5, 6};
|
||||
Version g_fdfs_version = {5, 7};
|
||||
bool g_use_connection_pool = false;
|
||||
ConnectionPool g_connection_pool;
|
||||
int g_connection_pool_max_idle_time = 3600;
|
||||
|
|
|
|||
|
|
@ -137,10 +137,13 @@ run_by_group=
|
|||
run_by_user=
|
||||
|
||||
# allow_hosts can ocur more than once, host can be hostname or ip address,
|
||||
# "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or
|
||||
# host[01-08,20-25].domain.com, for example:
|
||||
# "*" (only one asterisk) means match all ip addresses
|
||||
# we can use CIDR ips like 192.168.5.64/26
|
||||
# and also use range like these: 10.0.1.[0-254] and host[01-08,20-25].domain.com
|
||||
# for example:
|
||||
# allow_hosts=10.0.1.[1-15,20]
|
||||
# allow_hosts=host[01-08,20-25].domain.com
|
||||
# allow_hosts=192.168.5.64/26
|
||||
allow_hosts=*
|
||||
|
||||
# the mode of the files distributed to the data path
|
||||
|
|
|
|||
|
|
@ -92,10 +92,13 @@ run_by_group=
|
|||
run_by_user=
|
||||
|
||||
# allow_hosts can ocur more than once, host can be hostname or ip address,
|
||||
# "*" means match all ip addresses, can use range like this: 10.0.1.[1-15,20] or
|
||||
# host[01-08,20-25].domain.com, for example:
|
||||
# "*" (only one asterisk) means match all ip addresses
|
||||
# we can use CIDR ips like 192.168.5.64/26
|
||||
# and also use range like these: 10.0.1.[0-254] and host[01-08,20-25].domain.com
|
||||
# for example:
|
||||
# allow_hosts=10.0.1.[1-15,20]
|
||||
# allow_hosts=host[01-08,20-25].domain.com
|
||||
# allow_hosts=192.168.5.64/26
|
||||
allow_hosts=*
|
||||
|
||||
# sync log buff to disk every interval seconds
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%define FDFSServer fastdfs-server
|
||||
%define FDFSClient libfdfsclient
|
||||
%define FDFSTool fastdfs-tool
|
||||
%define FDFSVersion 5.0.5
|
||||
%define FDFSVersion 5.0.7
|
||||
|
||||
Name: %{FastDFS}
|
||||
Version: %{FDFSVersion}
|
||||
|
|
@ -16,12 +16,13 @@ Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.gz
|
|||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id
|
||||
BuildRequires: libfastcommon-devel >= 1.0.21
|
||||
|
||||
%description
|
||||
This package provides tracker & storage of fastdfs
|
||||
|
||||
%package -n %{FDFSServer}
|
||||
Requires: libfastcommon
|
||||
Requires: libfastcommon >= 1.0.21
|
||||
Summary: fastdfs tracker & storage
|
||||
|
||||
%package -n %{FDFSTool}
|
||||
|
|
|
|||
24
make.sh
24
make.sh
|
|
@ -46,16 +46,6 @@ else
|
|||
OFF_BITS=32
|
||||
fi
|
||||
|
||||
cat <<EOF > common/_os_bits.h
|
||||
#ifndef _OS_BITS_H
|
||||
#define _OS_BITS_H
|
||||
|
||||
#define OS_BITS $OS_BITS
|
||||
#define OFF_BITS $OFF_BITS
|
||||
|
||||
#endif
|
||||
EOF
|
||||
|
||||
ENABLE_STATIC_LIB=0
|
||||
ENABLE_SHARED_LIB=1
|
||||
TARGET_PREFIX=$DESTDIR/usr
|
||||
|
|
@ -75,28 +65,28 @@ fi
|
|||
|
||||
LIBS=''
|
||||
if [ $OS_BITS -eq 64 ]; then
|
||||
LIBS='-L/usr/lib64'
|
||||
LIBS="$LIBS -L/usr/lib64"
|
||||
else
|
||||
LIBS='-L/usr/lib'
|
||||
LIBS="$LIBS -L/usr/lib"
|
||||
fi
|
||||
|
||||
uname=$(uname)
|
||||
if [ "$uname" = "Linux" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_LINUX -DIOEVENT_USE_EPOLL"
|
||||
CFLAGS="$CFLAGS"
|
||||
elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_FREEBSD -DIOEVENT_USE_KQUEUE"
|
||||
CFLAGS="$CFLAGS"
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DDARWIN"
|
||||
fi
|
||||
elif [ "$uname" = "SunOS" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_SUNOS -D_THREAD_SAFE -DIOEVENT_USE_PORT"
|
||||
CFLAGS="$CFLAGS -D_THREAD_SAFE"
|
||||
LIBS="$LIBS -lsocket -lnsl -lresolv"
|
||||
export CC=gcc
|
||||
elif [ "$uname" = "AIX" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_AIX -D_THREAD_SAFE"
|
||||
CFLAGS="$CFLAGS -D_THREAD_SAFE"
|
||||
export CC=gcc
|
||||
elif [ "$uname" = "HP-UX" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_HPUX"
|
||||
CFLAGS="$CFLAGS"
|
||||
fi
|
||||
|
||||
have_pthread=0
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
daemon_init(false);
|
||||
umask(0);
|
||||
|
||||
memset(g_bind_addr, 0, sizeof(g_bind_addr));
|
||||
if ((result=storage_func_init(conf_filename, \
|
||||
g_bind_addr, sizeof(g_bind_addr))) != 0)
|
||||
|
|
@ -168,8 +171,6 @@ int main(int argc, char *argv[])
|
|||
return result;
|
||||
}
|
||||
|
||||
daemon_init(false);
|
||||
umask(0);
|
||||
if ((result=write_to_pid_file(pidFilename)) != 0)
|
||||
{
|
||||
log_destroy();
|
||||
|
|
@ -312,79 +313,54 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
scheduleArray.entries = scheduleEntries;
|
||||
|
||||
scheduleArray.count = 0;
|
||||
memset(scheduleEntries, 0, sizeof(scheduleEntries));
|
||||
scheduleEntries[0].id = 1;
|
||||
scheduleEntries[0].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[0].time_base.minute = TIME_NONE;
|
||||
scheduleEntries[0].interval = g_sync_log_buff_interval;
|
||||
scheduleEntries[0].task_func = log_sync_func;
|
||||
scheduleEntries[0].func_args = &g_log_context;
|
||||
|
||||
scheduleEntries[1].id = 2;
|
||||
scheduleEntries[1].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[1].time_base.minute = TIME_NONE;
|
||||
scheduleEntries[1].interval = g_sync_binlog_buff_interval;
|
||||
scheduleEntries[1].task_func = fdfs_binlog_sync_func;
|
||||
scheduleEntries[1].func_args = NULL;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_sync_log_buff_interval, log_sync_func, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
scheduleEntries[2].id = 3;
|
||||
scheduleEntries[2].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[2].time_base.minute = TIME_NONE;
|
||||
scheduleEntries[2].interval = g_sync_stat_file_interval;
|
||||
scheduleEntries[2].task_func = fdfs_stat_file_sync_func;
|
||||
scheduleEntries[2].func_args = NULL;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_sync_binlog_buff_interval, fdfs_binlog_sync_func, NULL);
|
||||
scheduleArray.count++;
|
||||
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_sync_stat_file_interval, fdfs_stat_file_sync_func, NULL);
|
||||
scheduleArray.count++;
|
||||
|
||||
scheduleArray.count = 3;
|
||||
if (g_if_use_trunk_file)
|
||||
{
|
||||
scheduleEntries[scheduleArray.count].id = 4;
|
||||
scheduleEntries[scheduleArray.count].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[scheduleArray.count].time_base.minute=TIME_NONE;
|
||||
scheduleEntries[scheduleArray.count].interval = 1;
|
||||
scheduleEntries[scheduleArray.count].task_func = \
|
||||
trunk_binlog_sync_func;
|
||||
scheduleEntries[scheduleArray.count].func_args = NULL;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
1, trunk_binlog_sync_func, NULL);
|
||||
scheduleArray.count++;
|
||||
}
|
||||
|
||||
if (g_use_access_log)
|
||||
{
|
||||
scheduleEntries[scheduleArray.count].id = 5;
|
||||
scheduleEntries[scheduleArray.count].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[scheduleArray.count].time_base.minute=TIME_NONE;
|
||||
scheduleEntries[scheduleArray.count].interval = \
|
||||
g_sync_log_buff_interval;
|
||||
scheduleEntries[scheduleArray.count].task_func = log_sync_func;
|
||||
scheduleEntries[scheduleArray.count].func_args = \
|
||||
&g_access_log_context;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_sync_log_buff_interval, log_sync_func, &g_access_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
if (g_rotate_access_log)
|
||||
{
|
||||
scheduleEntries[scheduleArray.count].id = 6;
|
||||
scheduleEntries[scheduleArray.count].time_base = \
|
||||
g_access_log_rotate_time;
|
||||
scheduleEntries[scheduleArray.count].interval = \
|
||||
24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func = \
|
||||
log_notify_rotate;
|
||||
scheduleEntries[scheduleArray.count].func_args = \
|
||||
&g_access_log_context;
|
||||
INIT_SCHEDULE_ENTRY_EX(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, g_access_log_rotate_time,
|
||||
24 * 3600, log_notify_rotate, &g_access_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
if (g_log_file_keep_days > 0)
|
||||
{
|
||||
log_set_keep_days(&g_access_log_context,
|
||||
g_log_file_keep_days);
|
||||
scheduleEntries[scheduleArray.count].id = 7;
|
||||
scheduleEntries[scheduleArray.count].time_base.hour = 1;
|
||||
scheduleEntries[scheduleArray.count].time_base.minute = 0;
|
||||
scheduleEntries[scheduleArray.count].interval = 24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func =
|
||||
log_delete_old_files;
|
||||
scheduleEntries[scheduleArray.count].func_args =
|
||||
&g_access_log_context;
|
||||
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, 1, 0, 0, 24 * 3600,
|
||||
log_delete_old_files, &g_access_log_context);
|
||||
scheduleArray.count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -392,28 +368,18 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (g_rotate_error_log)
|
||||
{
|
||||
scheduleEntries[scheduleArray.count].id = 8;
|
||||
scheduleEntries[scheduleArray.count].time_base = \
|
||||
g_error_log_rotate_time;
|
||||
scheduleEntries[scheduleArray.count].interval = \
|
||||
24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func = \
|
||||
log_notify_rotate;
|
||||
scheduleEntries[scheduleArray.count].func_args = \
|
||||
&g_log_context;
|
||||
INIT_SCHEDULE_ENTRY_EX(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, g_error_log_rotate_time,
|
||||
24 * 3600, log_notify_rotate, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
if (g_log_file_keep_days > 0)
|
||||
{
|
||||
log_set_keep_days(&g_log_context, g_log_file_keep_days);
|
||||
scheduleEntries[scheduleArray.count].id = 9;
|
||||
scheduleEntries[scheduleArray.count].time_base.hour = 1;
|
||||
scheduleEntries[scheduleArray.count].time_base.minute = 0;
|
||||
scheduleEntries[scheduleArray.count].interval = 24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func =
|
||||
log_delete_old_files;
|
||||
scheduleEntries[scheduleArray.count].func_args =
|
||||
&g_log_context;
|
||||
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, 1, 0, 0, 24 * 3600,
|
||||
log_delete_old_files, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -497,6 +497,17 @@ static int recovery_reader_init(const char *pBasePath, \
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int recovery_reader_check_init(const char *pBasePath, \
|
||||
StorageBinLogReader *pReader)
|
||||
{
|
||||
if (pReader->binlog_fd >= 0 && pReader->binlog_buff.buffer != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return recovery_reader_init(pBasePath, pReader);
|
||||
}
|
||||
|
||||
static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pReader, \
|
||||
ConnectionInfo *pSrcStorage)
|
||||
{
|
||||
|
|
@ -512,6 +523,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
int64_t file_size;
|
||||
int64_t total_count;
|
||||
int64_t success_count;
|
||||
int64_t noent_count;
|
||||
bool bContinueFlag;
|
||||
char local_filename[MAX_PATH_SIZE];
|
||||
char src_filename[MAX_PATH_SIZE];
|
||||
|
|
@ -520,6 +532,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
count = 0;
|
||||
total_count = 0;
|
||||
success_count = 0;
|
||||
noent_count = 0;
|
||||
result = 0;
|
||||
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -529,6 +542,10 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
bContinueFlag = true;
|
||||
while (bContinueFlag)
|
||||
{
|
||||
if ((result=recovery_reader_check_init(pBasePath, pReader)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ((pStorageConn=tracker_connect_server(pSrcStorage, &result)) == NULL)
|
||||
{
|
||||
sleep(5);
|
||||
|
|
@ -605,7 +622,12 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
|
||||
success_count++;
|
||||
}
|
||||
else if (result != ENOENT)
|
||||
else if (result == ENOENT)
|
||||
{
|
||||
result = 0;
|
||||
noent_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -673,6 +695,10 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
bContinueFlag = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -692,25 +718,30 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
|||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"disk recovery: recover path: %s, " \
|
||||
"file count: %"PRId64 \
|
||||
", success count: %"PRId64, \
|
||||
", success count: %"PRId64", noent_count: %"PRId64, \
|
||||
__LINE__, pBasePath, total_count, \
|
||||
success_count);
|
||||
success_count, noent_count);
|
||||
recovery_write_to_mark_file(pBasePath, pReader);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
tracker_disconnect_server_ex(pStorageConn, result != 0);
|
||||
recovery_write_to_mark_file(pBasePath, pReader);
|
||||
if (bContinueFlag)
|
||||
{
|
||||
storage_reader_destroy(pReader);
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
recovery_write_to_mark_file(pBasePath, pReader);
|
||||
count = 0;
|
||||
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"disk recovery: recover path: %s, " \
|
||||
"file count: %"PRId64 \
|
||||
", success count: %"PRId64, \
|
||||
__LINE__, pBasePath, total_count, success_count);
|
||||
", success count: %"PRId64", noent_count: %"PRId64, \
|
||||
__LINE__, pBasePath, total_count, success_count, noent_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1086,7 +1117,7 @@ int storage_disk_recovery_start(const int store_path_index)
|
|||
}
|
||||
|
||||
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
||||
tracker_disconnect_server_ex(pStorageConn, result != 0);
|
||||
tracker_disconnect_server_ex(pStorageConn, true);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1530,12 +1530,12 @@ int storage_func_init(const char *filename, \
|
|||
}
|
||||
g_thread_stack_size = (int)thread_stack_size;
|
||||
|
||||
if (g_thread_stack_size < 64 * 1024)
|
||||
if (g_thread_stack_size < FAST_WRITE_BUFF_SIZE + 64 * 1024)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"thread_stack_size\" %d is invalid, " \
|
||||
"which < %d", __LINE__, g_thread_stack_size, \
|
||||
64 * 1024);
|
||||
FAST_WRITE_BUFF_SIZE + 64 * 1024);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1693,7 +1693,7 @@ int storage_func_init(const char *filename, \
|
|||
rotate_access_log_size);
|
||||
rotate_access_log_size = FDFS_ONE_MB;
|
||||
}
|
||||
g_access_log_context.rotate_size = rotate_access_log_size;
|
||||
fdfs_set_log_rotate_size(&g_access_log_context, rotate_access_log_size);
|
||||
|
||||
pRotateErrorLogSize = iniGetStrValue(NULL, \
|
||||
"rotate_error_log_size", &iniContext);
|
||||
|
|
@ -1716,7 +1716,7 @@ int storage_func_init(const char *filename, \
|
|||
rotate_error_log_size);
|
||||
rotate_error_log_size = FDFS_ONE_MB;
|
||||
}
|
||||
g_log_context.rotate_size = rotate_error_log_size;
|
||||
fdfs_set_log_rotate_size(&g_log_context, rotate_error_log_size);
|
||||
|
||||
g_log_file_keep_days = iniGetIntValue(NULL, \
|
||||
"log_file_keep_days", &iniContext, 0);
|
||||
|
|
@ -2155,7 +2155,7 @@ int recv_file_serialized(int sock, const char *filename, \
|
|||
const int64_t file_bytes)
|
||||
{
|
||||
int fd;
|
||||
char buff[FDFS_WRITE_BUFF_SIZE];
|
||||
char buff[FAST_WRITE_BUFF_SIZE];
|
||||
int64_t remain_bytes;
|
||||
int recv_bytes;
|
||||
int result;
|
||||
|
|
|
|||
|
|
@ -3758,6 +3758,15 @@ static int storage_server_trunk_alloc_space(struct fast_task_info *pTask)
|
|||
}
|
||||
|
||||
trunkInfo.path.store_path_index = *(in_buff+FDFS_GROUP_NAME_MAX_LEN+4);
|
||||
if (trunkInfo.path.store_path_index < 0 ||
|
||||
trunkInfo.path.store_path_index >= g_fdfs_store_paths.count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, store_path_index: %d " \
|
||||
"is invalid", __LINE__, \
|
||||
pTask->client_ip, trunkInfo.path.store_path_index);
|
||||
return EINVAL;
|
||||
}
|
||||
if ((result=trunk_alloc_space(file_size, &trunkInfo)) != 0)
|
||||
{
|
||||
return result;
|
||||
|
|
@ -3981,6 +3990,16 @@ static int storage_server_trunk_confirm_or_free(struct fast_task_info *pTask)
|
|||
trunkInfo.file.offset = buff2int(pTrunkBuff->offset);
|
||||
trunkInfo.file.size = buff2int(pTrunkBuff->size);
|
||||
|
||||
if (trunkInfo.path.store_path_index < 0 ||
|
||||
trunkInfo.path.store_path_index >= g_fdfs_store_paths.count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, store_path_index: %d " \
|
||||
"is invalid", __LINE__, \
|
||||
pTask->client_ip, trunkInfo.path.store_path_index);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (pHeader->cmd == STORAGE_PROTO_CMD_TRUNK_ALLOC_CONFIRM)
|
||||
{
|
||||
return trunk_alloc_confirm(&trunkInfo, pHeader->status);
|
||||
|
|
@ -4268,6 +4287,7 @@ static int storage_server_do_fetch_one_path_binlog( \
|
|||
if ((result=storage_reader_init(NULL, pReader)) != 0)
|
||||
{
|
||||
storage_reader_destroy(pReader);
|
||||
free(pReader);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -750,6 +750,15 @@ static int storage_trunk_restore(const int64_t restore_offset)
|
|||
break;
|
||||
}
|
||||
|
||||
if (record.trunk.path.store_path_index < 0 ||
|
||||
record.trunk.path.store_path_index >= g_fdfs_store_paths.count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"store_path_index: %d is invalid", __LINE__, \
|
||||
record.trunk.path.store_path_index);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
line_count++;
|
||||
if (record.op_type == TRUNK_OP_TYPE_ADD_SPACE)
|
||||
{
|
||||
|
|
@ -784,8 +793,7 @@ static int storage_trunk_restore(const int64_t restore_offset)
|
|||
logError("file: "__FILE__", line: %d, "\
|
||||
"avl_tree_insert fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, result, \
|
||||
STRERROR(result));
|
||||
__LINE__, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
else if (result == 0)
|
||||
|
|
|
|||
|
|
@ -1016,3 +1016,17 @@ void fdfs_connection_pool_destroy()
|
|||
conn_pool_destroy(&g_connection_pool);
|
||||
}
|
||||
|
||||
void fdfs_set_log_rotate_size(LogContext *pContext, const int64_t log_rotate_size)
|
||||
{
|
||||
if (log_rotate_size > 0)
|
||||
{
|
||||
pContext->rotate_size = log_rotate_size;
|
||||
log_set_rotate_time_format(pContext, "%Y%m%d_%H%M%S");
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->rotate_size = 0;
|
||||
log_set_rotate_time_format(pContext, "%Y%m%d");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "common_define.h"
|
||||
#include "ini_file_reader.h"
|
||||
#include "logger.h"
|
||||
#include "tracker_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -77,6 +78,8 @@ int fdfs_connection_pool_init(const char *config_filename, \
|
|||
|
||||
void fdfs_connection_pool_destroy();
|
||||
|
||||
void fdfs_set_log_rotate_size(LogContext *pContext, const int64_t log_rotate_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -313,54 +313,39 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
scheduleArray.entries = scheduleEntries;
|
||||
scheduleArray.count = 0;
|
||||
memset(scheduleEntries, 0, sizeof(scheduleEntries));
|
||||
scheduleEntries[0].id = 1;
|
||||
scheduleEntries[0].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[0].time_base.minute = TIME_NONE;
|
||||
scheduleEntries[0].interval = g_sync_log_buff_interval;
|
||||
scheduleEntries[0].task_func = log_sync_func;
|
||||
scheduleEntries[0].func_args = &g_log_context;
|
||||
|
||||
scheduleEntries[1].id = 2;
|
||||
scheduleEntries[1].time_base.hour = TIME_NONE;
|
||||
scheduleEntries[1].time_base.minute = TIME_NONE;
|
||||
scheduleEntries[1].interval = g_check_active_interval;
|
||||
scheduleEntries[1].task_func = tracker_mem_check_alive;
|
||||
scheduleEntries[1].func_args = NULL;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_sync_log_buff_interval, log_sync_func, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
scheduleEntries[2].id = 3;
|
||||
scheduleEntries[2].time_base.hour = 0;
|
||||
scheduleEntries[2].time_base.minute = 0;
|
||||
scheduleEntries[2].interval = TRACKER_SYNC_STATUS_FILE_INTERVAL;
|
||||
scheduleEntries[2].task_func = tracker_write_status_to_file;
|
||||
scheduleEntries[2].func_args = NULL;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, TIME_NONE, TIME_NONE, TIME_NONE,
|
||||
g_check_active_interval, tracker_mem_check_alive, NULL);
|
||||
scheduleArray.count++;
|
||||
|
||||
scheduleArray.count = 3;
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, 0, 0, 0,
|
||||
TRACKER_SYNC_STATUS_FILE_INTERVAL,
|
||||
tracker_write_status_to_file, NULL);
|
||||
scheduleArray.count++;
|
||||
|
||||
if (g_rotate_error_log)
|
||||
{
|
||||
scheduleEntries[scheduleArray.count].id = 4;
|
||||
scheduleEntries[scheduleArray.count].time_base = \
|
||||
g_error_log_rotate_time;
|
||||
scheduleEntries[scheduleArray.count].interval = \
|
||||
24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func = \
|
||||
log_notify_rotate;
|
||||
scheduleEntries[scheduleArray.count].func_args = \
|
||||
&g_log_context;
|
||||
INIT_SCHEDULE_ENTRY_EX(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, g_error_log_rotate_time,
|
||||
24 * 3600, log_notify_rotate, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
|
||||
if (g_log_file_keep_days > 0)
|
||||
{
|
||||
log_set_keep_days(&g_log_context, g_log_file_keep_days);
|
||||
scheduleEntries[scheduleArray.count].id = 5;
|
||||
scheduleEntries[scheduleArray.count].time_base.hour = 1;
|
||||
scheduleEntries[scheduleArray.count].time_base.minute = 0;
|
||||
scheduleEntries[scheduleArray.count].interval = 24 * 3600;
|
||||
scheduleEntries[scheduleArray.count].task_func =
|
||||
log_delete_old_files;
|
||||
scheduleEntries[scheduleArray.count].func_args =
|
||||
&g_log_context;
|
||||
|
||||
INIT_SCHEDULE_ENTRY(scheduleEntries[scheduleArray.count],
|
||||
scheduleArray.count + 1, 1, 0, 0, 24 * 3600,
|
||||
log_delete_old_files, &g_log_context);
|
||||
scheduleArray.count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ int tracker_load_from_conf_file(const char *filename, \
|
|||
rotate_error_log_size);
|
||||
rotate_error_log_size = FDFS_ONE_MB;
|
||||
}
|
||||
g_log_context.rotate_size = rotate_error_log_size;
|
||||
fdfs_set_log_rotate_size(&g_log_context, rotate_error_log_size);
|
||||
|
||||
g_log_file_keep_days = iniGetIntValue(NULL, \
|
||||
"log_file_keep_days", &iniContext, 0);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ bool g_storage_ip_changed_auto_adjust = true;
|
|||
bool g_use_storage_id = false; //if use storage ID instead of IP address
|
||||
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
|
||||
bool g_rotate_error_log = false; //if rotate the error log every day
|
||||
TimeInfo g_error_log_rotate_time = {0, 0}; //rotate error log time base
|
||||
TimeInfo g_error_log_rotate_time = {0, 0, 0}; //rotate error log time base
|
||||
|
||||
int g_thread_stack_size = 64 * 1024;
|
||||
int g_storage_sync_file_max_delay = DEFAULT_STORAGE_SYNC_FILE_MAX_DELAY;
|
||||
|
|
|
|||
Loading…
Reference in New Issue