Merge branch 'use_libfastcommon1.70'

pull/687/head V6.10.0
YuQing 2023-11-16 11:36:52 +08:00
commit d24c3200d1
13 changed files with 58 additions and 69 deletions

View File

@ -11,7 +11,7 @@ Chinese language: http://www.fastken.com/
# command lines as:
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon; git checkout V1.0.67
cd libfastcommon; git checkout V1.0.70
./make.sh clean && ./make.sh && ./make.sh install
@ -21,7 +21,7 @@ Chinese language: http://www.fastken.com/
# command lines as:
git clone https://github.com/happyfish100/libserverframe.git
cd libserverframe; git checkout V1.1.26
cd libserverframe; git checkout V1.2.0
./make.sh clean && ./make.sh && ./make.sh install
# step 3. download fastdfs source codes and install it,
@ -30,7 +30,7 @@ Chinese language: http://www.fastken.com/
# command lines as:
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs; git checkout V6.9.5
cd fastdfs; git checkout V6.10.0
./make.sh clean && ./make.sh && ./make.sh install

View File

@ -20,7 +20,7 @@
#include "fastcommon/logger.h"
#include "fdfs_global.h"
Version g_fdfs_version = {6, 9, 5};
Version g_fdfs_version = {6, 10, 0};
bool g_use_connection_pool = false;
ConnectionPool g_connection_pool;
int g_connection_pool_max_idle_time = 3600;

View File

@ -7,7 +7,7 @@
%define CommitVersion %(echo $COMMIT_VERSION)
Name: %{FastDFS}
Version: 6.9.5
Version: 6.10.0
Release: 1%{?dist}
Summary: FastDFS server and client
License: GPL
@ -18,14 +18,14 @@ 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: libserverframe-devel >= 1.1.26
BuildRequires: libserverframe-devel >= 1.2.0
%description
This package provides tracker & storage of fastdfs
commit version: %{CommitVersion}
%package -n %{FDFSServer}
Requires: libserverframe >= 1.1.26
Requires: libserverframe >= 1.2.0
Requires: %{FDFSConfig}
Summary: fastdfs tracker & storage
@ -34,7 +34,7 @@ Requires: %{FDFSClient}
Summary: fastdfs tools
%package -n %{FDFSClient}
Requires: libserverframe >= 1.1.26
Requires: libserverframe >= 1.2.0
Requires: %{FDFSConfig}
Summary: The client dynamic library of fastdfs

View File

@ -943,7 +943,7 @@ static void php_fdfs_connect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \
server_info.sock = -1;
if ((pContext->err_no=conn_pool_connect_server(&server_info, \
SF_G_NETWORK_TIMEOUT)) == 0)
SF_G_NETWORK_TIMEOUT * 1000)) == 0)
{
array_init(return_value);
zend_add_assoc_stringl_ex(return_value, "ip_addr", \

View File

@ -249,8 +249,8 @@ int main(int argc, char *argv[])
return result;
}
if ((result=set_run_by(g_sf_global_vars.run_by_group,
g_sf_global_vars.run_by_user)) != 0)
if ((result=set_run_by(g_sf_global_vars.run_by.group,
g_sf_global_vars.run_by.user)) != 0)
{
logCrit("exit abnormally!\n");
log_destroy();
@ -362,7 +362,7 @@ static void sigAlarmHandler(int sig)
server.port = SF_G_INNER_PORT;
server.sock = -1;
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT) != 0)
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT * 1000) != 0)
{
return;
}

View File

@ -332,7 +332,7 @@ int dio_read_file(struct fast_task_info *pTask)
remain_bytes = pFileContext->end - pFileContext->offset;
capacity_bytes = pTask->send.ptr->size - pTask->send.ptr->length;
read_bytes = (capacity_bytes < remain_bytes) ? \
read_bytes = (capacity_bytes < remain_bytes) ?
capacity_bytes : remain_bytes;
/*
@ -340,8 +340,8 @@ int dio_read_file(struct fast_task_info *pTask)
read_bytes, pTask->send.ptr->length, pFileContext->offset);
*/
if (fc_safe_read(pFileContext->fd, pTask->send.ptr->data + pTask->send.ptr->length, \
read_bytes) != read_bytes)
if (fc_safe_read(pFileContext->fd, pTask->send.ptr->data +
pTask->send.ptr->length, read_bytes) != read_bytes)
{
result = errno != 0 ? errno : EIO;
logError("file: "__FILE__", line: %d, " \
@ -364,8 +364,8 @@ int dio_read_file(struct fast_task_info *pTask)
if (pFileContext->calc_crc32)
{
pFileContext->crc32 = CRC32_ex(pTask->send.ptr->data + pTask->send.ptr->length,
read_bytes, pFileContext->crc32);
pFileContext->crc32 = CRC32_ex(pTask->send.ptr->data + pTask->
send.ptr->length, read_bytes, pFileContext->crc32);
}
pTask->send.ptr->length += read_bytes;
@ -486,8 +486,8 @@ int dio_write_file(struct fast_task_info *pTask)
}
/*
logInfo("###dio fd: %d, write bytes: %d, pTask->length=%d, "
"buff_offset=%d", pFileContext->fd, write_bytes,
logInfo("###dio fd: %d, write bytes: %d, task length: %d, "
"buff_offset: %d", pFileContext->fd, write_bytes,
pTask->recv.ptr->length, pFileContext->buff_offset);
*/
@ -762,8 +762,11 @@ static void *dio_thread_entrance(void* arg)
{
while ((pTask=blocked_queue_pop(&(pContext->queue))) != NULL)
{
((StorageClientInfo *)pTask->arg)->deal_func(pTask);
storage_release_task(pTask);
if (!FC_ATOMIC_GET(pTask->canceled))
{
((StorageClientInfo *)pTask->arg)->deal_func(pTask);
}
sf_release_task(pTask);
}
}

View File

@ -150,8 +150,8 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
, g_last_server_port
, g_last_http_port
, g_allow_ip_count
, g_sf_global_vars.run_by_group
, g_sf_global_vars.run_by_user
, g_sf_global_vars.run_by.group
, g_sf_global_vars.run_by.user
, g_http_domain
, g_file_distribute_path_mode
, g_file_distribute_rotate_count

View File

@ -1525,16 +1525,6 @@ static void storage_set_metadata_done_callback( \
sf_nio_notify(pTask, SF_NIO_STAGE_SEND);
}
void task_finish_clean_up(struct fast_task_info *pTask)
{
if (__sync_sub_and_fetch(&pTask->reffer_count, 0) == 1)
{
storage_clear_task(pTask);
}
++g_stat_change_count;
sf_task_finish_clean_up(pTask);
}
int storage_set_body_length(struct fast_task_info *pTask)
{
StorageClientInfo *pClientInfo;
@ -1588,7 +1578,7 @@ static int sock_accept_done_callback(struct fast_task_info *task,
}
static int sock_send_done_callback(struct fast_task_info *pTask,
const int length)
const int length, int *next_stage)
{
StorageClientInfo *pClientInfo;
@ -1609,10 +1599,13 @@ static int sock_send_done_callback(struct fast_task_info *pTask,
/* response done, try to recv again */
pClientInfo->total_length = 0;
pClientInfo->total_offset = 0;
*next_stage = SF_NIO_STAGE_RECV;
return 0;
}
else //continue to send file content
{
*next_stage = SF_NIO_STAGE_SEND;
/* continue read from file */
return storage_dio_queue_push(pTask);
}
@ -1638,6 +1631,19 @@ static void *alloc_thread_extra_data_func(const int thread_index)
}
}
static void storage_clear_task(struct fast_task_info *pTask)
{
StorageClientInfo *pClientInfo;
pClientInfo = (StorageClientInfo *)pTask->arg;
if (pClientInfo->clean_func != NULL)
{
pClientInfo->clean_func(pTask);
}
memset(pTask->arg, 0, sizeof(StorageClientInfo));
++g_stat_change_count;
}
int storage_service_init()
{
int result;
@ -1652,10 +1658,12 @@ int storage_service_init()
SF_G_EPOLL_EDGE_TRIGGER = true;
result = sf_service_init("storage", alloc_thread_extra_data_func,
NULL, sock_accept_done_callback, storage_set_body_length,
sock_send_done_callback, storage_deal_task, task_finish_clean_up,
sock_send_done_callback, storage_deal_task, sf_task_finish_clean_up,
NULL, 1000, sizeof(TrackerHeader), sizeof(StorageClientInfo));
sf_enable_thread_notify(false);
sf_set_remove_from_ready_list(false);
free_queue_set_release_callback(&g_sf_context.
free_queue, storage_clear_task);
return result;
}

View File

@ -40,28 +40,6 @@ int storage_get_storage_path_index(int *store_path_index);
void storage_get_store_path(const char *filename, const int filename_len,
int *sub_path_high, int *sub_path_low);
static inline void storage_clear_task(struct fast_task_info *pTask)
{
StorageClientInfo *pClientInfo;
pClientInfo = (StorageClientInfo *)pTask->arg;
if (pClientInfo->clean_func != NULL)
{
pClientInfo->clean_func(pTask);
pClientInfo->clean_func = NULL;
}
memset(pTask->arg, 0, sizeof(StorageClientInfo));
}
static inline void storage_release_task(struct fast_task_info *pTask)
{
if (FC_ATOMIC_GET(pTask->reffer_count) == 1)
{
storage_clear_task(pTask);
}
sf_release_task(pTask);
}
#ifdef __cplusplus
}
#endif

View File

@ -27,8 +27,8 @@ static ConnectionInfo *getConnectedStorageServer(
{
if (pServer->sock < 0)
{
*err_no = conn_pool_connect_server(pServer, \
SF_G_CONNECT_TIMEOUT);
*err_no = conn_pool_connect_server(pServer,
SF_G_CONNECT_TIMEOUT * 1000);
if (*err_no != 0)
{
return NULL;
@ -46,8 +46,8 @@ static ConnectionInfo *getConnectedStorageServer(
pServer = pEnd;
memcpy(pServer, pStorageServer, sizeof(ConnectionInfo));
pServer->sock = -1;
if ((*err_no=conn_pool_connect_server(pServer, \
SF_G_CONNECT_TIMEOUT)) != 0)
if ((*err_no=conn_pool_connect_server(pServer,
SF_G_CONNECT_TIMEOUT * 1000)) != 0)
{
return NULL;
}

View File

@ -289,8 +289,8 @@ int main(int argc, char *argv[])
}
#endif
if ((result=set_run_by(g_sf_global_vars.run_by_group,
g_sf_global_vars.run_by_user)) != 0)
if ((result=set_run_by(g_sf_global_vars.run_by.group,
g_sf_global_vars.run_by.user)) != 0)
{
logCrit("exit abnormally!\n");
log_destroy();
@ -434,7 +434,7 @@ static void sigAlarmHandler(int sig)
server.port = SF_G_INNER_PORT;
server.sock = -1;
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT) != 0)
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT * 1000) != 0)
{
return;
}

View File

@ -361,8 +361,8 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
, fdfs_storage_reserved_space_to_string( \
&g_storage_reserved_space, reserved_space_str) \
, g_allow_ip_count
, g_sf_global_vars.run_by_group
, g_sf_global_vars.run_by_user
, g_sf_global_vars.run_by.group
, g_sf_global_vars.run_by.user
, g_storage_ip_changed_auto_adjust
, SF_G_THREAD_STACK_SIZE
, g_if_use_trunk_file

View File

@ -501,7 +501,7 @@ ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo
}
*err_no = conn_pool_connect_server_ex(pServerInfo->connections
+ pServerInfo->index, SF_G_CONNECT_TIMEOUT,
+ pServerInfo->index, SF_G_CONNECT_TIMEOUT * 1000,
bind_addr, log_connect_error);
if (*err_no == 0)
{
@ -520,7 +520,7 @@ ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo
if (current_index != pServerInfo->index)
{
if ((*err_no=conn_pool_connect_server_ex(conn,
SF_G_CONNECT_TIMEOUT, bind_addr,
SF_G_CONNECT_TIMEOUT * 1000, bind_addr,
log_connect_error)) == 0)
{
pServerInfo->index = current_index;
@ -542,7 +542,7 @@ ConnectionInfo *tracker_make_connection_ex(ConnectionInfo *conn,
}
else
{
*err_no = conn_pool_connect_server(conn, connect_timeout);
*err_no = conn_pool_connect_server(conn, connect_timeout * 1000);
if (*err_no != 0)
{
return NULL;