use fc_safe_read instead of read, and fc_safe_write instead of write
parent
5d0d1ef531
commit
69c7ea4cb3
4
HISTORY
4
HISTORY
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
Version 5.10 2017-02-17
|
||||
* use fc_safe_read instead of read, and fc_safe_write instead of write
|
||||
you must upgrade libfastcommon to V1.35 or later
|
||||
|
||||
Version 5.09 2016-12-29
|
||||
* bug fixed: list_all_groups expand buffer auto for so many groups
|
||||
* tracker.conf add parameters: min_buff_size and max_buff_size
|
||||
|
|
|
|||
|
|
@ -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, 9};
|
||||
Version g_fdfs_version = {5, 10};
|
||||
bool g_use_connection_pool = false;
|
||||
ConnectionPool g_connection_pool;
|
||||
int g_connection_pool_max_idle_time = 3600;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
%define FDFSClient libfdfsclient
|
||||
%define FDFSClientDevel libfdfsclient-devel
|
||||
%define FDFSTool fastdfs-tool
|
||||
%define FDFSVersion 5.0.9
|
||||
%define FDFSVersion 5.0.10
|
||||
|
||||
Name: %{FastDFS}
|
||||
Version: %{FDFSVersion}
|
||||
|
|
@ -17,13 +17,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.30
|
||||
BuildRequires: libfastcommon-devel >= 1.0.35
|
||||
|
||||
%description
|
||||
This package provides tracker & storage of fastdfs
|
||||
|
||||
%package -n %{FDFSServer}
|
||||
Requires: libfastcommon >= 1.0.30
|
||||
Requires: libfastcommon >= 1.0.35
|
||||
Summary: fastdfs tracker & storage
|
||||
|
||||
%package -n %{FDFSTool}
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ int dio_read_file(struct fast_task_info *pTask)
|
|||
read_bytes, pTask->length, pFileContext->offset);
|
||||
*/
|
||||
|
||||
if (read(pFileContext->fd, pTask->data + pTask->length, \
|
||||
if (fc_safe_read(pFileContext->fd, pTask->data + pTask->length, \
|
||||
read_bytes) != read_bytes)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
@ -424,7 +424,7 @@ int dio_write_file(struct fast_task_info *pTask)
|
|||
|
||||
pDataBuff = pTask->data + pFileContext->buff_offset;
|
||||
write_bytes = pTask->length - pFileContext->buff_offset;
|
||||
if (write(pFileContext->fd, pDataBuff, write_bytes) != write_bytes)
|
||||
if (fc_safe_write(pFileContext->fd, pDataBuff, write_bytes) != write_bytes)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -807,7 +807,7 @@ int dio_check_trunk_file_ex(int fd, const char *filename, const int64_t offset)
|
|||
char old_header[FDFS_TRUNK_FILE_HEADER_SIZE];
|
||||
char expect_header[FDFS_TRUNK_FILE_HEADER_SIZE];
|
||||
|
||||
if (read(fd, old_header, FDFS_TRUNK_FILE_HEADER_SIZE) !=
|
||||
if (fc_safe_read(fd, old_header, FDFS_TRUNK_FILE_HEADER_SIZE) !=
|
||||
FDFS_TRUNK_FILE_HEADER_SIZE)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
@ -903,7 +903,7 @@ int dio_write_chunk_header(struct fast_task_info *pTask)
|
|||
}
|
||||
*/
|
||||
|
||||
if (write(pFileContext->fd, header, FDFS_TRUNK_FILE_HEADER_SIZE) != \
|
||||
if (fc_safe_write(pFileContext->fd, header, FDFS_TRUNK_FILE_HEADER_SIZE) != \
|
||||
FDFS_TRUNK_FILE_HEADER_SIZE)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ int storage_write_to_fd(int fd, get_filename_func filename_func, \
|
|||
return errno != 0 ? errno : ENOENT;
|
||||
}
|
||||
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -657,7 +657,7 @@ int storage_write_to_sync_ini_file()
|
|||
INIT_ITEM_CURRENT_TRUNK_FILE_ID, g_current_trunk_file_id, \
|
||||
INIT_ITEM_TRUNK_LAST_COMPRESS_TIME, (int)g_trunk_last_compress_time
|
||||
);
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -2019,7 +2019,7 @@ int write_serialized(int fd, const char *buff, size_t count, const bool bSync)
|
|||
__LINE__, result, STRERROR(result));
|
||||
}
|
||||
|
||||
if (write(fd, buff, count) == count)
|
||||
if (fc_safe_write(fd, buff, count) == count)
|
||||
{
|
||||
if (bSync && fsync(fd) != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ static int write_to_binlog_index(const int binlog_index)
|
|||
}
|
||||
|
||||
len = sprintf(buff, "%d", binlog_index);
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -1206,7 +1206,7 @@ int storage_sync_init()
|
|||
"%s/%s", sync_path, SYNC_BINLOG_INDEX_FILENAME);
|
||||
if ((fd=open(full_filename, O_RDONLY)) >= 0)
|
||||
{
|
||||
bytes = read(fd, file_buff, sizeof(file_buff) - 1);
|
||||
bytes = fc_safe_read(fd, file_buff, sizeof(file_buff) - 1);
|
||||
close(fd);
|
||||
if (bytes <= 0)
|
||||
{
|
||||
|
|
@ -1369,7 +1369,7 @@ static int storage_binlog_fsync(const bool bNeedLock)
|
|||
{
|
||||
write_ret = 0; //skip
|
||||
}
|
||||
else if (write(g_binlog_fd, binlog_write_cache_buff, \
|
||||
else if (fc_safe_write(g_binlog_fd, binlog_write_cache_buff, \
|
||||
binlog_write_cache_len) != binlog_write_cache_len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -2163,7 +2163,7 @@ static int storage_binlog_preread(StorageBinLogReader *pReader)
|
|||
pReader->binlog_buff.current = pReader->binlog_buff.buffer;
|
||||
}
|
||||
|
||||
bytes_read = read(pReader->binlog_fd, pReader->binlog_buff.buffer \
|
||||
bytes_read = fc_safe_read(pReader->binlog_fd, pReader->binlog_buff.buffer \
|
||||
+ pReader->binlog_buff.length, \
|
||||
STORAGE_BINLOG_BUFFER_SIZE - pReader->binlog_buff.length);
|
||||
if (bytes_read < 0)
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ static int tree_walk_callback(void *data, void *args)
|
|||
if (pCallbackArgs->pCurrent - pCallbackArgs->buff > \
|
||||
sizeof(pCallbackArgs->buff) - 128)
|
||||
{
|
||||
if (write(pCallbackArgs->fd, pCallbackArgs->buff, \
|
||||
if (fc_safe_write(pCallbackArgs->fd, pCallbackArgs->buff, \
|
||||
pCallbackArgs->pCurrent - pCallbackArgs->buff) \
|
||||
!= pCallbackArgs->pCurrent - pCallbackArgs->buff)
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ static int storage_trunk_do_save()
|
|||
len = callback_args.pCurrent - callback_args.buff;
|
||||
if (len > 0 && result == 0)
|
||||
{
|
||||
if (write(callback_args.fd, callback_args.buff, len) != len)
|
||||
if (fc_safe_write(callback_args.fd, callback_args.buff, len) != len)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
logError("file: "__FILE__", line: %d, "\
|
||||
|
|
@ -991,7 +991,7 @@ static int storage_trunk_load()
|
|||
return result;
|
||||
}
|
||||
|
||||
if ((bytes=read(fd, buff, sizeof(buff) - 1)) < 0)
|
||||
if ((bytes=fc_safe_read(fd, buff, sizeof(buff) - 1)) < 0)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -1039,7 +1039,7 @@ static int storage_trunk_load()
|
|||
}
|
||||
|
||||
memcpy(buff, pLineStart, len);
|
||||
if ((bytes=read(fd, buff + len, sizeof(buff) \
|
||||
if ((bytes=fc_safe_read(fd, buff + len, sizeof(buff) \
|
||||
- len - 1)) < 0)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
@ -1890,7 +1890,7 @@ int trunk_file_delete(const char *trunk_filename, \
|
|||
trunkHeader.file_type = FDFS_TRUNK_FILE_TYPE_NONE;
|
||||
trunk_pack_header(&trunkHeader, pack_buff);
|
||||
|
||||
write_bytes = write(fd, pack_buff, FDFS_TRUNK_FILE_HEADER_SIZE);
|
||||
write_bytes = fc_safe_write(fd, pack_buff, FDFS_TRUNK_FILE_HEADER_SIZE);
|
||||
if (write_bytes != FDFS_TRUNK_FILE_HEADER_SIZE)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
@ -1905,7 +1905,7 @@ int trunk_file_delete(const char *trunk_filename, \
|
|||
{
|
||||
write_bytes = remain_bytes > sizeof(buff) ? \
|
||||
sizeof(buff) : remain_bytes;
|
||||
if (write(fd, buff, write_bytes) != write_bytes)
|
||||
if (fc_safe_write(fd, buff, write_bytes) != write_bytes)
|
||||
{
|
||||
result = errno != 0 ? errno : EIO;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ int trunk_file_get_content_ex(const FDFSStorePaths *pStorePaths, \
|
|||
}
|
||||
}
|
||||
|
||||
read_bytes = read(fd, buff, file_size);
|
||||
read_bytes = fc_safe_read(fd, buff, file_size);
|
||||
if (read_bytes == file_size)
|
||||
{
|
||||
result = 0;
|
||||
|
|
@ -626,7 +626,7 @@ int trunk_file_do_lstat_func_ex(const FDFSStorePaths *pStorePaths, \
|
|||
return result;
|
||||
}
|
||||
|
||||
read_bytes = read(fd, buff, FDFS_TRUNK_FILE_HEADER_SIZE);
|
||||
read_bytes = fc_safe_read(fd, buff, FDFS_TRUNK_FILE_HEADER_SIZE);
|
||||
if (read_bytes == FDFS_TRUNK_FILE_HEADER_SIZE)
|
||||
{
|
||||
result = 0;
|
||||
|
|
|
|||
|
|
@ -389,9 +389,9 @@ static int trunk_binlog_merge_file(int old_fd)
|
|||
return result;
|
||||
}
|
||||
|
||||
while ((bytes=read(old_fd, buff, sizeof(buff))) > 0)
|
||||
while ((bytes=fc_safe_read(old_fd, buff, sizeof(buff))) > 0)
|
||||
{
|
||||
if (write(tmp_fd, buff, bytes) != bytes)
|
||||
if (fc_safe_write(tmp_fd, buff, bytes) != bytes)
|
||||
{
|
||||
result = errno != 0 ? errno : EACCES;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -414,9 +414,9 @@ static int trunk_binlog_merge_file(int old_fd)
|
|||
return errno != 0 ? errno : EPERM;
|
||||
}
|
||||
|
||||
while ((bytes=read(binlog_fd, buff, sizeof(buff))) > 0)
|
||||
while ((bytes=fc_safe_read(binlog_fd, buff, sizeof(buff))) > 0)
|
||||
{
|
||||
if (write(tmp_fd, buff, bytes) != bytes)
|
||||
if (fc_safe_write(tmp_fd, buff, bytes) != bytes)
|
||||
{
|
||||
result = errno != 0 ? errno : EACCES;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
|
|
@ -622,23 +622,23 @@ static int trunk_binlog_fsync_ex(const bool bNeedLock, \
|
|||
{
|
||||
write_ret = 0; //skip
|
||||
}
|
||||
else if (write(trunk_binlog_fd, buff, *length) != *length)
|
||||
else if (fc_safe_write(trunk_binlog_fd, buff, *length) != *length)
|
||||
{
|
||||
write_ret = errno != 0 ? errno : EIO;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to binlog file \"%s\" fail, fd=%d, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, get_trunk_binlog_filename(full_filename), \
|
||||
trunk_binlog_fd, errno, STRERROR(errno));
|
||||
write_ret = errno != 0 ? errno : EIO;
|
||||
}
|
||||
else if (fsync(trunk_binlog_fd) != 0)
|
||||
{
|
||||
write_ret = errno != 0 ? errno : EIO;
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync to binlog file \"%s\" fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, get_trunk_binlog_filename(full_filename), \
|
||||
errno, STRERROR(errno));
|
||||
write_ret = errno != 0 ? errno : EIO;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1087,7 +1087,7 @@ static int trunk_binlog_preread(TrunkBinLogReader *pReader)
|
|||
pReader->binlog_buff.current = pReader->binlog_buff.buffer;
|
||||
}
|
||||
|
||||
bytes_read = read(pReader->binlog_fd, pReader->binlog_buff.buffer \
|
||||
bytes_read = fc_safe_read(pReader->binlog_fd, pReader->binlog_buff.buffer \
|
||||
+ pReader->binlog_buff.length, \
|
||||
TRUNK_BINLOG_BUFFER_SIZE - pReader->binlog_buff.length);
|
||||
if (bytes_read < 0)
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ static int tracker_write_to_changelog(FDFSGroupInfo *pGroup, \
|
|||
(int)g_current_time, pGroup->group_name, pStorage->id, \
|
||||
pStorage->status, pArg != NULL ? pArg : "");
|
||||
|
||||
if (write(changelog_fd, buff, len) != len)
|
||||
if (fc_safe_write(changelog_fd, buff, len) != len)
|
||||
{
|
||||
tracker_mem_file_unlock();
|
||||
|
||||
|
|
@ -1742,7 +1742,7 @@ int tracker_save_groups()
|
|||
"\t%s=%d\n\n", \
|
||||
GROUP_SECTION_NAME_GLOBAL, \
|
||||
GROUP_ITEM_GROUP_COUNT, g_groups.count);
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -1791,7 +1791,7 @@ int tracker_save_groups()
|
|||
(*ppGroup)->last_trunk_server_id
|
||||
);
|
||||
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -2060,7 +2060,7 @@ int tracker_save_storages()
|
|||
pStorage->changelog_offset \
|
||||
);
|
||||
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -2081,7 +2081,7 @@ int tracker_save_storages()
|
|||
"\t%s=%d\n", \
|
||||
STORAGE_SECTION_NAME_GLOBAL, \
|
||||
STORAGE_ITEM_STORAGE_COUNT, count);
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -2198,7 +2198,7 @@ int tracker_save_sync_timestamps()
|
|||
*(buff + len) = '\n';
|
||||
len++;
|
||||
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
@ -3838,7 +3838,8 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
|
||||
pContent = pInBuff + FDFS_PROTO_PKG_LEN_SIZE;
|
||||
if (write_bytes > 0 && write(fd, pContent, write_bytes) != write_bytes)
|
||||
if (write_bytes > 0 &&
|
||||
fc_safe_write(fd, pContent, write_bytes) != write_bytes)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file %s fail, " \
|
||||
|
|
@ -4997,7 +4998,7 @@ static int tracker_write_to_trunk_change_log(FDFSGroupInfo *pGroup, \
|
|||
}
|
||||
}
|
||||
|
||||
if (write(fd, buff, len) != len)
|
||||
if (fc_safe_write(fd, buff, len) != len)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"write to file \"%s\" fail, " \
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ static int tracker_changelog_response(struct fast_task_info *pTask, \
|
|||
return result;
|
||||
}
|
||||
|
||||
read_bytes = read(fd, pTask->data + sizeof(TrackerHeader), chg_len);
|
||||
read_bytes = fc_safe_read(fd, pTask->data + sizeof(TrackerHeader), chg_len);
|
||||
close(fd);
|
||||
|
||||
if (read_bytes != chg_len)
|
||||
|
|
|
|||
Loading…
Reference in New Issue