Compare commits
No commits in common. "master" and "V6.9.3" have entirely different histories.
31
HISTORY
31
HISTORY
|
|
@ -1,35 +1,4 @@
|
||||||
|
|
||||||
Version 6.12.2 2024-09-16
|
|
||||||
* use libfastcommon V1.75 and libserverframe 1.2.5
|
|
||||||
|
|
||||||
Version 6.12.1 2024-03-06
|
|
||||||
* adapt to libserverframe 1.2.3
|
|
||||||
* bugfixed: notify_leader_changed support IPv6 correctly
|
|
||||||
* log square quoted IPv6 address
|
|
||||||
|
|
||||||
Version 6.12.0 2024-02-12
|
|
||||||
* bugfixed: parse ip and port use parseAddress instead of splitEx
|
|
||||||
* bugfixed: fdfs_server_info_to_string support IPv6 correctly
|
|
||||||
* check filename duplicate by hashtable instead of file system access
|
|
||||||
|
|
||||||
Version 6.11.0 2023-12-10
|
|
||||||
* support IPv6, config item: address_family in tracker.conf and storage.conf
|
|
||||||
use libfastcommon V1.71 and libserverframe 1.2.1
|
|
||||||
* storage.conf can specify the storage server ID for NAT network
|
|
||||||
|
|
||||||
Version 6.10.0 2023-09-07
|
|
||||||
* use libfastcommon V1.70 and libserverframe 1.2.0
|
|
||||||
|
|
||||||
Version 6.9.5 2023-06-05
|
|
||||||
* fix possible out-of-bounds issues with array access
|
|
||||||
* fix realloc mistakes to avoid memory leaks
|
|
||||||
* add ExecStartPost=/bin/sleep 0.1 to systemd service files
|
|
||||||
* fdht_client/fdht_func.c: fixed compile error
|
|
||||||
|
|
||||||
Version 6.9.4 2023-02-15
|
|
||||||
* use epoll edge trigger to resolve github issues #608
|
|
||||||
* bugfixed: report connections' current_count and max_count correctly
|
|
||||||
|
|
||||||
Version 6.9.3 2022-12-24
|
Version 6.9.3 2022-12-24
|
||||||
* use prctl to set pthread name under Linux
|
* use prctl to set pthread name under Linux
|
||||||
|
|
||||||
|
|
|
||||||
6
INSTALL
6
INSTALL
|
|
@ -11,7 +11,7 @@ Chinese language: http://www.fastken.com/
|
||||||
# command lines as:
|
# command lines as:
|
||||||
|
|
||||||
git clone https://github.com/happyfish100/libfastcommon.git
|
git clone https://github.com/happyfish100/libfastcommon.git
|
||||||
cd libfastcommon; git checkout V1.0.75
|
cd libfastcommon; git checkout V1.0.65
|
||||||
./make.sh clean && ./make.sh && ./make.sh install
|
./make.sh clean && ./make.sh && ./make.sh install
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ Chinese language: http://www.fastken.com/
|
||||||
# command lines as:
|
# command lines as:
|
||||||
|
|
||||||
git clone https://github.com/happyfish100/libserverframe.git
|
git clone https://github.com/happyfish100/libserverframe.git
|
||||||
cd libserverframe; git checkout V1.2.5
|
cd libserverframe; git checkout V1.1.24
|
||||||
./make.sh clean && ./make.sh && ./make.sh install
|
./make.sh clean && ./make.sh && ./make.sh install
|
||||||
|
|
||||||
# step 3. download fastdfs source codes and install it,
|
# step 3. download fastdfs source codes and install it,
|
||||||
|
|
@ -30,7 +30,7 @@ Chinese language: http://www.fastken.com/
|
||||||
# command lines as:
|
# command lines as:
|
||||||
|
|
||||||
git clone https://github.com/happyfish100/fastdfs.git
|
git clone https://github.com/happyfish100/fastdfs.git
|
||||||
cd fastdfs; git checkout V6.12.2
|
cd fastdfs; git checkout V6.9.3
|
||||||
./make.sh clean && ./make.sh && ./make.sh install
|
./make.sh clean && ./make.sh && ./make.sh install
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ Please visit the FastDFS Home Page for more detail.
|
||||||
Chinese language: http://www.fastken.com/
|
Chinese language: http://www.fastken.com/
|
||||||
|
|
||||||
|
|
||||||
FastDFS is an open source high performance distributed file system. Its major
|
FastDFS is an open source high performance distributed file system. It's major
|
||||||
functions include: file storing, file syncing and file accessing (file uploading
|
functions include: file storing, file syncing and file accessing (file uploading
|
||||||
and file downloading), and it can resolve the high capacity and load balancing
|
and file downloading), and it can resolve the high capacity and load balancing
|
||||||
problem. FastDFS should meet the requirement of the website whose service based
|
problem. FastDFS should meet the requirement of the website whose service based
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,11 @@ static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
TrackerServerInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+ \
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+
|
|
||||||
pTrackerGroup->server_count; pServer++)
|
pTrackerGroup->server_count; pServer++)
|
||||||
{
|
{
|
||||||
format_ip_address(pServer->connections[0].ip_addr, formatted_ip);
|
//printf("server=%s:%u\n", \
|
||||||
printf("server=%s:%u\n", formatted_ip, pServer->connections[0].port);
|
pServer->ip_addr, pServer->port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
@ -242,7 +241,7 @@ static int fdfs_get_params_from_tracker(bool *use_storage_id)
|
||||||
|
|
||||||
continue_flag = false;
|
continue_flag = false;
|
||||||
if ((result=fdfs_get_ini_context_from_tracker(&g_tracker_group,
|
if ((result=fdfs_get_ini_context_from_tracker(&g_tracker_group,
|
||||||
&iniContext, &continue_flag)) != 0)
|
&iniContext, &continue_flag, false, NULL)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -349,77 +348,39 @@ static int fdfs_client_do_init_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_fdfs_parameters_from_tracker = iniGetBoolValue(NULL,
|
load_fdfs_parameters_from_tracker = iniGetBoolValue(NULL, \
|
||||||
"load_fdfs_parameters_from_tracker",
|
"load_fdfs_parameters_from_tracker", \
|
||||||
iniContext, false);
|
iniContext, false);
|
||||||
if (load_fdfs_parameters_from_tracker)
|
if (load_fdfs_parameters_from_tracker)
|
||||||
{
|
{
|
||||||
if ((result=fdfs_get_params_from_tracker(&use_storage_id)) != 0)
|
fdfs_get_params_from_tracker(&use_storage_id);
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
use_storage_id = iniGetBoolValue(NULL, "use_storage_id",
|
use_storage_id = iniGetBoolValue(NULL, "use_storage_id", \
|
||||||
iniContext, false);
|
iniContext, false);
|
||||||
if (use_storage_id)
|
if (use_storage_id)
|
||||||
{
|
{
|
||||||
if ((result=fdfs_load_storage_ids_from_file(
|
result = fdfs_load_storage_ids_from_file( \
|
||||||
conf_filename, iniContext)) != 0)
|
conf_filename, iniContext);
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (use_storage_id)
|
|
||||||
{
|
|
||||||
FDFSStorageIdInfo *idInfo;
|
|
||||||
FDFSStorageIdInfo *end;
|
|
||||||
char *connect_first_by;
|
|
||||||
|
|
||||||
end = g_storage_ids_by_id.ids + g_storage_ids_by_id.count;
|
|
||||||
for (idInfo=g_storage_ids_by_id.ids; idInfo<end; idInfo++)
|
|
||||||
{
|
|
||||||
if (idInfo->ip_addrs.count > 1)
|
|
||||||
{
|
|
||||||
g_multi_storage_ips = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_multi_storage_ips)
|
|
||||||
{
|
|
||||||
connect_first_by = iniGetStrValue(NULL,
|
|
||||||
"connect_first_by", iniContext);
|
|
||||||
if (connect_first_by != NULL && strncasecmp(connect_first_by,
|
|
||||||
"last", 4) == 0)
|
|
||||||
{
|
|
||||||
g_connect_first_by = fdfs_connect_first_by_last_connected;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_FLAG
|
#ifdef DEBUG_FLAG
|
||||||
logDebug("base_path=%s, "
|
logDebug("base_path=%s, " \
|
||||||
"connect_timeout=%d, "
|
"connect_timeout=%d, "\
|
||||||
"network_timeout=%d, "
|
"network_timeout=%d, "\
|
||||||
"tracker_server_count=%d, "
|
"tracker_server_count=%d, " \
|
||||||
"anti_steal_token=%d, "
|
"anti_steal_token=%d, " \
|
||||||
"anti_steal_secret_key length=%d, "
|
"anti_steal_secret_key length=%d, " \
|
||||||
"use_connection_pool=%d, "
|
"use_connection_pool=%d, " \
|
||||||
"g_connection_pool_max_idle_time=%ds, "
|
"g_connection_pool_max_idle_time=%ds, " \
|
||||||
"use_storage_id=%d, connect_first_by=%s, "
|
"use_storage_id=%d, storage server id count: %d\n", \
|
||||||
"storage server id count: %d, "
|
SF_G_BASE_PATH_STR, SF_G_CONNECT_TIMEOUT, \
|
||||||
"multi storage ips: %d\n",
|
SF_G_NETWORK_TIMEOUT, pTrackerGroup->server_count, \
|
||||||
SF_G_BASE_PATH_STR, SF_G_CONNECT_TIMEOUT,
|
g_anti_steal_token, g_anti_steal_secret_key.length, \
|
||||||
SF_G_NETWORK_TIMEOUT, pTrackerGroup->server_count,
|
g_use_connection_pool, g_connection_pool_max_idle_time, \
|
||||||
g_anti_steal_token, g_anti_steal_secret_key.length,
|
use_storage_id, g_storage_ids_by_id.count);
|
||||||
g_use_connection_pool, g_connection_pool_max_idle_time,
|
|
||||||
use_storage_id, g_connect_first_by == fdfs_connect_first_by_tracker ?
|
|
||||||
"tracker" : "last-connected", g_storage_ids_by_id.count,
|
|
||||||
g_multi_storage_ips);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,5 @@
|
||||||
int g_tracker_server_http_port = 80;
|
int g_tracker_server_http_port = 80;
|
||||||
TrackerServerGroup g_tracker_group = {0, 0, -1, NULL};
|
TrackerServerGroup g_tracker_group = {0, 0, -1, NULL};
|
||||||
|
|
||||||
bool g_multi_storage_ips = false;
|
|
||||||
FDFSConnectFirstBy g_connect_first_by = fdfs_connect_first_by_tracker;
|
|
||||||
bool g_anti_steal_token = false;
|
bool g_anti_steal_token = false;
|
||||||
BufferInfo g_anti_steal_secret_key = {0};
|
BufferInfo g_anti_steal_secret_key = {0};
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,6 @@
|
||||||
#include "tracker_types.h"
|
#include "tracker_types.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
fdfs_connect_first_by_tracker,
|
|
||||||
fdfs_connect_first_by_last_connected
|
|
||||||
} FDFSConnectFirstBy;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -27,8 +22,6 @@ extern "C" {
|
||||||
extern int g_tracker_server_http_port;
|
extern int g_tracker_server_http_port;
|
||||||
extern TrackerServerGroup g_tracker_group;
|
extern TrackerServerGroup g_tracker_group;
|
||||||
|
|
||||||
extern bool g_multi_storage_ips;
|
|
||||||
extern FDFSConnectFirstBy g_connect_first_by;
|
|
||||||
extern bool g_anti_steal_token;
|
extern bool g_anti_steal_token;
|
||||||
extern BufferInfo g_anti_steal_secret_key;
|
extern BufferInfo g_anti_steal_secret_key;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,12 @@ static void usage(char *argv[])
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *conf_filename;
|
char *conf_filename;
|
||||||
|
int result;
|
||||||
char *op_type;
|
char *op_type;
|
||||||
char *group_name;
|
|
||||||
char *tracker_server;
|
char *tracker_server;
|
||||||
int arg_index;
|
int arg_index;
|
||||||
int result;
|
char *group_name;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
|
@ -97,7 +96,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
//g_log_context.log_level = LOG_DEBUG;
|
g_log_context.log_level = LOG_DEBUG;
|
||||||
ignore_signal_pipe();
|
ignore_signal_pipe();
|
||||||
|
|
||||||
if ((result=fdfs_client_init(conf_filename)) != 0)
|
if ((result=fdfs_client_init(conf_filename)) != 0)
|
||||||
|
|
@ -156,9 +155,7 @@ int main(int argc, char *argv[])
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return errno != 0 ? errno : ECONNREFUSED;
|
return errno != 0 ? errno : ECONNREFUSED;
|
||||||
}
|
}
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
printf("\ntracker server is %s:%u\n\n", pTrackerServer->ip_addr, pTrackerServer->port);
|
||||||
printf("\ntracker server is %s:%u\n\n", formatted_ip,
|
|
||||||
pTrackerServer->port);
|
|
||||||
|
|
||||||
if (arg_index < argc)
|
if (arg_index < argc)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ int main(int argc, char *argv[])
|
||||||
int meta_count;
|
int meta_count;
|
||||||
int i;
|
int i;
|
||||||
FDFSMetaData *pMetaList;
|
FDFSMetaData *pMetaList;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char token[32 + 1];
|
char token[32 + 1];
|
||||||
char file_id[128];
|
char file_id[128];
|
||||||
char file_url[256];
|
char file_url[256];
|
||||||
|
|
@ -461,9 +460,8 @@ g_fdfs_version.patch);
|
||||||
printf("server list (%d):\n", server_count);
|
printf("server list (%d):\n", server_count);
|
||||||
for (i=0; i<server_count; i++)
|
for (i=0; i<server_count; i++)
|
||||||
{
|
{
|
||||||
format_ip_address(storageServers[i].
|
printf("\t%s:%u\n", \
|
||||||
ip_addr, formatted_ip);
|
storageServers[i].ip_addr, \
|
||||||
printf("\t%s:%u\n", formatted_ip,
|
|
||||||
storageServers[i].port);
|
storageServers[i].port);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -490,8 +488,8 @@ g_fdfs_version.patch);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(storageServer.ip_addr, formatted_ip);
|
printf("storage=%s:%u\n", storageServer.ip_addr, \
|
||||||
printf("storage=%s:%u\n", formatted_ip, storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
|
|
@ -672,17 +670,15 @@ g_fdfs_version.patch);
|
||||||
/* for test only */
|
/* for test only */
|
||||||
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
printf("active_test to tracker server %s:%u fail, errno: %d\n", \
|
||||||
printf("active_test to tracker server %s:%u fail, errno: %d\n",
|
pTrackerServer->ip_addr, pTrackerServer->port, result);
|
||||||
formatted_ip, pTrackerServer->port, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for test only */
|
/* for test only */
|
||||||
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
printf("active_test to storage server %s:%u fail, errno: %d\n", \
|
||||||
printf("active_test to storage server %s:%u fail, errno: %d\n",
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
formatted_ip, pStorageServer->port, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_close_connection_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
|
|
@ -692,3 +688,4 @@ g_fdfs_version.patch);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ int main(int argc, char *argv[])
|
||||||
int meta_count;
|
int meta_count;
|
||||||
int i;
|
int i;
|
||||||
FDFSMetaData *pMetaList;
|
FDFSMetaData *pMetaList;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char token[32 + 1];
|
char token[32 + 1];
|
||||||
char file_id[128];
|
char file_id[128];
|
||||||
char master_file_id[128];
|
char master_file_id[128];
|
||||||
|
|
@ -433,9 +432,8 @@ g_fdfs_version.patch);
|
||||||
printf("server list (%d):\n", server_count);
|
printf("server list (%d):\n", server_count);
|
||||||
for (i=0; i<server_count; i++)
|
for (i=0; i<server_count; i++)
|
||||||
{
|
{
|
||||||
format_ip_address(storageServers[i].
|
printf("\t%s:%u\n", \
|
||||||
ip_addr, formatted_ip);
|
storageServers[i].ip_addr, \
|
||||||
printf("\t%s:%u\n", formatted_ip,
|
|
||||||
storageServers[i].port);
|
storageServers[i].port);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -457,8 +455,8 @@ g_fdfs_version.patch);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(storageServer.ip_addr, formatted_ip);
|
printf("storage=%s:%u\n", storageServer.ip_addr, \
|
||||||
printf("storage=%s:%u\n", formatted_ip, storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
|
|
@ -639,17 +637,15 @@ g_fdfs_version.patch);
|
||||||
/* for test only */
|
/* for test only */
|
||||||
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
printf("active_test to tracker server %s:%u fail, errno: %d\n", \
|
||||||
printf("active_test to tracker server %s:%u fail, errno: %d\n",
|
pTrackerServer->ip_addr, pTrackerServer->port, result);
|
||||||
formatted_ip, pTrackerServer->port, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for test only */
|
/* for test only */
|
||||||
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
printf("active_test to storage server %s:%u fail, errno: %d\n", \
|
||||||
printf("active_test to storage server %s:%u fail, errno: %d\n",
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
formatted_ip, pStorageServer->port, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_close_connection_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@
|
||||||
#include "client_global.h"
|
#include "client_global.h"
|
||||||
#include "fastcommon/base64.h"
|
#include "fastcommon/base64.h"
|
||||||
|
|
||||||
static int g_base64_context_inited = 0;
|
static struct base64_context the_base64_context;
|
||||||
|
static int the_base64_context_inited = 0;
|
||||||
|
|
||||||
#define FDFS_SPLIT_GROUP_NAME_AND_FILENAME(file_id) \
|
#define FDFS_SPLIT_GROUP_NAME_AND_FILENAME(file_id) \
|
||||||
char in_file_id[FDFS_GROUP_NAME_MAX_LEN + 128]; \
|
char in_file_id[FDFS_GROUP_NAME_MAX_LEN + 128]; \
|
||||||
|
|
@ -64,103 +65,6 @@ static int g_base64_context_inited = 0;
|
||||||
ppStorageServer, TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, \
|
ppStorageServer, TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE, \
|
||||||
group_name, filename, pNewStorage, new_connection)
|
group_name, filename, pNewStorage, new_connection)
|
||||||
|
|
||||||
static ConnectionInfo *make_connection_by_tracker(
|
|
||||||
ConnectionInfo *pStorageServer, int *err_no)
|
|
||||||
{
|
|
||||||
ConnectionInfo *conn;
|
|
||||||
FDFSStorageIdInfo *idInfo;
|
|
||||||
|
|
||||||
if ((conn=tracker_make_connection(pStorageServer, err_no)) != NULL)
|
|
||||||
{
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_multi_storage_ips)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((idInfo=fdfs_get_storage_id_by_ip_port(pStorageServer->ip_addr,
|
|
||||||
pStorageServer->port)) == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idInfo->ip_addrs.count < 2)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(pStorageServer->ip_addr, idInfo->ip_addrs.ips[0].address) == 0)
|
|
||||||
{
|
|
||||||
strcpy(pStorageServer->ip_addr, idInfo->ip_addrs.ips[1].address);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(pStorageServer->ip_addr, idInfo->ip_addrs.ips[0].address);
|
|
||||||
}
|
|
||||||
return tracker_make_connection(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ConnectionInfo *make_connection_by_last_connected(
|
|
||||||
ConnectionInfo *pStorageServer, int *err_no)
|
|
||||||
{
|
|
||||||
ConnectionInfo *conn;
|
|
||||||
FDFSStorageIdInfo *idInfo;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
if (!g_multi_storage_ips)
|
|
||||||
{
|
|
||||||
return tracker_make_connection(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((idInfo=fdfs_get_storage_id_by_ip_port(pStorageServer->ip_addr,
|
|
||||||
pStorageServer->port)) == NULL)
|
|
||||||
{
|
|
||||||
return tracker_make_connection(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
if (idInfo->ip_addrs.count < 2)
|
|
||||||
{
|
|
||||||
return tracker_make_connection(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
|
|
||||||
index = idInfo->ip_addrs.index;
|
|
||||||
if (strcmp(pStorageServer->ip_addr, idInfo->ip_addrs.
|
|
||||||
ips[index].address) != 0)
|
|
||||||
{
|
|
||||||
strcpy(pStorageServer->ip_addr, idInfo->ip_addrs.
|
|
||||||
ips[index].address);
|
|
||||||
}
|
|
||||||
if ((conn=tracker_make_connection(pStorageServer, err_no)) != NULL)
|
|
||||||
{
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++index == idInfo->ip_addrs.count)
|
|
||||||
{
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
strcpy(pStorageServer->ip_addr, idInfo->ip_addrs.ips[index].address);
|
|
||||||
if ((conn=tracker_make_connection(pStorageServer, err_no)) != NULL)
|
|
||||||
{
|
|
||||||
idInfo->ip_addrs.index = index;
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline ConnectionInfo *storage_make_connection(
|
|
||||||
ConnectionInfo *pStorageServer, int *err_no)
|
|
||||||
{
|
|
||||||
if (g_connect_first_by == fdfs_connect_first_by_tracker)
|
|
||||||
{
|
|
||||||
return make_connection_by_tracker(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return make_connection_by_last_connected(pStorageServer, err_no);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
ConnectionInfo **ppStorageServer, const byte cmd, \
|
ConnectionInfo **ppStorageServer, const byte cmd, \
|
||||||
const char *group_name, const char *filename, \
|
const char *group_name, const char *filename, \
|
||||||
|
|
@ -194,7 +98,7 @@ static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ppStorageServer=storage_make_connection(pNewStorage,
|
if ((*ppStorageServer=tracker_make_connection(pNewStorage,
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -210,7 +114,7 @@ static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((*ppStorageServer=storage_make_connection(
|
if ((*ppStorageServer=tracker_make_connection(
|
||||||
*ppStorageServer, &result)) == NULL)
|
*ppStorageServer, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -259,7 +163,7 @@ static int storage_get_upload_connection(ConnectionInfo *pTrackerServer, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ppStorageServer=storage_make_connection(pNewStorage,
|
if ((*ppStorageServer=tracker_make_connection(pNewStorage,
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -275,7 +179,7 @@ static int storage_get_upload_connection(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((*ppStorageServer=storage_make_connection(
|
if ((*ppStorageServer=tracker_make_connection(
|
||||||
*ppStorageServer, &result)) == NULL)
|
*ppStorageServer, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -309,7 +213,6 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
int result;
|
int result;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int filename_len;
|
int filename_len;
|
||||||
char *file_buff;
|
char *file_buff;
|
||||||
|
|
@ -347,15 +250,15 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_GET_METADATA;
|
pHeader->cmd = STORAGE_PROTO_CMD_GET_METADATA;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +314,6 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||||
char in_buff[3 * FDFS_PROTO_PKG_LEN_SIZE + IP_ADDRESS_SIZE];
|
char in_buff[3 * FDFS_PROTO_PKG_LEN_SIZE + IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char buff[64];
|
char buff[64];
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int filename_len;
|
int filename_len;
|
||||||
|
|
@ -448,15 +350,15 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_QUERY_FILE_INFO;
|
pHeader->cmd = STORAGE_PROTO_CMD_QUERY_FILE_INFO;
|
||||||
pHeader->status = bSilence ? ENOENT : 0;
|
pHeader->status = bSilence ? ENOENT : 0;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -473,25 +375,25 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != sizeof(in_buff))
|
if (in_bytes != sizeof(in_buff))
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"recv data from storage server %s:%u fail, " \
|
||||||
"recv data from storage server %s:%u fail, "
|
"recv bytes: %"PRId64" != %d", __LINE__, \
|
||||||
"recv bytes: %"PRId64" != %d", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, in_bytes, (int)sizeof(in_buff));
|
in_bytes, (int)sizeof(in_buff));
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_base64_context_inited)
|
if (!the_base64_context_inited)
|
||||||
{
|
{
|
||||||
g_base64_context_inited = 1;
|
the_base64_context_inited = 1;
|
||||||
base64_init_ex(&g_fdfs_base64_context, 0, '-', '_', '.');
|
base64_init_ex(&the_base64_context, 0, '-', '_', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buff, 0, sizeof(buff));
|
memset(buff, 0, sizeof(buff));
|
||||||
if (filename_len >= FDFS_LOGIC_FILE_PATH_LEN \
|
if (filename_len >= FDFS_LOGIC_FILE_PATH_LEN \
|
||||||
+ FDFS_FILENAME_BASE64_LENGTH + FDFS_FILE_EXT_NAME_MAX_LEN + 1)
|
+ FDFS_FILENAME_BASE64_LENGTH + FDFS_FILE_EXT_NAME_MAX_LEN + 1)
|
||||||
{
|
{
|
||||||
base64_decode_auto(&g_fdfs_base64_context, (char *)filename + \
|
base64_decode_auto(&the_base64_context, (char *)filename + \
|
||||||
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
||||||
buff, &buff_len);
|
buff, &buff_len);
|
||||||
}
|
}
|
||||||
|
|
@ -545,7 +447,6 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
|
||||||
int result;
|
int result;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pBuff;
|
char *pBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -579,15 +480,15 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_DELETE_FILE;
|
pHeader->cmd = STORAGE_PROTO_CMD_DELETE_FILE;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,7 +536,6 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
||||||
int result;
|
int result;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int out_bytes;
|
int out_bytes;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -670,21 +570,21 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
||||||
p += 8;
|
p += 8;
|
||||||
snprintf(p, sizeof(out_buff) - (p - out_buff), "%s", group_name);
|
snprintf(p, sizeof(out_buff) - (p - out_buff), "%s", group_name);
|
||||||
p += FDFS_GROUP_NAME_MAX_LEN;
|
p += FDFS_GROUP_NAME_MAX_LEN;
|
||||||
filename_len = snprintf(p, sizeof(out_buff) -
|
filename_len = snprintf(p, sizeof(out_buff) - (p - out_buff), \
|
||||||
(p - out_buff), "%s", remote_filename);
|
"%s", remote_filename);
|
||||||
p += filename_len;
|
p += filename_len;
|
||||||
out_bytes = p - out_buff;
|
out_bytes = p - out_buff;
|
||||||
long2buff(out_bytes - sizeof(TrackerHeader), pHeader->pkg_len);
|
long2buff(out_bytes - sizeof(TrackerHeader), pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_DOWNLOAD_FILE;
|
pHeader->cmd = STORAGE_PROTO_CMD_DOWNLOAD_FILE;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
out_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
out_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -748,14 +648,15 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
||||||
recv_bytes = remain_bytes;
|
recv_bytes = remain_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tcprecvdata_nb(pStorageServer->sock, buff,
|
if ((result=tcprecvdata_nb(pStorageServer->sock, buff, \
|
||||||
recv_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
recv_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"recv data from storage server " \
|
||||||
"recv data from storage server %s:%u fail, "
|
"%s:%u fail, " \
|
||||||
"errno: %d, error info: %s", __LINE__,
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
formatted_ip, pStorageServer->port,
|
pStorageServer->ip_addr, \
|
||||||
|
pStorageServer->port, \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -920,10 +821,9 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int64_t total_send_bytes;
|
int64_t total_send_bytes;
|
||||||
char in_buff[128];
|
char in_buff[128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
bool new_connection = false;
|
bool new_connection;
|
||||||
bool bUploadSlave;
|
bool bUploadSlave;
|
||||||
int new_store_path;
|
int new_store_path;
|
||||||
int master_filename_len;
|
int master_filename_len;
|
||||||
|
|
@ -952,30 +852,26 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
bUploadSlave = (strlen(group_name) > 0 && master_filename_len > 0);
|
bUploadSlave = (strlen(group_name) > 0 && master_filename_len > 0);
|
||||||
if (bUploadSlave)
|
if (bUploadSlave)
|
||||||
{
|
{
|
||||||
if ((result=storage_get_update_connection(pTrackerServer,
|
if ((result=storage_get_update_connection(pTrackerServer, \
|
||||||
&pStorageServer, group_name, master_filename,
|
&pStorageServer, group_name, master_filename, \
|
||||||
&storageServer, &new_connection)) != 0)
|
&storageServer, &new_connection)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ((result=storage_get_upload_connection(pTrackerServer, \
|
||||||
{
|
&pStorageServer, group_name, &storageServer, \
|
||||||
if ((result=storage_get_upload_connection(pTrackerServer,
|
|
||||||
&pStorageServer, group_name, &storageServer,
|
|
||||||
&new_store_path, &new_connection)) != 0)
|
&new_store_path, &new_connection)) != 0)
|
||||||
{
|
{
|
||||||
*group_name = '\0';
|
*group_name = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*group_name = '\0';
|
*group_name = '\0';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
//logInfo("upload to storage %s:%u\n", \
|
//logInfo("upload to storage %s:%u\n", \
|
||||||
formatted_ip, pStorageServer->port);
|
pStorageServer->ip_addr, pStorageServer->port);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
@ -1041,14 +937,14 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
pHeader->cmd = cmd;
|
pHeader->cmd = cmd;
|
||||||
pHeader->status = 0;
|
pHeader->status = 0;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1063,15 +959,15 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||||
{
|
{
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||||
(char *)file_buff, file_size,
|
(char *)file_buff, file_size, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1097,11 +993,12 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
"should > %d", __LINE__, \
|
||||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
|
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1261,7 +1158,6 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
char out_buff[sizeof(TrackerHeader)+2*FDFS_PROTO_PKG_LEN_SIZE+\
|
char out_buff[sizeof(TrackerHeader)+2*FDFS_PROTO_PKG_LEN_SIZE+\
|
||||||
FDFS_GROUP_NAME_MAX_LEN+128];
|
FDFS_GROUP_NAME_MAX_LEN+128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
char *pBuff;
|
char *pBuff;
|
||||||
|
|
@ -1272,8 +1168,8 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
char *pEnd;
|
char *pEnd;
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
|
|
||||||
if ((result=storage_get_update_connection(pTrackerServer,
|
if ((result=storage_get_update_connection(pTrackerServer, \
|
||||||
&pStorageServer, group_name, filename,
|
&pStorageServer, group_name, filename, \
|
||||||
&storageServer, &new_connection)) != 0)
|
&storageServer, &new_connection)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1318,29 +1214,30 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
p += filename_len;
|
p += filename_len;
|
||||||
|
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
long2buff((int)(p - (out_buff + sizeof(TrackerHeader))) +
|
long2buff((int)(p - (out_buff + sizeof(TrackerHeader))) + \
|
||||||
meta_bytes, pHeader->pkg_len);
|
meta_bytes, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_SET_METADATA;
|
pHeader->cmd = STORAGE_PROTO_CMD_SET_METADATA;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta_bytes > 0 && (result=tcpsenddata_nb(pStorageServer->sock,
|
if (meta_bytes > 0 && (result=tcpsenddata_nb(pStorageServer->sock, \
|
||||||
meta_buff, meta_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
meta_buff, meta_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1441,7 +1338,6 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
||||||
FDFS_GROUP_NAME_MAX_LEN + FDFS_FILE_PREFIX_MAX_LEN + \
|
FDFS_GROUP_NAME_MAX_LEN + FDFS_FILE_PREFIX_MAX_LEN + \
|
||||||
FDFS_FILE_EXT_NAME_MAX_LEN + 256];
|
FDFS_FILE_EXT_NAME_MAX_LEN + 256];
|
||||||
char in_buff[128];
|
char in_buff[128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int group_name_len;
|
int group_name_len;
|
||||||
int master_filename_len;
|
int master_filename_len;
|
||||||
|
|
@ -1539,11 +1435,11 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1559,11 +1455,12 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
"should > %d", __LINE__, \
|
||||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
|
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1792,7 +1689,6 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
char out_buff[512];
|
char out_buff[512];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int64_t total_send_bytes;
|
int64_t total_send_bytes;
|
||||||
|
|
@ -1810,9 +1706,8 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
//printf("upload to storage %s:%u\n", \
|
//printf("upload to storage %s:%u\n", \
|
||||||
formatted_ip, pStorageServer->port);
|
pStorageServer->ip_addr, pStorageServer->port);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
@ -1828,19 +1723,19 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
memcpy(p, appender_filename, appender_filename_len);
|
memcpy(p, appender_filename, appender_filename_len);
|
||||||
p += appender_filename_len;
|
p += appender_filename_len;
|
||||||
|
|
||||||
long2buff((p - out_buff) + file_size - sizeof(TrackerHeader),
|
long2buff((p - out_buff) + file_size - sizeof(TrackerHeader), \
|
||||||
pHeader->pkg_len);
|
pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_APPEND_FILE;
|
pHeader->cmd = STORAGE_PROTO_CMD_APPEND_FILE;
|
||||||
pHeader->status = 0;
|
pHeader->status = 0;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1855,15 +1750,15 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||||
{
|
{
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||||
(char *)file_buff, file_size,
|
(char *)file_buff, file_size, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1887,10 +1782,10 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != 0)
|
if (in_bytes != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, in_bytes);
|
pStorageServer->port, in_bytes);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1923,7 +1818,6 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
char out_buff[512];
|
char out_buff[512];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int64_t total_send_bytes;
|
int64_t total_send_bytes;
|
||||||
|
|
@ -1940,9 +1834,8 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
//printf("upload to storage %s:%u\n", \
|
//printf("upload to storage %s:%u\n", \
|
||||||
formatted_ip, pStorageServer->port);
|
pStorageServer->ip_addr, pStorageServer->port);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
@ -1961,41 +1854,42 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
||||||
memcpy(p, appender_filename, appender_filename_len);
|
memcpy(p, appender_filename, appender_filename_len);
|
||||||
p += appender_filename_len;
|
p += appender_filename_len;
|
||||||
|
|
||||||
long2buff((p - out_buff) + file_size - sizeof(TrackerHeader),
|
long2buff((p - out_buff) + file_size - sizeof(TrackerHeader), \
|
||||||
pHeader->pkg_len);
|
pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_MODIFY_FILE;
|
pHeader->cmd = STORAGE_PROTO_CMD_MODIFY_FILE;
|
||||||
pHeader->status = 0;
|
pHeader->status = 0;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upload_type == FDFS_UPLOAD_BY_FILE)
|
if (upload_type == FDFS_UPLOAD_BY_FILE)
|
||||||
{
|
{
|
||||||
if ((result=tcpsendfile(pStorageServer->sock, file_buff,
|
if ((result=tcpsendfile(pStorageServer->sock, file_buff, \
|
||||||
file_size, SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0)
|
file_size, SF_G_NETWORK_TIMEOUT, \
|
||||||
|
&total_send_bytes)) != 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||||
{
|
{
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||||
(char *)file_buff, file_size,
|
(char *)file_buff, file_size, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2019,10 +1913,10 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != 0)
|
if (in_bytes != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, in_bytes);
|
pStorageServer->port, in_bytes);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -2245,10 +2139,10 @@ int fdfs_get_file_info_ex(const char *group_name, const char *remote_filename, \
|
||||||
char buff[64];
|
char buff[64];
|
||||||
|
|
||||||
memset(pFileInfo, 0, sizeof(FDFSFileInfo));
|
memset(pFileInfo, 0, sizeof(FDFSFileInfo));
|
||||||
if (!g_base64_context_inited)
|
if (!the_base64_context_inited)
|
||||||
{
|
{
|
||||||
g_base64_context_inited = 1;
|
the_base64_context_inited = 1;
|
||||||
base64_init_ex(&g_fdfs_base64_context, 0, '-', '_', '.');
|
base64_init_ex(&the_base64_context, 0, '-', '_', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_len = strlen(remote_filename);
|
filename_len = strlen(remote_filename);
|
||||||
|
|
@ -2262,7 +2156,7 @@ int fdfs_get_file_info_ex(const char *group_name, const char *remote_filename, \
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buff, 0, sizeof(buff));
|
memset(buff, 0, sizeof(buff));
|
||||||
base64_decode_auto(&g_fdfs_base64_context, (char *)remote_filename + \
|
base64_decode_auto(&the_base64_context, (char *)remote_filename + \
|
||||||
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
||||||
buff, &buff_len);
|
buff, &buff_len);
|
||||||
|
|
||||||
|
|
@ -2392,7 +2286,6 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
char out_buff[512];
|
char out_buff[512];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
|
|
@ -2408,9 +2301,8 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
//printf("upload to storage %s:%u\n", \
|
//printf("upload to storage %s:%u\n", \
|
||||||
formatted_ip, pStorageServer->port);
|
pStorageServer->ip_addr, pStorageServer->port);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
@ -2426,19 +2318,19 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
||||||
memcpy(p, appender_filename, appender_filename_len);
|
memcpy(p, appender_filename, appender_filename_len);
|
||||||
p += appender_filename_len;
|
p += appender_filename_len;
|
||||||
|
|
||||||
long2buff((p - out_buff) - sizeof(TrackerHeader),
|
long2buff((p - out_buff) - sizeof(TrackerHeader), \
|
||||||
pHeader->pkg_len);
|
pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_TRUNCATE_FILE;
|
pHeader->cmd = STORAGE_PROTO_CMD_TRUNCATE_FILE;
|
||||||
pHeader->status = 0;
|
pHeader->status = 0;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pStorageServer->ip_addr, pStorageServer->port, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2452,10 +2344,10 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != 0)
|
if (in_bytes != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, in_bytes);
|
pStorageServer->port, in_bytes);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -2479,7 +2371,6 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
||||||
int result;
|
int result;
|
||||||
char out_buff[512];
|
char out_buff[512];
|
||||||
char in_buff[256];
|
char in_buff[256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -2511,11 +2402,11 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to storage server %s:%u fail, "
|
"send data to storage server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->ip_addr, pStorageServer->port,
|
||||||
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2531,11 +2422,12 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"storage server %s:%u response data length: %"PRId64" "
|
"storage server %s:%u response data "
|
||||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
"length: %"PRId64" is invalid, "
|
||||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
"should > %d", __LINE__,
|
||||||
|
pStorageServer->ip_addr, pStorageServer->port,
|
||||||
|
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,6 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
IP_ADDRESS_SIZE];
|
IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
|
|
@ -294,15 +293,16 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + id_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + id_len, pHeader->pkg_len);
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_STORAGE;
|
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_STORAGE;
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + id_len,
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + id_len, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -330,10 +330,10 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes % sizeof(TrackerStorageStat) != 0)
|
if (in_bytes % sizeof(TrackerStorageStat) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64
|
"length: %"PRId64" is invalid", \
|
||||||
" is invalid", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
*storage_count = 0;
|
*storage_count = 0;
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
@ -342,12 +342,11 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
||||||
*storage_count = in_bytes / sizeof(TrackerStorageStat);
|
*storage_count = in_bytes / sizeof(TrackerStorageStat);
|
||||||
if (*storage_count > max_storages)
|
if (*storage_count > max_storages)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u insufficent space, " \
|
||||||
"tracker server %s:%u insufficent space, "
|
"max storage count: %d, expect count: %d", \
|
||||||
"max storage count: %d, expect count: %d",
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, max_storages, *storage_count);
|
||||||
max_storages, *storage_count);
|
|
||||||
*storage_count = 0;
|
*storage_count = 0;
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
@ -485,7 +484,6 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerGroupStat src;
|
TrackerGroupStat src;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -499,14 +497,15 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
||||||
sizeof(TrackerHeader), "%s", group_name);
|
sizeof(TrackerHeader), "%s", group_name);
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_ONE_GROUP;
|
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_ONE_GROUP;
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN, pHeader->pkg_len);
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -533,10 +532,10 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != sizeof(TrackerGroupStat))
|
if (in_bytes != sizeof(TrackerGroupStat))
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid", \
|
||||||
"is invalid", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -570,7 +569,6 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
||||||
TrackerGroupStat *pSrc;
|
TrackerGroupStat *pSrc;
|
||||||
TrackerGroupStat *pEnd;
|
TrackerGroupStat *pEnd;
|
||||||
FDFSGroupStat *pDest;
|
FDFSGroupStat *pDest;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
||||||
|
|
@ -579,14 +577,15 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.cmd = TRACKER_PROTO_CMD_SERVER_LIST_ALL_GROUPS;
|
header.cmd = TRACKER_PROTO_CMD_SERVER_LIST_ALL_GROUPS;
|
||||||
header.status = 0;
|
header.status = 0;
|
||||||
if ((result=tcpsenddata_nb(conn->sock, &header,
|
if ((result=tcpsenddata_nb(conn->sock, &header, \
|
||||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -614,10 +613,10 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes % sizeof(TrackerGroupStat) != 0)
|
if (in_bytes % sizeof(TrackerGroupStat) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid", \
|
||||||
"is invalid", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
*group_count = 0;
|
*group_count = 0;
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
@ -626,12 +625,11 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
||||||
*group_count = in_bytes / sizeof(TrackerGroupStat);
|
*group_count = in_bytes / sizeof(TrackerGroupStat);
|
||||||
if (*group_count > max_groups)
|
if (*group_count > max_groups)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u insufficent space, " \
|
||||||
"tracker server %s:%u insufficent space, "
|
"max group count: %d, expect count: %d", \
|
||||||
"max group count: %d, expect count: %d",
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, max_groups, *group_count);
|
||||||
max_groups, *group_count);
|
|
||||||
*group_count = 0;
|
*group_count = 0;
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
@ -674,7 +672,6 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 128];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 128];
|
||||||
char in_buff[sizeof(TrackerHeader) + TRACKER_QUERY_STORAGE_FETCH_BODY_LEN];
|
char in_buff[sizeof(TrackerHeader) + TRACKER_QUERY_STORAGE_FETCH_BODY_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -696,15 +693,16 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||||
pHeader->cmd = cmd;
|
pHeader->cmd = cmd;
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -731,11 +729,12 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != TRACKER_QUERY_STORAGE_FETCH_BODY_LEN)
|
if (in_bytes != TRACKER_QUERY_STORAGE_FETCH_BODY_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, expect length: %d", __LINE__,
|
"expect length: %d", __LINE__, \
|
||||||
formatted_ip, pTrackerServer->port, in_bytes,
|
pTrackerServer->ip_addr, \
|
||||||
|
pTrackerServer->port, in_bytes, \
|
||||||
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN);
|
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -760,7 +759,6 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
||||||
char in_buff[sizeof(TrackerHeader) + \
|
char in_buff[sizeof(TrackerHeader) + \
|
||||||
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN + \
|
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN + \
|
||||||
FDFS_MAX_SERVERS_EACH_GROUP * IP_ADDRESS_SIZE];
|
FDFS_MAX_SERVERS_EACH_GROUP * IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -783,11 +781,12 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -815,10 +814,10 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
||||||
if ((in_bytes - TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) % \
|
if ((in_bytes - TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) % \
|
||||||
(IP_ADDRESS_SIZE - 1) != 0)
|
(IP_ADDRESS_SIZE - 1) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid", \
|
||||||
"is invalid", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -827,11 +826,10 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
||||||
(IP_ADDRESS_SIZE - 1);
|
(IP_ADDRESS_SIZE - 1);
|
||||||
if (nMaxServerCount < *server_count)
|
if (nMaxServerCount < *server_count)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response storage server " \
|
||||||
"tracker server %s:%u response storage server "
|
"count: %d, exceeds max server count: %d!", __LINE__, \
|
||||||
"count: %d, exceeds max server count: %d!", __LINE__,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
formatted_ip, pTrackerServer->port,
|
|
||||||
*server_count, nMaxServerCount);
|
*server_count, nMaxServerCount);
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
@ -866,7 +864,6 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
||||||
TrackerHeader header;
|
TrackerHeader header;
|
||||||
char in_buff[sizeof(TrackerHeader) + \
|
char in_buff[sizeof(TrackerHeader) + \
|
||||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
|
|
@ -883,11 +880,12 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
||||||
if ((result=tcpsenddata_nb(conn->sock, &header, \
|
if ((result=tcpsenddata_nb(conn->sock, &header, \
|
||||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -914,12 +912,12 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid, " \
|
||||||
"is invalid, expect length: %d", __LINE__,
|
"expect length: %d", __LINE__, \
|
||||||
formatted_ip, pTrackerServer->port, in_bytes,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -945,7 +943,6 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char in_buff[sizeof(TrackerHeader) + \
|
char in_buff[sizeof(TrackerHeader) + \
|
||||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -962,15 +959,16 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN, pHeader->pkg_len);
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE;
|
pHeader->cmd = TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE;
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -997,11 +995,11 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data "
|
"length: %"PRId64" is invalid, " \
|
||||||
"length: %"PRId64" is invalid, expect length: %d",
|
"expect length: %d", __LINE__, \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -1029,7 +1027,6 @@ int tracker_query_storage_store_list_with_group( \
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char in_buff[sizeof(TrackerHeader) + FDFS_MAX_SERVERS_EACH_GROUP * \
|
char in_buff[sizeof(TrackerHeader) + FDFS_MAX_SERVERS_EACH_GROUP * \
|
||||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char returned_group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
|
char returned_group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
@ -1058,14 +1055,15 @@ int tracker_query_storage_store_list_with_group( \
|
||||||
}
|
}
|
||||||
|
|
||||||
long2buff(out_len, pHeader->pkg_len);
|
long2buff(out_len, pHeader->pkg_len);
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + out_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(TrackerHeader) + out_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1092,11 +1090,11 @@ int tracker_query_storage_store_list_with_group( \
|
||||||
|
|
||||||
if (in_bytes < TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
if (in_bytes < TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data "
|
"length: %"PRId64" is invalid, " \
|
||||||
"length: %"PRId64" is invalid, expect length >= %d",
|
"expect length >= %d", __LINE__, \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -1106,23 +1104,22 @@ int tracker_query_storage_store_list_with_group( \
|
||||||
ipPortsLen = in_bytes - (FDFS_GROUP_NAME_MAX_LEN + 1);
|
ipPortsLen = in_bytes - (FDFS_GROUP_NAME_MAX_LEN + 1);
|
||||||
if (ipPortsLen % RECORD_LENGTH != 0)
|
if (ipPortsLen % RECORD_LENGTH != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data "
|
"length: %"PRId64" is invalid", \
|
||||||
"length: %"PRId64" is invalid", __LINE__,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
formatted_ip, pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*storage_count = ipPortsLen / RECORD_LENGTH;
|
*storage_count = ipPortsLen / RECORD_LENGTH;
|
||||||
if (nMaxServerCount < *storage_count)
|
if (nMaxServerCount < *storage_count)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response storage server " \
|
||||||
"tracker server %s:%u response storage server "
|
"count: %d, exceeds max server count: %d!", \
|
||||||
"count: %d, exceeds max server count: %d!",
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, *storage_count, nMaxServerCount);
|
||||||
*storage_count, nMaxServerCount);
|
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1160,7 +1157,6 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
FDFSStorageInfo storage_infos[1];
|
FDFSStorageInfo storage_infos[1];
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE];
|
FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -1232,11 +1228,11 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
conn->port, result, STRERROR(result));
|
conn->ip_addr, conn->port,
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1284,7 +1280,6 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
||||||
TrackerServerInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
TrackerServerInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -1313,11 +1308,11 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
conn->port, result, STRERROR(result));
|
conn->ip_addr, conn->port,
|
||||||
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1348,7 +1343,6 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE];
|
FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char in_buff[FDFS_STORAGE_ID_MAX_SIZE];
|
char in_buff[FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -1386,15 +1380,15 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
conn->port, result, STRERROR(result));
|
conn->ip_addr, conn->port,
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
tracker_close_connection_ex(conn, true);
|
tracker_close_connection_ex(conn, true);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1444,7 +1438,6 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
IP_ADDRESS_SIZE];
|
IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
char *p;
|
char *p;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -1474,14 +1467,15 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
||||||
}
|
}
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_STATUS;
|
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_STATUS;
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + ip_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + ip_len, pHeader->pkg_len);
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1508,11 +1502,11 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (in_bytes != sizeof(FDFSStorageBrief))
|
if (in_bytes != sizeof(FDFSStorageBrief))
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data "
|
"length: %"PRId64" is invalid", \
|
||||||
"length: %"PRId64" is invalid", __LINE__,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
formatted_ip, pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1528,7 +1522,6 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
||||||
bool new_connection;
|
bool new_connection;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
IP_ADDRESS_SIZE];
|
IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int result;
|
int result;
|
||||||
int ip_len;
|
int ip_len;
|
||||||
|
|
@ -1562,14 +1555,15 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_SERVER_ID;
|
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_SERVER_ID;
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + ip_len, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + ip_len, pHeader->pkg_len);
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1595,10 +1589,10 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes == 0 || in_bytes >= FDFS_STORAGE_ID_MAX_SIZE)
|
if (in_bytes == 0 || in_bytes >= FDFS_STORAGE_ID_MAX_SIZE)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data length: %"PRId64" "
|
"length: %"PRId64" is invalid", \
|
||||||
"is invalid", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -1660,3 +1654,4 @@ int tracker_get_storage_max_status(TrackerServerGroup *pTrackerGroup, \
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,10 @@
|
||||||
#include "fastcommon/logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
|
|
||||||
Version g_fdfs_version = {6, 12, 2};
|
Version g_fdfs_version = {6, 9, 3};
|
||||||
bool g_use_connection_pool = false;
|
bool g_use_connection_pool = false;
|
||||||
ConnectionPool g_connection_pool;
|
ConnectionPool g_connection_pool;
|
||||||
int g_connection_pool_max_idle_time = 3600;
|
int g_connection_pool_max_idle_time = 3600;
|
||||||
struct base64_context g_fdfs_base64_context;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
data filename format:
|
data filename format:
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@
|
||||||
#define _FDFS_GLOBAL_H
|
#define _FDFS_GLOBAL_H
|
||||||
|
|
||||||
#include "fastcommon/common_define.h"
|
#include "fastcommon/common_define.h"
|
||||||
#include "fastcommon/base64.h"
|
|
||||||
#include "fastcommon/connection_pool.h"
|
|
||||||
#include "sf/sf_global.h"
|
#include "sf/sf_global.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
|
#include "fastcommon/connection_pool.h"
|
||||||
|
|
||||||
#define FDFS_FILE_EXT_NAME_MAX_LEN 6
|
#define FDFS_FILE_EXT_NAME_MAX_LEN 6
|
||||||
|
|
||||||
|
|
@ -27,7 +26,6 @@ extern Version g_fdfs_version;
|
||||||
extern bool g_use_connection_pool;
|
extern bool g_use_connection_pool;
|
||||||
extern ConnectionPool g_connection_pool;
|
extern ConnectionPool g_connection_pool;
|
||||||
extern int g_connection_pool_max_idle_time;
|
extern int g_connection_pool_max_idle_time;
|
||||||
extern struct base64_context g_fdfs_base64_context;
|
|
||||||
|
|
||||||
int fdfs_check_data_filename(const char *filename, const int len);
|
int fdfs_check_data_filename(const char *filename, const int len);
|
||||||
int fdfs_gen_slave_filename(const char *master_filename, \
|
int fdfs_gen_slave_filename(const char *master_filename, \
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ connect_timeout = 5
|
||||||
network_timeout = 60
|
network_timeout = 60
|
||||||
|
|
||||||
# the base path to store log files
|
# the base path to store log files
|
||||||
base_path = /opt/fastdfs
|
base_path = /home/yuqing/fastdfs
|
||||||
|
|
||||||
# tracker_server can ocur more than once for multi tracker servers.
|
# tracker_server can ocur more than once for multi tracker servers.
|
||||||
# the value format of tracker_server is "HOST:PORT",
|
# the value format of tracker_server is "HOST:PORT",
|
||||||
|
|
@ -16,13 +16,9 @@ base_path = /opt/fastdfs
|
||||||
# and the HOST can be dual IPs or hostnames seperated by comma,
|
# and the HOST can be dual IPs or hostnames seperated by comma,
|
||||||
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
|
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
|
||||||
# or two different types of inner (intranet) IPs.
|
# or two different types of inner (intranet) IPs.
|
||||||
# IPv4:
|
|
||||||
# for example: 192.168.2.100,122.244.141.46:22122
|
# for example: 192.168.2.100,122.244.141.46:22122
|
||||||
# another eg.: 192.168.1.10,172.17.4.21:22122
|
# another eg.: 192.168.1.10,172.17.4.21:22122
|
||||||
#
|
|
||||||
# IPv6:
|
|
||||||
# for example: [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e,fe80::1ee9:90a8:1351:436c]:22122
|
|
||||||
#
|
|
||||||
tracker_server = 192.168.0.196:22122
|
tracker_server = 192.168.0.196:22122
|
||||||
tracker_server = 192.168.0.197:22122
|
tracker_server = 192.168.0.197:22122
|
||||||
|
|
||||||
|
|
@ -37,13 +33,6 @@ tracker_server = 192.168.0.197:22122
|
||||||
### debug
|
### debug
|
||||||
log_level = info
|
log_level = info
|
||||||
|
|
||||||
# connect which ip address first for multi IPs of a storage server, value list:
|
|
||||||
## tracker: connect to the ip address return by tracker server first
|
|
||||||
## last-connected: connect to the ip address last connected first
|
|
||||||
# default value is tracker
|
|
||||||
# since V6.11
|
|
||||||
connect_first_by = tracker
|
|
||||||
|
|
||||||
# if use connection pool
|
# if use connection pool
|
||||||
# default value is false
|
# default value is false
|
||||||
# since V4.05
|
# since V4.05
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,6 @@ group_name = group1
|
||||||
|
|
||||||
# bind an address of this host
|
# bind an address of this host
|
||||||
# empty for bind all addresses of this host
|
# empty for bind all addresses of this host
|
||||||
#
|
|
||||||
# bind IPv4 example: 192.168.2.100
|
|
||||||
#
|
|
||||||
# bind IPv6 example: 2409:8a20:42d:2f40:587a:4c47:72c0:ad8e
|
|
||||||
#
|
|
||||||
# bind IPv4 and IPv6 example: 192.168.2.100,2409:8a20:42d:2f40:587a:4c47:72c0:ad8e
|
|
||||||
#
|
|
||||||
# as any/all addresses, IPv4 is 0.0.0.0, IPv6 is ::
|
|
||||||
#
|
|
||||||
bind_addr =
|
bind_addr =
|
||||||
|
|
||||||
# if bind an address of this host when connect to other servers
|
# if bind an address of this host when connect to other servers
|
||||||
|
|
@ -32,27 +23,6 @@ client_bind = true
|
||||||
# the storage server port
|
# the storage server port
|
||||||
port = 23000
|
port = 23000
|
||||||
|
|
||||||
# the address family of service, value list:
|
|
||||||
## IPv4: IPv4 stack
|
|
||||||
## IPv6: IPv6 stack
|
|
||||||
## auto: auto detect by bind_addr, IPv4 first then IPv6 when bind_addr is empty
|
|
||||||
## both: IPv4 and IPv6 dual stacks
|
|
||||||
# default value is auto
|
|
||||||
# since V6.11
|
|
||||||
address_family = auto
|
|
||||||
|
|
||||||
|
|
||||||
# specify the storage server ID for NAT network
|
|
||||||
# NOT set or commented for auto set by the local ip addresses
|
|
||||||
# since V6.11
|
|
||||||
#
|
|
||||||
# NOTE:
|
|
||||||
## * this paramter is valid only when use_storage_id and trust_storage_server_id
|
|
||||||
## in tracker.conf set to true
|
|
||||||
## * the storage server id must exist in storage_ids.conf
|
|
||||||
#server_id =
|
|
||||||
|
|
||||||
|
|
||||||
# connect timeout in seconds
|
# connect timeout in seconds
|
||||||
# default value is 30
|
# default value is 30
|
||||||
# Note: in the intranet network (LAN), 2 seconds is enough.
|
# Note: in the intranet network (LAN), 2 seconds is enough.
|
||||||
|
|
@ -76,7 +46,7 @@ stat_report_interval = 60
|
||||||
# NOTE: the binlog files maybe are large, make sure
|
# NOTE: the binlog files maybe are large, make sure
|
||||||
# the base path has enough disk space,
|
# the base path has enough disk space,
|
||||||
# eg. the disk free space should > 50GB
|
# eg. the disk free space should > 50GB
|
||||||
base_path = /opt/fastdfs
|
base_path = /home/yuqing/fastdfs
|
||||||
|
|
||||||
# max concurrent connections the server supported,
|
# max concurrent connections the server supported,
|
||||||
# you should set this parameter larger, eg. 10240
|
# you should set this parameter larger, eg. 10240
|
||||||
|
|
@ -156,8 +126,8 @@ store_path_count = 1
|
||||||
# the store paths' order is very important, don't mess up!!!
|
# the store paths' order is very important, don't mess up!!!
|
||||||
# the base_path should be independent (different) of the store paths
|
# the base_path should be independent (different) of the store paths
|
||||||
|
|
||||||
store_path0 = /opt/fastdfs
|
store_path0 = /home/yuqing/fastdfs
|
||||||
#store_path1 = /opt/fastdfs2
|
#store_path1 = /home/yuqing/fastdfs2
|
||||||
|
|
||||||
# subdir_count * subdir_count directories will be auto created under each
|
# subdir_count * subdir_count directories will be auto created under each
|
||||||
# store_path (disk), value can be 1 to 256, default value is 256
|
# store_path (disk), value can be 1 to 256, default value is 256
|
||||||
|
|
@ -169,13 +139,9 @@ subdir_count_per_path = 256
|
||||||
# and the HOST can be dual IPs or hostnames seperated by comma,
|
# and the HOST can be dual IPs or hostnames seperated by comma,
|
||||||
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
|
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
|
||||||
# or two different types of inner (intranet) IPs.
|
# or two different types of inner (intranet) IPs.
|
||||||
# IPv4:
|
|
||||||
# for example: 192.168.2.100,122.244.141.46:22122
|
# for example: 192.168.2.100,122.244.141.46:22122
|
||||||
# another eg.: 192.168.1.10,172.17.4.21:22122
|
# another eg.: 192.168.1.10,172.17.4.21:22122
|
||||||
#
|
|
||||||
# IPv6:
|
|
||||||
# for example: [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e,fe80::1ee9:90a8:1351:436c]:22122
|
|
||||||
#
|
|
||||||
tracker_server = 192.168.209.121:22122
|
tracker_server = 192.168.209.121:22122
|
||||||
tracker_server = 192.168.209.122:22122
|
tracker_server = 192.168.209.122:22122
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,11 @@
|
||||||
# storage ip or hostname can be dual IPs seperated by comma,
|
# storage ip or hostname can be dual IPs seperated by comma,
|
||||||
# one is an inner (intranet) IP and another is an outer (extranet) IP,
|
# one is an inner (intranet) IP and another is an outer (extranet) IP,
|
||||||
# or two different types of inner (intranet) IPs
|
# or two different types of inner (intranet) IPs
|
||||||
# IPv4:
|
|
||||||
# for example: 192.168.2.100,122.244.141.46
|
# for example: 192.168.2.100,122.244.141.46
|
||||||
# another eg.: 192.168.1.10,172.17.4.21
|
# another eg.: 192.168.1.10,172.17.4.21
|
||||||
#
|
#
|
||||||
# IPv6:
|
|
||||||
# or example: [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e,fe80::1ee9:90a8:1351:436c]
|
|
||||||
# another eg.: [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e,fe80::1ee9:90a8:1351:436c]:100002
|
|
||||||
#
|
|
||||||
# the port is optional. if you run more than one storaged instances
|
# the port is optional. if you run more than one storaged instances
|
||||||
# in a server, you must specified the port to distinguish different instances.
|
# in a server, you must specified the port to distinguish different instances.
|
||||||
|
|
||||||
100001 group1 192.168.0.196
|
100001 group1 192.168.0.196
|
||||||
100002 group1 192.168.0.197
|
100002 group1 192.168.0.197
|
||||||
100003 group1 [2409:8a20:42d:2f40:587a:4c47:72c0:ad8e]:100002
|
|
||||||
|
|
|
||||||
|
|
@ -5,33 +5,11 @@ disabled = false
|
||||||
|
|
||||||
# bind an address of this host
|
# bind an address of this host
|
||||||
# empty for bind all addresses of this host
|
# empty for bind all addresses of this host
|
||||||
#
|
|
||||||
# bind IPv4 example: 192.168.2.100
|
|
||||||
#
|
|
||||||
# bind IPv6 example: 2409:8a20:42d:2f40:587a:4c47:72c0:ad8e
|
|
||||||
#
|
|
||||||
# bind IPv4 and IPv6 example: 192.168.2.100,2409:8a20:42d:2f40:587a:4c47:72c0:ad8e
|
|
||||||
#
|
|
||||||
# as any/all addresses, IPv4 is 0.0.0.0, IPv6 is ::
|
|
||||||
#
|
|
||||||
bind_addr =
|
bind_addr =
|
||||||
|
|
||||||
# the tracker server port
|
# the tracker server port
|
||||||
port = 22122
|
port = 22122
|
||||||
|
|
||||||
# the address family of service, value list:
|
|
||||||
## IPv4: IPv4 stack
|
|
||||||
## IPv6: IPv6 stack
|
|
||||||
## auto: auto detect by bind_addr, IPv4 first then IPv6 when bind_addr is empty
|
|
||||||
## both: IPv4 and IPv6 dual stacks
|
|
||||||
#
|
|
||||||
# following parameter use_storage_id MUST set to true and
|
|
||||||
# id_type_in_filename MUST set to id when IPv6 enabled
|
|
||||||
#
|
|
||||||
# default value is auto
|
|
||||||
# since V6.11
|
|
||||||
address_family = auto
|
|
||||||
|
|
||||||
# connect timeout in seconds
|
# connect timeout in seconds
|
||||||
# default value is 30
|
# default value is 30
|
||||||
# Note: in the intranet network (LAN), 2 seconds is enough.
|
# Note: in the intranet network (LAN), 2 seconds is enough.
|
||||||
|
|
@ -42,7 +20,7 @@ connect_timeout = 5
|
||||||
network_timeout = 60
|
network_timeout = 60
|
||||||
|
|
||||||
# the base path to store data and log files
|
# the base path to store data and log files
|
||||||
base_path = /opt/fastdfs
|
base_path = /home/yuqing/fastdfs
|
||||||
|
|
||||||
# max concurrent connections this server support
|
# max concurrent connections this server support
|
||||||
# you should set this parameter larger, eg. 10240
|
# you should set this parameter larger, eg. 10240
|
||||||
|
|
@ -103,12 +81,7 @@ download_server = 0
|
||||||
### M or m for megabyte(MB)
|
### M or m for megabyte(MB)
|
||||||
### K or k for kilobyte(KB)
|
### K or k for kilobyte(KB)
|
||||||
### no unit for byte(B)
|
### no unit for byte(B)
|
||||||
#
|
|
||||||
### XX.XX% as ratio such as: reserved_storage_space = 10%
|
### XX.XX% as ratio such as: reserved_storage_space = 10%
|
||||||
#
|
|
||||||
# NOTE:
|
|
||||||
## the absolute reserved space is the sum of all store paths in the storage server
|
|
||||||
## the reserved space ratio is for each store path
|
|
||||||
reserved_storage_space = 20%
|
reserved_storage_space = 20%
|
||||||
|
|
||||||
#standard log level as syslog, case insensitive, value list:
|
#standard log level as syslog, case insensitive, value list:
|
||||||
|
|
@ -287,13 +260,6 @@ storage_ids_filename = storage_ids.conf
|
||||||
# since V4.03
|
# since V4.03
|
||||||
id_type_in_filename = id
|
id_type_in_filename = id
|
||||||
|
|
||||||
# if trust the storage server ID sent by the storage server
|
|
||||||
# this paramter is valid only when use_storage_id set to true
|
|
||||||
# default value is true
|
|
||||||
# since V6.11
|
|
||||||
trust_storage_server_id = true
|
|
||||||
|
|
||||||
|
|
||||||
# if store slave file use symbol link
|
# if store slave file use symbol link
|
||||||
# default value is false
|
# default value is false
|
||||||
# since V4.01
|
# since V4.01
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
FastDFS is an open source high performance distributed file system. Its major
|
|
||||||
functions include: file storing, file syncing and file accessing (file uploading
|
|
||||||
and file downloading), and it can resolve the high capacity and load balancing
|
|
||||||
problem. FastDFS should meet the requirement of the website whose service based
|
|
||||||
on files such as photo sharing site and video sharing site.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
fastdfs (6.12.1-1) stable; urgency=medium
|
|
||||||
|
|
||||||
* adapt to libserverframe 1.2.3
|
|
||||||
* bugfixed: notify_leader_changed support IPv6 correctly
|
|
||||||
* log square quoted IPv6 address
|
|
||||||
|
|
||||||
-- YuQing <384681@qq.com> Wed, 6 Mar 2024 15:14:27 +0000
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
11
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
Source: fastdfs
|
|
||||||
Section: admin
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: YuQing <384681@qq.com>
|
|
||||||
Build-Depends: debhelper (>=11~),
|
|
||||||
libfastcommon-dev (>= 1.0.73),
|
|
||||||
libserverframe-dev (>= 1.2.3)
|
|
||||||
Standards-Version: 4.1.4
|
|
||||||
Homepage: http://github.com/happyfish100/fastdfs/
|
|
||||||
|
|
||||||
Package: fastdfs
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Depends: fastdfs-server (= ${binary:Version}),
|
|
||||||
fastdfs-tool (= ${binary:Version}),
|
|
||||||
${misc:Depends}
|
|
||||||
Description: FastDFS server and client
|
|
||||||
|
|
||||||
Package: fastdfs-server
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Depends: libfastcommon (>= ${libfastcommon:Version}),
|
|
||||||
libserverframe (>= ${libserverframe:Version}),
|
|
||||||
fastdfs-config (>= ${fastdfs-config:Version}),
|
|
||||||
${misc:Depends}, ${shlibs:Depends}
|
|
||||||
Description: FastDFS server
|
|
||||||
|
|
||||||
Package: libfdfsclient
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Depends: libfastcommon (>= ${libfastcommon:Version}),
|
|
||||||
libserverframe (>= ${libserverframe:Version}),
|
|
||||||
${misc:Depends}, ${shlibs:Depends}
|
|
||||||
Description: FastDFS client tools
|
|
||||||
|
|
||||||
Package: libfdfsclient-dev
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Depends: libfdfsclient (= ${binary:Version}),
|
|
||||||
${misc:Depends}
|
|
||||||
Description: header files of FastDFS client library
|
|
||||||
This package provides the header files of libfdfsclient
|
|
||||||
|
|
||||||
Package: fastdfs-tool
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Depends: libfdfsclient (= ${binary:Version}),
|
|
||||||
fastdfs-config (>= ${fastdfs-config:Version}),
|
|
||||||
${misc:Depends}, ${shlibs:Depends}
|
|
||||||
Description: FastDFS client tools
|
|
||||||
|
|
||||||
Package: fastdfs-config
|
|
||||||
Architecture: linux-any
|
|
||||||
Multi-Arch: foreign
|
|
||||||
Description: FastDFS config files for sample
|
|
||||||
FastDFS config files for sample including server and client
|
|
||||||
|
|
@ -1,675 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
etc/fdfs/*.conf
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
opt/fastdfs
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
usr/bin/fdfs_trackerd
|
|
||||||
usr/bin/fdfs_storaged
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
opt/fastdfs
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
usr/bin/fdfs_monitor
|
|
||||||
usr/bin/fdfs_test
|
|
||||||
usr/bin/fdfs_test1
|
|
||||||
usr/bin/fdfs_crc32
|
|
||||||
usr/bin/fdfs_upload_file
|
|
||||||
usr/bin/fdfs_download_file
|
|
||||||
usr/bin/fdfs_delete_file
|
|
||||||
usr/bin/fdfs_file_info
|
|
||||||
usr/bin/fdfs_appender_test
|
|
||||||
usr/bin/fdfs_appender_test1
|
|
||||||
usr/bin/fdfs_append_file
|
|
||||||
usr/bin/fdfs_upload_appender
|
|
||||||
usr/bin/fdfs_regenerate_filename
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
usr/include/fastdfs/*
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
usr/lib/libfdfsclient*
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
export DH_VERBOSE=1
|
|
||||||
export DESTDIR=$(CURDIR)/debian/tmp
|
|
||||||
|
|
||||||
export CONFDIR=$(DESTDIR)/etc/fdfs/
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
||||||
|
|
||||||
|
|
||||||
override_dh_auto_build:
|
|
||||||
./make.sh clean && DESTDIR=$(DESTDIR) ./make.sh
|
|
||||||
|
|
||||||
override_dh_auto_install:
|
|
||||||
DESTDIR=$(DESTDIR) ./make.sh install
|
|
||||||
mkdir -p $(CONFDIR)
|
|
||||||
cp conf/*.conf $(CONFDIR)
|
|
||||||
cp systemd/fdfs_storaged.service debian/fastdfs-server.fdfs_storaged.service
|
|
||||||
cp systemd/fdfs_trackerd.service debian/fastdfs-server.fdfs_trackerd.service
|
|
||||||
|
|
||||||
dh_auto_install
|
|
||||||
|
|
||||||
override_dh_installsystemd:
|
|
||||||
dh_installsystemd --package=fastdfs-server --name=fdfs_storaged --no-start --no-restart-on-upgrade
|
|
||||||
dh_installsystemd --package=fastdfs-server --name=fdfs_trackerd --no-start --no-restart-on-upgrade
|
|
||||||
|
|
||||||
.PHONY: override_dh_gencontrol
|
|
||||||
override_dh_gencontrol:
|
|
||||||
dh_gencontrol -- -Tdebian/substvars
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
3.0 (quilt)
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
libfastcommon:Version=1.0.73
|
|
||||||
libserverframe:Version=1.2.3
|
|
||||||
fastdfs-config:Version=1.0.0
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
version=3
|
|
||||||
opts="mode=git" https://github.com/happyfish100/fastdfs.git \
|
|
||||||
refs/tags/v([\d\.]+) debian uupdate
|
|
||||||
|
|
@ -11,82 +11,26 @@ ADD conf/nginx.conf /etc/fdfs/
|
||||||
ADD conf/mod_fastdfs.conf /etc/fdfs
|
ADD conf/mod_fastdfs.conf /etc/fdfs
|
||||||
|
|
||||||
# run
|
# run
|
||||||
# install packages
|
RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y \
|
||||||
RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
|
|
||||||
# git clone libfastcommon / libserverframe / fastdfs / fastdfs-nginx-module
|
|
||||||
RUN cd /usr/local/src \
|
|
||||||
&& git clone https://gitee.com/fastdfs100/libfastcommon.git \
|
|
||||||
&& git clone https://gitee.com/fastdfs100/libserverframe.git \
|
|
||||||
&& git clone https://gitee.com/fastdfs100/fastdfs.git \
|
|
||||||
&& git clone https://gitee.com/fastdfs100/fastdfs-nginx-module.git \
|
|
||||||
&& pwd && ls
|
|
||||||
# build libfastcommon / libserverframe / fastdfs
|
|
||||||
RUN mkdir /home/dfs \
|
|
||||||
&& cd /usr/local/src \
|
&& cd /usr/local/src \
|
||||||
&& pwd && ls \
|
&& git clone https://github.com/happyfish100/libfastcommon.git --depth 1 \
|
||||||
|
&& git clone https://github.com/happyfish100/fastdfs.git --depth 1 \
|
||||||
|
&& git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1 \
|
||||||
|
&& wget http://nginx.org/download/nginx-1.15.4.tar.gz \
|
||||||
|
&& tar -zxvf nginx-1.15.4.tar.gz \
|
||||||
|
&& mkdir /home/dfs \
|
||||||
|
&& cd /usr/local/src/ \
|
||||||
&& cd libfastcommon/ \
|
&& cd libfastcommon/ \
|
||||||
&& ./make.sh && ./make.sh install \
|
&& ./make.sh && ./make.sh install \
|
||||||
&& cd ../ \
|
&& cd ../ \
|
||||||
&& cd libserverframe/ \
|
&& cd fastdfs/ \
|
||||||
&& ./make.sh && ./make.sh install \
|
&& ./make.sh && ./make.sh install \
|
||||||
&& cd ../ \
|
&& cd ../ \
|
||||||
&& cd fastdfs/ \
|
&& cd nginx-1.15.4/ \
|
||||||
&& ./make.sh && ./make.sh install
|
|
||||||
# download nginx and build with fastdfs-nginx-module
|
|
||||||
# 推荐 NGINX 版本:
|
|
||||||
# NGINX_VERSION=1.16.1
|
|
||||||
# NGINX_VERSION=1.17.10
|
|
||||||
# NGINX_VERSION=1.18.0
|
|
||||||
# NGINX_VERSION=1.19.10
|
|
||||||
# NGINX_VERSION=1.20.2
|
|
||||||
# NGINX_VERSION=1.21.6
|
|
||||||
# NGINX_VERSION=1.22.1
|
|
||||||
# NGINX_VERSION=1.23.3
|
|
||||||
# 可在 docker build 命令中指定使用的 nginx 版本, 例如:
|
|
||||||
# docker build --build-arg NGINX_VERSION="1.16.1" -t happyfish100/fastdfs:latest -t happyfish100/fastdfs:6.09.01 .
|
|
||||||
# docker build --build-arg NGINX_VERSION="1.19.10" -t happyfish100/fastdfs:latest -t happyfish100/fastdfs:6.09.02 .
|
|
||||||
# docker build --build-arg NGINX_VERSION="1.23.3" -t happyfish100/fastdfs:latest -t happyfish100/fastdfs:6.09.03 .
|
|
||||||
ARG NGINX_VERSION=1.16.1
|
|
||||||
RUN cd /usr/local/src \
|
|
||||||
&& NGINX_PACKAGE=nginx-${NGINX_VERSION} \
|
|
||||||
&& NGINX_FILE=${NGINX_PACKAGE}.tar.gz \
|
|
||||||
&& wget http://nginx.org/download/${NGINX_FILE} \
|
|
||||||
&& tar -zxvf ${NGINX_FILE} \
|
|
||||||
&& pwd && ls \
|
|
||||||
&& cd /usr/local/src \
|
|
||||||
&& cd ${NGINX_PACKAGE}/ \
|
|
||||||
&& ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ \
|
&& ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ \
|
||||||
&& make && make install \
|
&& make && make install \
|
||||||
&& chmod +x /home/fastdfs.sh
|
&& chmod +x /home/fastdfs.sh
|
||||||
|
|
||||||
# 原来的 RUN 语句太复杂, 不利于 docker build 时使用多阶段构建缓存
|
|
||||||
# RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y \
|
|
||||||
# && NGINX_VERSION=1.19.9 \
|
|
||||||
# && NGINX_PACKAGE=nginx-${NGINX_VERSION} \
|
|
||||||
# && NGINX_FILE=${NGINX_PACKAGE}.tar.gz \
|
|
||||||
# && cd /usr/local/src \
|
|
||||||
# && git clone https://gitee.com/fastdfs100/libfastcommon.git \
|
|
||||||
# && git clone https://gitee.com/fastdfs100/libserverframe.git \
|
|
||||||
# && git clone https://gitee.com/fastdfs100/fastdfs.git \
|
|
||||||
# && git clone https://gitee.com/fastdfs100/fastdfs-nginx-module.git \
|
|
||||||
# && wget http://nginx.org/download/${NGINX_FILE} \
|
|
||||||
# && tar -zxvf ${NGINX_FILE} \
|
|
||||||
# && mkdir /home/dfs \
|
|
||||||
# && cd /usr/local/src/ \
|
|
||||||
# && cd libfastcommon/ \
|
|
||||||
# && ./make.sh && ./make.sh install \
|
|
||||||
# && cd ../ \
|
|
||||||
# && cd libserverframe/ \
|
|
||||||
# && ./make.sh && ./make.sh install \
|
|
||||||
# && cd ../ \
|
|
||||||
# && cd fastdfs/ \
|
|
||||||
# && ./make.sh && ./make.sh install \
|
|
||||||
# && cd ../ \
|
|
||||||
# && cd ${NGINX_PACKAGE}/ \
|
|
||||||
# && ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ \
|
|
||||||
# && make && make install \
|
|
||||||
# && chmod +x /home/fastdfs.sh
|
|
||||||
|
|
||||||
RUN ln -s /usr/local/src/fastdfs/init.d/fdfs_trackerd /etc/init.d/fdfs_trackerd \
|
RUN ln -s /usr/local/src/fastdfs/init.d/fdfs_trackerd /etc/init.d/fdfs_trackerd \
|
||||||
&& ln -s /usr/local/src/fastdfs/init.d/fdfs_storaged /etc/init.d/fdfs_storaged
|
&& ln -s /usr/local/src/fastdfs/init.d/fdfs_storaged /etc/init.d/fdfs_storaged
|
||||||
|
|
||||||
|
|
|
||||||
19
fastdfs.spec
19
fastdfs.spec
|
|
@ -7,26 +7,25 @@
|
||||||
%define CommitVersion %(echo $COMMIT_VERSION)
|
%define CommitVersion %(echo $COMMIT_VERSION)
|
||||||
|
|
||||||
Name: %{FastDFS}
|
Name: %{FastDFS}
|
||||||
Version: 6.12.2
|
Version: 6.9.3
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: FastDFS server and client
|
Summary: FastDFS server and client
|
||||||
License: GPL
|
License: GPL
|
||||||
Group: Arch/Tech
|
Group: Arch/Tech
|
||||||
URL: https://github.com/happyfish100/fastdfs/
|
URL: http://perso.orange.fr/sebastien.godard/
|
||||||
Source: https://github.com/happyfish100/fastdfs/%{name}-%{version}.tar.gz
|
Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
BuildRequires: libserverframe-devel >= 1.2.5
|
|
||||||
Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id
|
Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id
|
||||||
Requires: %{FDFSServer} = %{version}-%{release}
|
BuildRequires: libserverframe-devel >= 1.1.24
|
||||||
Requires: %{FDFSTool} = %{version}-%{release}
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package provides tracker & storage of fastdfs
|
This package provides tracker & storage of fastdfs
|
||||||
commit version: %{CommitVersion}
|
commit version: %{CommitVersion}
|
||||||
|
|
||||||
%package -n %{FDFSServer}
|
%package -n %{FDFSServer}
|
||||||
Requires: libserverframe >= 1.2.5
|
Requires: libserverframe >= 1.1.24
|
||||||
Requires: %{FDFSConfig}
|
Requires: %{FDFSConfig}
|
||||||
Summary: fastdfs tracker & storage
|
Summary: fastdfs tracker & storage
|
||||||
|
|
||||||
|
|
@ -35,7 +34,7 @@ Requires: %{FDFSClient}
|
||||||
Summary: fastdfs tools
|
Summary: fastdfs tools
|
||||||
|
|
||||||
%package -n %{FDFSClient}
|
%package -n %{FDFSClient}
|
||||||
Requires: libserverframe >= 1.2.5
|
Requires: libserverframe >= 1.1.24
|
||||||
Requires: %{FDFSConfig}
|
Requires: %{FDFSConfig}
|
||||||
Summary: The client dynamic library of fastdfs
|
Summary: The client dynamic library of fastdfs
|
||||||
|
|
||||||
|
|
@ -85,10 +84,6 @@ DESTDIR=$RPM_BUILD_ROOT ./make.sh install
|
||||||
|
|
||||||
%files
|
%files
|
||||||
|
|
||||||
%post -n %{FDFSServer}
|
|
||||||
systemctl enable fdfs_trackerd
|
|
||||||
systemctl enable fdfs_storaged
|
|
||||||
|
|
||||||
%files -n %{FDFSServer}
|
%files -n %{FDFSServer}
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
/usr/bin/fdfs_trackerd
|
/usr/bin/fdfs_trackerd
|
||||||
|
|
|
||||||
18
make.sh
18
make.sh
|
|
@ -6,7 +6,7 @@ TARGET_SYSTEMD_PATH=$DESTDIR/usr/lib/systemd/system
|
||||||
|
|
||||||
WITH_LINUX_SERVICE=1
|
WITH_LINUX_SERVICE=1
|
||||||
|
|
||||||
DEBUG_FLAG=0
|
DEBUG_FLAG=1
|
||||||
|
|
||||||
export CC=gcc
|
export CC=gcc
|
||||||
CFLAGS='-Wall'
|
CFLAGS='-Wall'
|
||||||
|
|
@ -22,9 +22,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /usr/include/fastcommon/_os_define.h ]; then
|
if [ -f /usr/include/fastcommon/_os_define.h ]; then
|
||||||
OS_BITS=$(grep -F OS_BITS /usr/include/fastcommon/_os_define.h | awk '{print $NF;}')
|
OS_BITS=$(fgrep OS_BITS /usr/include/fastcommon/_os_define.h | awk '{print $NF;}')
|
||||||
elif [ -f /usr/local/include/fastcommon/_os_define.h ]; then
|
elif [ -f /usr/local/include/fastcommon/_os_define.h ]; then
|
||||||
OS_BITS=$(grep -F OS_BITS /usr/local/include/fastcommon/_os_define.h | awk '{print $NF;}')
|
OS_BITS=$(fgrep OS_BITS /usr/local/include/fastcommon/_os_define.h | awk '{print $NF;}')
|
||||||
else
|
else
|
||||||
OS_BITS=64
|
OS_BITS=64
|
||||||
fi
|
fi
|
||||||
|
|
@ -32,15 +32,7 @@ fi
|
||||||
uname=$(uname)
|
uname=$(uname)
|
||||||
|
|
||||||
if [ "$OS_BITS" -eq 64 ]; then
|
if [ "$OS_BITS" -eq 64 ]; then
|
||||||
if [ $uname = 'Linux' ]; then
|
if [ "$uname" = "Darwin" ]; then
|
||||||
osname=$(cat /etc/os-release | grep -w NAME | awk -F '=' '{print $2;}' | \
|
|
||||||
awk -F '"' '{if (NF==3) {print $2} else {print $1}}' | awk '{print $1}')
|
|
||||||
if [ $osname = 'Ubuntu' -o $osname = 'Debian' ]; then
|
|
||||||
LIB_VERSION=lib
|
|
||||||
else
|
|
||||||
LIB_VERSION=lib64
|
|
||||||
fi
|
|
||||||
elif [ "$uname" = "Darwin" ]; then
|
|
||||||
LIB_VERSION=lib
|
LIB_VERSION=lib
|
||||||
else
|
else
|
||||||
LIB_VERSION=lib64
|
LIB_VERSION=lib64
|
||||||
|
|
@ -113,7 +105,7 @@ elif [ "$uname" = "FreeBSD" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $have_pthread -eq 0 ] && [ "$uname" != "Darwin" ]; then
|
if [ $have_pthread -eq 0 ] && [ "$uname" != "Darwin" ]; then
|
||||||
/sbin/ldconfig -p | grep -F libpthread.so > /dev/null
|
/sbin/ldconfig -p | fgrep libpthread.so > /dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
LIBS="$LIBS -lpthread"
|
LIBS="$LIBS -lpthread"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -943,7 +943,7 @@ static void php_fdfs_connect_server_impl(INTERNAL_FUNCTION_PARAMETERS, \
|
||||||
server_info.sock = -1;
|
server_info.sock = -1;
|
||||||
|
|
||||||
if ((pContext->err_no=conn_pool_connect_server(&server_info, \
|
if ((pContext->err_no=conn_pool_connect_server(&server_info, \
|
||||||
SF_G_NETWORK_TIMEOUT * 1000)) == 0)
|
SF_G_NETWORK_TIMEOUT)) == 0)
|
||||||
{
|
{
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
zend_add_assoc_stringl_ex(return_value, "ip_addr", \
|
zend_add_assoc_stringl_ex(return_value, "ip_addr", \
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ SHARED_OBJS = ../common/fdfs_global.o ../tracker/fdfs_shared_func.o \
|
||||||
storage_sync_func.o storage_service.o storage_sync.o \
|
storage_sync_func.o storage_service.o storage_sync.o \
|
||||||
storage_dio.o storage_ip_changed_dealer.o \
|
storage_dio.o storage_ip_changed_dealer.o \
|
||||||
storage_param_getter.o storage_disk_recovery.o \
|
storage_param_getter.o storage_disk_recovery.o \
|
||||||
file_id_hashtable.o \
|
|
||||||
trunk_mgr/trunk_mem.o trunk_mgr/trunk_shared.o \
|
trunk_mgr/trunk_mem.o trunk_mgr/trunk_shared.o \
|
||||||
trunk_mgr/trunk_sync.o trunk_mgr/trunk_client.o \
|
trunk_mgr/trunk_sync.o trunk_mgr/trunk_client.o \
|
||||||
trunk_mgr/trunk_free_block_checker.o \
|
trunk_mgr/trunk_free_block_checker.o \
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@
|
||||||
#include "trunk_mem.h"
|
#include "trunk_mem.h"
|
||||||
#include "trunk_sync.h"
|
#include "trunk_sync.h"
|
||||||
#include "trunk_shared.h"
|
#include "trunk_shared.h"
|
||||||
#include "file_id_hashtable.h"
|
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
#include "storage_httpd.h"
|
#include "storage_httpd.h"
|
||||||
|
|
@ -250,15 +249,8 @@ int main(int argc, char *argv[])
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=file_id_hashtable_init()) != 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();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=set_run_by(g_sf_global_vars.run_by.group,
|
|
||||||
g_sf_global_vars.run_by.user)) != 0)
|
|
||||||
{
|
{
|
||||||
logCrit("exit abnormally!\n");
|
logCrit("exit abnormally!\n");
|
||||||
log_destroy();
|
log_destroy();
|
||||||
|
|
@ -359,34 +351,18 @@ static void sigAlarmHandler(int sig)
|
||||||
logDebug("file: "__FILE__", line: %d, " \
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
"signal server to quit...", __LINE__);
|
"signal server to quit...", __LINE__);
|
||||||
|
|
||||||
if (SF_G_IPV4_ENABLED)
|
if (*SF_G_INNER_BIND_ADDR != '\0')
|
||||||
{
|
{
|
||||||
server.af = AF_INET;
|
strcpy(server.ip_addr, SF_G_INNER_BIND_ADDR);
|
||||||
if (*SF_G_INNER_BIND_ADDR4 != '\0')
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, SF_G_INNER_BIND_ADDR4);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(server.ip_addr, LOCAL_LOOPBACK_IPv4);
|
strcpy(server.ip_addr, "127.0.0.1");
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server.af = AF_INET6;
|
|
||||||
if (*SF_G_INNER_BIND_ADDR6 != '\0')
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, SF_G_INNER_BIND_ADDR6);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, LOCAL_LOOPBACK_IPv6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
server.port = SF_G_INNER_PORT;
|
server.port = SF_G_INNER_PORT;
|
||||||
server.sock = -1;
|
server.sock = -1;
|
||||||
|
|
||||||
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT * 1000) != 0)
|
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT) != 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -500,9 +476,9 @@ static int setup_schedule_tasks()
|
||||||
|
|
||||||
if (g_compress_binlog)
|
if (g_compress_binlog)
|
||||||
{
|
{
|
||||||
INIT_SCHEDULE_ENTRY_EX1(scheduleEntries[scheduleArray.count],
|
INIT_SCHEDULE_ENTRY_EX(scheduleEntries[scheduleArray.count],
|
||||||
sched_generate_next_id(), g_compress_binlog_time,
|
sched_generate_next_id(), g_compress_binlog_time,
|
||||||
24 * 3600, fdfs_binlog_compress_func, NULL, true);
|
24 * 3600, fdfs_binlog_compress_func, NULL);
|
||||||
scheduleArray.count++;
|
scheduleArray.count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fastcommon/logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fastcommon/sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fastcommon/local_ip_func.h"
|
|
||||||
#include "fastcommon/shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "fastcommon/ini_file_reader.h"
|
#include "fastcommon/ini_file_reader.h"
|
||||||
#include "fdht_func.h"
|
#include "fdht_func.h"
|
||||||
|
|
@ -226,12 +225,10 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
|
||||||
}
|
}
|
||||||
if (alloc_count < *id_count + (count + 1))
|
if (alloc_count < *id_count + (count + 1))
|
||||||
{
|
{
|
||||||
int *new_ids;
|
|
||||||
|
|
||||||
alloc_count += count + 1;
|
alloc_count += count + 1;
|
||||||
new_ids = (int *)realloc(*ppIds,
|
*ppIds = (int *)realloc(*ppIds, \
|
||||||
sizeof(int) * alloc_count);
|
sizeof(int) * alloc_count);
|
||||||
if (new_ids == NULL)
|
if (*ppIds == NULL)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : ENOMEM;
|
result = errno != 0 ? errno : ENOMEM;
|
||||||
logError("file: "__FILE__", line: %d, "\
|
logError("file: "__FILE__", line: %d, "\
|
||||||
|
|
@ -240,11 +237,9 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
(int)sizeof(int) * alloc_count,\
|
(int)sizeof(int) * alloc_count,\
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
free(*ppIds);
|
|
||||||
*ppIds = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*ppIds = new_ids;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=nStart; i<=nEnd; i++)
|
for (i=nStart; i<=nEnd; i++)
|
||||||
|
|
@ -449,7 +444,7 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
pItemEnd = pItemInfo + pServerArray->count;
|
pItemEnd = pItemInfo + pServerArray->count;
|
||||||
for (; pItemInfo<pItemEnd; pItemInfo++)
|
for (; pItemInfo<pItemEnd; pItemInfo++)
|
||||||
{
|
{
|
||||||
if (parseAddress(pItemInfo->value, ip_port) !=2 )
|
if (splitEx(pItemInfo->value, ':', ip_port, 2) != 2)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"\"%s\" 's value \"%s\" is invalid, "\
|
"\"%s\" 's value \"%s\" is invalid, "\
|
||||||
|
|
@ -469,13 +464,12 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(pServerInfo->ip_addr, LOCAL_LOOPBACK_IPv4) == 0 ||
|
if (strcmp(pServerInfo->ip_addr, "127.0.0.1") == 0)
|
||||||
strcmp(pServerInfo->ip_addr, LOCAL_LOOPBACK_IPv6) ==0 )
|
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"group%d: invalid hostname \"%s\", " \
|
"group%d: invalid hostname \"%s\", " \
|
||||||
"ip address can not be %s!", \
|
"ip address can not be 127.0.0.1!", \
|
||||||
__LINE__, group_id, pItemInfo->value, pServerInfo->ip_addr);
|
__LINE__, group_id, pItemInfo->value);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,16 +495,14 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
if (pGroupArray->server_count >= \
|
if (pGroupArray->server_count >= \
|
||||||
alloc_server_count)
|
alloc_server_count)
|
||||||
{
|
{
|
||||||
FDHTServerInfo *new_servers;
|
alloc_server_count = \
|
||||||
|
pGroupArray->server_count + \
|
||||||
alloc_server_count =
|
|
||||||
pGroupArray->server_count +
|
|
||||||
pGroupArray->group_count + 8;
|
pGroupArray->group_count + 8;
|
||||||
new_servers = (FDHTServerInfo *)
|
pGroupArray->servers = (FDHTServerInfo*)
|
||||||
realloc(pGroupArray->servers,
|
realloc(pGroupArray->servers, \
|
||||||
sizeof(FDHTServerInfo) *
|
sizeof(FDHTServerInfo) * \
|
||||||
alloc_server_count);
|
alloc_server_count);
|
||||||
if (new_servers == NULL)
|
if (pGroupArray->servers == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", " \
|
logError("file: "__FILE__", " \
|
||||||
"line: %d, malloc " \
|
"line: %d, malloc " \
|
||||||
|
|
@ -521,11 +513,8 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
(int)sizeof(FDHTServerInfo) \
|
(int)sizeof(FDHTServerInfo) \
|
||||||
* alloc_server_count, \
|
* alloc_server_count, \
|
||||||
errno, STRERROR(errno));
|
errno, STRERROR(errno));
|
||||||
free(pGroupArray->servers);
|
|
||||||
pGroupArray->servers = NULL;
|
|
||||||
return errno!=0 ? errno:ENOMEM;
|
return errno!=0 ? errno:ENOMEM;
|
||||||
}
|
}
|
||||||
pGroupArray->servers = new_servers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fdht_insert_sorted_servers( \
|
fdht_insert_sorted_servers( \
|
||||||
|
|
@ -585,10 +574,10 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
|
|
||||||
if (alloc_server_count > pGroupArray->server_count)
|
if (alloc_server_count > pGroupArray->server_count)
|
||||||
{
|
{
|
||||||
FDHTServerInfo *new_servers= (FDHTServerInfo*)realloc(
|
pGroupArray->servers = (FDHTServerInfo*)realloc( \
|
||||||
pGroupArray->servers, sizeof(FDHTServerInfo)
|
pGroupArray->servers, sizeof(FDHTServerInfo) \
|
||||||
* pGroupArray->server_count);
|
* pGroupArray->server_count);
|
||||||
if (new_servers == NULL)
|
if (pGroupArray->servers == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"malloc %d bytes fail, " \
|
"malloc %d bytes fail, " \
|
||||||
|
|
@ -596,11 +585,8 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
|
||||||
__LINE__, (int)sizeof(FDHTServerInfo) * \
|
__LINE__, (int)sizeof(FDHTServerInfo) * \
|
||||||
pGroupArray->server_count, \
|
pGroupArray->server_count, \
|
||||||
errno, STRERROR(errno));
|
errno, STRERROR(errno));
|
||||||
free(pGroupArray->servers);
|
|
||||||
pGroupArray->servers = NULL;
|
|
||||||
return errno != 0 ? errno : ENOMEM;
|
return errno != 0 ? errno : ENOMEM;
|
||||||
}
|
}
|
||||||
pGroupArray->servers = new_servers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&pGroupArray->proxy_server, 0, sizeof(FDHTServerInfo));
|
memset(&pGroupArray->proxy_server, 0, sizeof(FDHTServerInfo));
|
||||||
|
|
|
||||||
|
|
@ -172,17 +172,7 @@ int fdht_connect_server_nb(FDHTServerInfo *pServer, const int connect_timeout)
|
||||||
{
|
{
|
||||||
close(pServer->sock);
|
close(pServer->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过判断IP地址是IPv4或者IPv6,根据结果进行初始化
|
|
||||||
if (is_ipv6_addr(pServer->ip_addr))
|
|
||||||
{
|
|
||||||
pServer->sock = socket(AF_INET6, SOCK_STREAM, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
}
|
|
||||||
|
|
||||||
if(pServer->sock < 0)
|
if(pServer->sock < 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -223,17 +213,7 @@ int fdht_connect_server(FDHTServerInfo *pServer)
|
||||||
{
|
{
|
||||||
close(pServer->sock);
|
close(pServer->sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过判断IP地址是IPv4或者IPv6,根据结果进行初始化
|
|
||||||
if (is_ipv6_addr(pServer->ip_addr))
|
|
||||||
{
|
|
||||||
pServer->sock = socket(AF_INET6, SOCK_STREAM, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
}
|
|
||||||
|
|
||||||
if(pServer->sock < 0)
|
if(pServer->sock < 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
|
|
||||||
|
|
@ -1,335 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020 YuQing <384681@qq.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fastcommon/pthread_func.h"
|
|
||||||
#include "fastcommon/logger.h"
|
|
||||||
#include "fastcommon/fc_atomic.h"
|
|
||||||
#include "fastcommon/fast_allocator.h"
|
|
||||||
#include "file_id_hashtable.h"
|
|
||||||
|
|
||||||
typedef struct file_id_info {
|
|
||||||
string_t file_id;
|
|
||||||
uint32_t hash_code;
|
|
||||||
uint32_t expires;
|
|
||||||
struct {
|
|
||||||
struct file_id_info *htable;
|
|
||||||
struct file_id_info *list;
|
|
||||||
} nexts;
|
|
||||||
} FileIdInfo;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
FileIdInfo **buckets;
|
|
||||||
uint32_t capacity;
|
|
||||||
#if defined(DEBUG_FLAG)
|
|
||||||
volatile uint32_t count;
|
|
||||||
#endif
|
|
||||||
} FileIdHashtable;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pthread_mutex_t *locks;
|
|
||||||
int count;
|
|
||||||
} FileIdSharedLockArray;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct {
|
|
||||||
struct file_id_info *head;
|
|
||||||
struct file_id_info *tail;
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
} list;
|
|
||||||
FileIdHashtable htable;
|
|
||||||
FileIdSharedLockArray lock_array;
|
|
||||||
struct fast_mblock_man allocator; //element: FileIdInfo
|
|
||||||
struct fast_allocator_context acontext; //for string allocator
|
|
||||||
} FileIdHTableContext;
|
|
||||||
|
|
||||||
static FileIdHTableContext file_id_ctx = {
|
|
||||||
{NULL, NULL}, {NULL, 0}, {NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int clear_expired_file_id_func(void *args);
|
|
||||||
|
|
||||||
int file_id_hashtable_init()
|
|
||||||
{
|
|
||||||
const int obj_size = 0;
|
|
||||||
int result;
|
|
||||||
int bytes;
|
|
||||||
struct fast_region_info regions[2];
|
|
||||||
pthread_mutex_t *lock;
|
|
||||||
pthread_mutex_t *end;
|
|
||||||
ScheduleArray scheduleArray;
|
|
||||||
ScheduleEntry entry;
|
|
||||||
|
|
||||||
file_id_ctx.htable.capacity = 1403641;
|
|
||||||
bytes = sizeof(FileIdInfo *) * file_id_ctx.htable.capacity;
|
|
||||||
file_id_ctx.htable.buckets = fc_malloc(bytes);
|
|
||||||
if (file_id_ctx.htable.buckets == NULL) {
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
memset(file_id_ctx.htable.buckets, 0, bytes);
|
|
||||||
|
|
||||||
file_id_ctx.lock_array.count = 163;
|
|
||||||
bytes = sizeof(pthread_mutex_t) * file_id_ctx.lock_array.count;
|
|
||||||
file_id_ctx.lock_array.locks = fc_malloc(bytes);
|
|
||||||
if (file_id_ctx.lock_array.locks == NULL) {
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
end = file_id_ctx.lock_array.locks + file_id_ctx.lock_array.count;
|
|
||||||
for (lock=file_id_ctx.lock_array.locks; lock<end; lock++) {
|
|
||||||
if ((result=init_pthread_lock(lock)) != 0) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=init_pthread_lock(&file_id_ctx.list.lock)) != 0) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=fast_mblock_init_ex1(&file_id_ctx.allocator,
|
|
||||||
"file-id", sizeof(FileIdInfo), 16 * 1024,
|
|
||||||
0, NULL, NULL, true)) != 0)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FAST_ALLOCATOR_INIT_REGION(regions[0], 0, 48, 48, 16 * 1024);
|
|
||||||
FAST_ALLOCATOR_INIT_REGION(regions[1], 48, 128, 8, 8 * 1024);
|
|
||||||
if ((result=fast_allocator_init_ex(&file_id_ctx.acontext, "file-id",
|
|
||||||
obj_size, NULL, regions, 2, 0, 0.00, 0, true)) != 0)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_SCHEDULE_ENTRY(entry, FDFS_CLEAR_EXPIRED_FILE_ID_TASK_ID,
|
|
||||||
0, 0, 0, 1, clear_expired_file_id_func, NULL);
|
|
||||||
scheduleArray.count = 1;
|
|
||||||
scheduleArray.entries = &entry;
|
|
||||||
return sched_add_entries(&scheduleArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
void file_id_hashtable_destroy()
|
|
||||||
{
|
|
||||||
if (file_id_ctx.htable.buckets != NULL) {
|
|
||||||
free(file_id_ctx.htable.buckets);
|
|
||||||
file_id_ctx.htable.buckets = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_id_ctx.lock_array.locks != NULL) {
|
|
||||||
pthread_mutex_t *lock;
|
|
||||||
pthread_mutex_t *end;
|
|
||||||
|
|
||||||
end = file_id_ctx.lock_array.locks +
|
|
||||||
file_id_ctx.lock_array.count;
|
|
||||||
for (lock=file_id_ctx.lock_array.locks; lock<end; lock++) {
|
|
||||||
pthread_mutex_destroy(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(file_id_ctx.lock_array.locks);
|
|
||||||
file_id_ctx.lock_array.locks = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
fast_mblock_destroy(&file_id_ctx.allocator);
|
|
||||||
pthread_mutex_destroy(&file_id_ctx.list.lock);
|
|
||||||
fast_allocator_destroy(&file_id_ctx.acontext);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FILE_ID_HASHTABLE_DECLARE_VARS() \
|
|
||||||
uint32_t bucket_index; \
|
|
||||||
FileIdInfo **bucket; \
|
|
||||||
pthread_mutex_t *lock
|
|
||||||
|
|
||||||
#define FILE_ID_HASHTABLE_SET_BUCKET_AND_LOCK(hash_code) \
|
|
||||||
bucket_index = hash_code % file_id_ctx.htable.capacity; \
|
|
||||||
bucket = file_id_ctx.htable.buckets + bucket_index; \
|
|
||||||
lock = file_id_ctx.lock_array.locks + bucket_index % \
|
|
||||||
file_id_ctx.lock_array.count
|
|
||||||
|
|
||||||
int file_id_hashtable_add(const string_t *file_id)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
uint32_t hash_code;
|
|
||||||
FileIdInfo *current;
|
|
||||||
FileIdInfo *previous;
|
|
||||||
FileIdInfo *finfo;
|
|
||||||
FILE_ID_HASHTABLE_DECLARE_VARS();
|
|
||||||
|
|
||||||
hash_code = fc_simple_hash(file_id->str, file_id->len);
|
|
||||||
FILE_ID_HASHTABLE_SET_BUCKET_AND_LOCK(hash_code);
|
|
||||||
|
|
||||||
result = 0;
|
|
||||||
PTHREAD_MUTEX_LOCK(lock);
|
|
||||||
previous = NULL;
|
|
||||||
current = *bucket;
|
|
||||||
while (current != NULL) {
|
|
||||||
if (hash_code < current->hash_code) {
|
|
||||||
break;
|
|
||||||
} else if (hash_code == current->hash_code && fc_string_equal(
|
|
||||||
file_id, ¤t->file_id))
|
|
||||||
{
|
|
||||||
result = EEXIST;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
current = current->nexts.htable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
do {
|
|
||||||
if ((finfo=fast_mblock_alloc_object(&file_id_ctx.
|
|
||||||
allocator)) == NULL)
|
|
||||||
{
|
|
||||||
result = ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((finfo->file_id.str=fast_allocator_alloc(&file_id_ctx.
|
|
||||||
acontext, file_id->len)) == NULL)
|
|
||||||
{
|
|
||||||
fast_mblock_free_object(&file_id_ctx.allocator, finfo);
|
|
||||||
result = ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(finfo->file_id.str, file_id->str, file_id->len);
|
|
||||||
finfo->file_id.len = file_id->len;
|
|
||||||
finfo->hash_code = hash_code;
|
|
||||||
finfo->expires = g_current_time + 3;
|
|
||||||
if (previous == NULL) {
|
|
||||||
finfo->nexts.htable = *bucket;
|
|
||||||
*bucket = finfo;
|
|
||||||
} else {
|
|
||||||
finfo->nexts.htable = current;
|
|
||||||
previous->nexts.htable = finfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(DEBUG_FLAG)
|
|
||||||
FC_ATOMIC_INC(file_id_ctx.htable.count);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} while (0);
|
|
||||||
} else {
|
|
||||||
finfo = NULL;
|
|
||||||
}
|
|
||||||
PTHREAD_MUTEX_UNLOCK(lock);
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
PTHREAD_MUTEX_LOCK(&file_id_ctx.list.lock);
|
|
||||||
finfo->nexts.list = NULL;
|
|
||||||
if (file_id_ctx.list.tail == NULL) {
|
|
||||||
file_id_ctx.list.head = finfo;
|
|
||||||
} else {
|
|
||||||
file_id_ctx.list.tail->nexts.list = finfo;
|
|
||||||
}
|
|
||||||
file_id_ctx.list.tail = finfo;
|
|
||||||
PTHREAD_MUTEX_UNLOCK(&file_id_ctx.list.lock);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int file_id_hashtable_del(FileIdInfo *finfo)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
FileIdInfo *current;
|
|
||||||
FileIdInfo *previous;
|
|
||||||
FILE_ID_HASHTABLE_DECLARE_VARS();
|
|
||||||
|
|
||||||
FILE_ID_HASHTABLE_SET_BUCKET_AND_LOCK(finfo->hash_code);
|
|
||||||
PTHREAD_MUTEX_LOCK(lock);
|
|
||||||
if (*bucket == NULL) {
|
|
||||||
result = ENOENT;
|
|
||||||
} else if (finfo->hash_code == (*bucket)->hash_code &&
|
|
||||||
fc_string_equal(&finfo->file_id, &(*bucket)->file_id))
|
|
||||||
{
|
|
||||||
*bucket = (*bucket)->nexts.htable;
|
|
||||||
#if defined(DEBUG_FLAG)
|
|
||||||
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
|
||||||
#endif
|
|
||||||
result = 0;
|
|
||||||
} else {
|
|
||||||
result = ENOENT;
|
|
||||||
previous = *bucket;
|
|
||||||
while ((current=previous->nexts.htable) != NULL) {
|
|
||||||
if (finfo->hash_code < current->hash_code) {
|
|
||||||
break;
|
|
||||||
} else if (finfo->hash_code == current->hash_code &&
|
|
||||||
fc_string_equal(&finfo->file_id, ¤t->file_id))
|
|
||||||
{
|
|
||||||
previous->nexts.htable = current->nexts.htable;
|
|
||||||
#if defined(DEBUG_FLAG)
|
|
||||||
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
|
||||||
#endif
|
|
||||||
result = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PTHREAD_MUTEX_UNLOCK(lock);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int clear_expired_file_id_func(void *args)
|
|
||||||
{
|
|
||||||
struct file_id_info *head;
|
|
||||||
struct file_id_info *tail;
|
|
||||||
struct fast_mblock_chain chain;
|
|
||||||
struct fast_mblock_node *node;
|
|
||||||
|
|
||||||
head = tail = NULL;
|
|
||||||
PTHREAD_MUTEX_LOCK(&file_id_ctx.list.lock);
|
|
||||||
if (file_id_ctx.list.head != NULL && file_id_ctx.
|
|
||||||
list.head->expires < g_current_time)
|
|
||||||
{
|
|
||||||
head = tail = file_id_ctx.list.head;
|
|
||||||
file_id_ctx.list.head = file_id_ctx.list.head->nexts.list;
|
|
||||||
while (file_id_ctx.list.head != NULL && file_id_ctx.
|
|
||||||
list.head->expires < g_current_time)
|
|
||||||
{
|
|
||||||
tail = file_id_ctx.list.head;
|
|
||||||
file_id_ctx.list.head = file_id_ctx.list.head->nexts.list;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_id_ctx.list.head == NULL) {
|
|
||||||
file_id_ctx.list.tail = NULL;
|
|
||||||
} else {
|
|
||||||
tail->nexts.list = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PTHREAD_MUTEX_UNLOCK(&file_id_ctx.list.lock);
|
|
||||||
|
|
||||||
if (head == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
chain.head = chain.tail = NULL;
|
|
||||||
do {
|
|
||||||
node = fast_mblock_to_node_ptr(head);
|
|
||||||
if (chain.head == NULL) {
|
|
||||||
chain.head = node;
|
|
||||||
} else {
|
|
||||||
chain.tail->next = node;
|
|
||||||
}
|
|
||||||
chain.tail = node;
|
|
||||||
|
|
||||||
file_id_hashtable_del(head);
|
|
||||||
fast_allocator_free(&file_id_ctx.acontext, head->file_id.str);
|
|
||||||
} while ((head=head->nexts.list) != NULL);
|
|
||||||
|
|
||||||
chain.tail->next = NULL;
|
|
||||||
fast_mblock_batch_free(&file_id_ctx.allocator, &chain);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020 YuQing <384681@qq.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _FILE_ID_HASHTABLE_H
|
|
||||||
#define _FILE_ID_HASHTABLE_H
|
|
||||||
|
|
||||||
#include "storage_types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int file_id_hashtable_init();
|
|
||||||
|
|
||||||
void file_id_hashtable_destroy();
|
|
||||||
|
|
||||||
int file_id_hashtable_add(const string_t *file_id);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -250,7 +250,7 @@ int dio_discard_file(struct fast_task_info *pTask)
|
||||||
StorageFileContext *pFileContext;
|
StorageFileContext *pFileContext;
|
||||||
|
|
||||||
pFileContext = &(((StorageClientInfo *)pTask->arg)->file_context);
|
pFileContext = &(((StorageClientInfo *)pTask->arg)->file_context);
|
||||||
pFileContext->offset += pTask->recv.ptr->length - pFileContext->buff_offset;
|
pFileContext->offset += pTask->length - pFileContext->buff_offset;
|
||||||
if (pFileContext->offset >= pFileContext->end)
|
if (pFileContext->offset >= pFileContext->end)
|
||||||
{
|
{
|
||||||
pFileContext->done_callback(pTask, 0);
|
pFileContext->done_callback(pTask, 0);
|
||||||
|
|
@ -331,17 +331,17 @@ int dio_read_file(struct fast_task_info *pTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
remain_bytes = pFileContext->end - pFileContext->offset;
|
remain_bytes = pFileContext->end - pFileContext->offset;
|
||||||
capacity_bytes = pTask->send.ptr->size - pTask->send.ptr->length;
|
capacity_bytes = pTask->size - pTask->length;
|
||||||
read_bytes = (capacity_bytes < remain_bytes) ?
|
read_bytes = (capacity_bytes < remain_bytes) ? \
|
||||||
capacity_bytes : remain_bytes;
|
capacity_bytes : remain_bytes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("###before dio read bytes: %d, pTask->length=%d, file offset=%ld", \
|
logInfo("###before dio read bytes: %d, pTask->length=%d, file offset=%ld", \
|
||||||
read_bytes, pTask->send.ptr->length, pFileContext->offset);
|
read_bytes, pTask->length, pFileContext->offset);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (fc_safe_read(pFileContext->fd, pTask->send.ptr->data +
|
if (fc_safe_read(pFileContext->fd, pTask->data + pTask->length, \
|
||||||
pTask->send.ptr->length, read_bytes) != read_bytes)
|
read_bytes) != read_bytes)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : EIO;
|
result = errno != 0 ? errno : EIO;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -364,17 +364,17 @@ int dio_read_file(struct fast_task_info *pTask)
|
||||||
|
|
||||||
if (pFileContext->calc_crc32)
|
if (pFileContext->calc_crc32)
|
||||||
{
|
{
|
||||||
pFileContext->crc32 = CRC32_ex(pTask->send.ptr->data + pTask->
|
pFileContext->crc32 = CRC32_ex(pTask->data + pTask->length,
|
||||||
send.ptr->length, read_bytes, pFileContext->crc32);
|
read_bytes, pFileContext->crc32);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTask->send.ptr->length += read_bytes;
|
pTask->length += read_bytes;
|
||||||
pFileContext->offset += read_bytes;
|
pFileContext->offset += read_bytes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("###after dio read bytes: %d, pTask->length=%d, "
|
logInfo("###after dio read bytes: %d, pTask->length=%d, "
|
||||||
"file offset=%"PRId64", file size: %"PRId64, read_bytes,
|
"file offset=%"PRId64", file size: %"PRId64, read_bytes,
|
||||||
pTask->send.ptr->length, pFileContext->offset, pFileContext->end);
|
pTask->length, pFileContext->offset, pFileContext->end);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pFileContext->offset < pFileContext->end)
|
if (pFileContext->offset < pFileContext->end)
|
||||||
|
|
@ -441,8 +441,8 @@ int dio_write_file(struct fast_task_info *pTask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pDataBuff = pTask->recv.ptr->data + pFileContext->buff_offset;
|
pDataBuff = pTask->data + pFileContext->buff_offset;
|
||||||
write_bytes = pTask->recv.ptr->length - pFileContext->buff_offset;
|
write_bytes = pTask->length - pFileContext->buff_offset;
|
||||||
if (fc_safe_write(pFileContext->fd, pDataBuff, write_bytes) != write_bytes)
|
if (fc_safe_write(pFileContext->fd, pDataBuff, write_bytes) != write_bytes)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : EIO;
|
result = errno != 0 ? errno : EIO;
|
||||||
|
|
@ -486,9 +486,9 @@ int dio_write_file(struct fast_task_info *pTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("###dio fd: %d, write bytes: %d, task length: %d, "
|
logInfo("###dio fd: %d, write bytes: %d, pTask->length=%d, "
|
||||||
"buff_offset: %d", pFileContext->fd, write_bytes,
|
"buff_offset=%d", pFileContext->fd, write_bytes,
|
||||||
pTask->recv.ptr->length, pFileContext->buff_offset);
|
pTask->length, pFileContext->buff_offset);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pFileContext->offset += write_bytes;
|
pFileContext->offset += write_bytes;
|
||||||
|
|
@ -761,12 +761,9 @@ static void *dio_thread_entrance(void* arg)
|
||||||
while (SF_G_CONTINUE_FLAG)
|
while (SF_G_CONTINUE_FLAG)
|
||||||
{
|
{
|
||||||
while ((pTask=blocked_queue_pop(&(pContext->queue))) != NULL)
|
while ((pTask=blocked_queue_pop(&(pContext->queue))) != NULL)
|
||||||
{
|
|
||||||
if (!FC_ATOMIC_GET(pTask->canceled))
|
|
||||||
{
|
{
|
||||||
((StorageClientInfo *)pTask->arg)->deal_func(pTask);
|
((StorageClientInfo *)pTask->arg)->deal_func(pTask);
|
||||||
}
|
storage_release_task(pTask);
|
||||||
sf_release_task(pTask);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,6 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 1];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 1];
|
||||||
char full_binlog_filename[MAX_PATH_SIZE];
|
char full_binlog_filename[MAX_PATH_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char *pBasePath;
|
char *pBasePath;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -143,11 +142,10 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
||||||
if((result=tcpsenddata_nb(pSrcStorage->sock, out_buff,
|
if((result=tcpsenddata_nb(pSrcStorage->sock, out_buff,
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"storage server %s:%u, send data fail, "
|
"storage server %s:%u, send data fail, "
|
||||||
"errno: %d, error info: %s.", __LINE__,
|
"errno: %d, error info: %s.",
|
||||||
formatted_ip, pSrcStorage->port,
|
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -172,19 +170,17 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
||||||
if ((result=tcprecvfile(pSrcStorage->sock, full_binlog_filename,
|
if ((result=tcprecvfile(pSrcStorage->sock, full_binlog_filename,
|
||||||
in_bytes, 0, network_timeout, &file_bytes)) != 0)
|
in_bytes, 0, network_timeout, &file_bytes)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"storage server %s:%u, tcprecvfile fail, "
|
"storage server %s:%u, tcprecvfile fail, "
|
||||||
"errno: %d, error info: %s.", __LINE__,
|
"errno: %d, error info: %s.",
|
||||||
formatted_ip, pSrcStorage->port,
|
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"recovery binlog from %s:%u, file size: %"PRId64, __LINE__,
|
"recovery binlog from %s:%u, file size: %"PRId64, __LINE__,
|
||||||
formatted_ip, pSrcStorage->port, file_bytes);
|
pSrcStorage->ip_addr, pSrcStorage->port, file_bytes);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +196,6 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
FDFSGroupStat groupStat;
|
FDFSGroupStat groupStat;
|
||||||
FDFSStorageInfo storageStats[FDFS_MAX_SERVERS_EACH_GROUP];
|
FDFSStorageInfo storageStats[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||||
FDFSStorageInfo *pStorageStat;
|
FDFSStorageInfo *pStorageStat;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
memset(pSrcStorage, 0, sizeof(ConnectionInfo));
|
memset(pSrcStorage, 0, sizeof(ConnectionInfo));
|
||||||
|
|
@ -361,12 +356,9 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
return EINTR;
|
return EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"disk recovery: get source storage server %s:%u",
|
"disk recovery: get source storage server %s:%u",
|
||||||
__LINE__, formatted_ip, pSrcStorage->port);
|
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -729,7 +721,6 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
||||||
bool bContinueFlag;
|
bool bContinueFlag;
|
||||||
char local_filename[MAX_PATH_SIZE];
|
char local_filename[MAX_PATH_SIZE];
|
||||||
char src_filename[MAX_PATH_SIZE];
|
char src_filename[MAX_PATH_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
pTrackerServer = tracker_get_connection_r(&trackerServer, &result);
|
pTrackerServer = tracker_get_connection_r(&trackerServer, &result);
|
||||||
if (pTrackerServer == NULL)
|
if (pTrackerServer == NULL)
|
||||||
|
|
@ -746,11 +737,10 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
||||||
noent_count = 0;
|
noent_count = 0;
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"disk recovery thread #%d, src storage server %s:%u, "
|
"disk recovery thread #%d, src storage server %s:%u, "
|
||||||
"recovering files of data path: %s ...", __LINE__,
|
"recovering files of data path: %s ...", __LINE__,
|
||||||
pThreadData->thread_index, formatted_ip,
|
pThreadData->thread_index, pSrcStorage->ip_addr,
|
||||||
pSrcStorage->port, pThreadData->base_path);
|
pSrcStorage->port, pThreadData->base_path);
|
||||||
|
|
||||||
bContinueFlag = true;
|
bContinueFlag = true;
|
||||||
|
|
@ -934,11 +924,10 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
||||||
|
|
||||||
if (pThreadData->done)
|
if (pThreadData->done)
|
||||||
{
|
{
|
||||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"disk recovery thread #%d, src storage server %s:%u, "
|
"disk recovery thread #%d, src storage server %s:%u, "
|
||||||
"recover files of data path: %s done", __LINE__,
|
"recover files of data path: %s done", __LINE__,
|
||||||
pThreadData->thread_index, formatted_ip,
|
pThreadData->thread_index, pSrcStorage->ip_addr,
|
||||||
pSrcStorage->port, pThreadData->base_path);
|
pSrcStorage->port, pThreadData->base_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1711,11 +1700,10 @@ static int storage_disk_recovery_split_trunk_binlog(const int store_path_index)
|
||||||
|
|
||||||
int storage_disk_recovery_prepare(const int store_path_index)
|
int storage_disk_recovery_prepare(const int store_path_index)
|
||||||
{
|
{
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
ConnectionInfo srcStorage;
|
ConnectionInfo srcStorage;
|
||||||
ConnectionInfo *pStorageConn;
|
ConnectionInfo *pStorageConn;
|
||||||
char *pBasePath;
|
|
||||||
int result;
|
int result;
|
||||||
|
char *pBasePath;
|
||||||
|
|
||||||
pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
|
pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
|
||||||
if ((result=recovery_init_flag_file(pBasePath, false, -1)) != 0)
|
if ((result=recovery_init_flag_file(pBasePath, false, -1)) != 0)
|
||||||
|
|
@ -1760,10 +1748,9 @@ int storage_disk_recovery_prepare(const int store_path_index)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(pStorageConn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"try to fetch binlog from %s:%u ...", __LINE__,
|
"try to fetch binlog from %s:%u ...", __LINE__,
|
||||||
formatted_ip, pStorageConn->port);
|
pStorageConn->ip_addr, pStorageConn->port);
|
||||||
|
|
||||||
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
||||||
tracker_close_connection_ex(pStorageConn, true);
|
tracker_close_connection_ex(pStorageConn, true);
|
||||||
|
|
@ -1772,10 +1759,9 @@ int storage_disk_recovery_prepare(const int store_path_index)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(pStorageConn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"fetch binlog from %s:%u successfully.", __LINE__,
|
"fetch binlog from %s:%u successfully.", __LINE__,
|
||||||
formatted_ip, pStorageConn->port);
|
pStorageConn->ip_addr, pStorageConn->port);
|
||||||
|
|
||||||
if ((result=storage_disk_recovery_split_trunk_binlog(
|
if ((result=storage_disk_recovery_split_trunk_binlog(
|
||||||
store_path_index)) != 0)
|
store_path_index)) != 0)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
char reserved_space_str[32];
|
char reserved_space_str[32];
|
||||||
char tracker_client_ip_str[256];
|
char tracker_client_ip_str[256];
|
||||||
char last_storage_ip_str[256];
|
char last_storage_ip_str[256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
int total_len;
|
int total_len;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -41,7 +40,6 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
tracker_client_ip_str, sizeof(tracker_client_ip_str));
|
tracker_client_ip_str, sizeof(tracker_client_ip_str));
|
||||||
fdfs_multi_ips_to_string(&g_last_storage_ip,
|
fdfs_multi_ips_to_string(&g_last_storage_ip,
|
||||||
last_storage_ip_str, sizeof(last_storage_ip_str));
|
last_storage_ip_str, sizeof(last_storage_ip_str));
|
||||||
format_ip_address(g_trunk_server.connections[0].ip_addr, formatted_ip);
|
|
||||||
|
|
||||||
total_len = snprintf(buff, buffSize,
|
total_len = snprintf(buff, buffSize,
|
||||||
"SF_G_CONNECT_TIMEOUT=%ds\n"
|
"SF_G_CONNECT_TIMEOUT=%ds\n"
|
||||||
|
|
@ -51,7 +49,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
"SF_G_CONTINUE_FLAG=%d\n"
|
"SF_G_CONTINUE_FLAG=%d\n"
|
||||||
"g_schedule_flag=%d\n"
|
"g_schedule_flag=%d\n"
|
||||||
"SF_G_INNER_PORT=%d\n"
|
"SF_G_INNER_PORT=%d\n"
|
||||||
"SF_G_MAX_CONNECTIONS=%d\n"
|
"g_max_connections=%d\n"
|
||||||
"g_storage_thread_count=%d\n"
|
"g_storage_thread_count=%d\n"
|
||||||
"g_group_name=%s\n"
|
"g_group_name=%s\n"
|
||||||
"g_subdir_count_per_path=%d\n"
|
"g_subdir_count_per_path=%d\n"
|
||||||
|
|
@ -95,8 +93,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
"g_check_file_duplicate=%d\n"
|
"g_check_file_duplicate=%d\n"
|
||||||
"g_key_namespace=%s\n"
|
"g_key_namespace=%s\n"
|
||||||
"g_namespace_len=%d\n"
|
"g_namespace_len=%d\n"
|
||||||
"bind_addr_ipv4=%s\n"
|
"SF_G_INNER_BIND_ADDR=%s\n"
|
||||||
"bind_addr_ipv6=%s\n"
|
|
||||||
"g_client_bind_addr=%d\n"
|
"g_client_bind_addr=%d\n"
|
||||||
"g_storage_ip_changed_auto_adjust=%d\n"
|
"g_storage_ip_changed_auto_adjust=%d\n"
|
||||||
"g_thread_kill_done=%d\n"
|
"g_thread_kill_done=%d\n"
|
||||||
|
|
@ -145,7 +142,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, g_fdfs_version.patch, SF_G_CONTINUE_FLAG
|
, g_fdfs_version.patch, SF_G_CONTINUE_FLAG
|
||||||
, g_schedule_flag
|
, g_schedule_flag
|
||||||
, SF_G_INNER_PORT
|
, SF_G_INNER_PORT
|
||||||
, SF_G_MAX_CONNECTIONS
|
, g_sf_global_vars.max_connections
|
||||||
, SF_G_ALIVE_THREAD_COUNT
|
, SF_G_ALIVE_THREAD_COUNT
|
||||||
, g_group_name
|
, g_group_name
|
||||||
, g_subdir_count_per_path
|
, g_subdir_count_per_path
|
||||||
|
|
@ -153,8 +150,8 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, g_last_server_port
|
, g_last_server_port
|
||||||
, g_last_http_port
|
, g_last_http_port
|
||||||
, g_allow_ip_count
|
, g_allow_ip_count
|
||||||
, g_sf_global_vars.run_by.group
|
, g_sf_global_vars.run_by_group
|
||||||
, g_sf_global_vars.run_by.user
|
, g_sf_global_vars.run_by_user
|
||||||
, g_http_domain
|
, g_http_domain
|
||||||
, g_file_distribute_path_mode
|
, g_file_distribute_path_mode
|
||||||
, g_file_distribute_rotate_count
|
, g_file_distribute_rotate_count
|
||||||
|
|
@ -191,8 +188,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, g_check_file_duplicate
|
, g_check_file_duplicate
|
||||||
, g_key_namespace
|
, g_key_namespace
|
||||||
, g_namespace_len
|
, g_namespace_len
|
||||||
, SF_G_INNER_BIND_ADDR4
|
, SF_G_INNER_BIND_ADDR
|
||||||
, SF_G_INNER_BIND_ADDR6
|
|
||||||
, g_client_bind_addr
|
, g_client_bind_addr
|
||||||
, g_storage_ip_changed_auto_adjust
|
, g_storage_ip_changed_auto_adjust
|
||||||
, g_thread_kill_done
|
, g_thread_kill_done
|
||||||
|
|
@ -210,18 +206,18 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, g_slot_min_size
|
, g_slot_min_size
|
||||||
, g_trunk_file_size
|
, g_trunk_file_size
|
||||||
, g_store_path_mode
|
, g_store_path_mode
|
||||||
, fdfs_storage_reserved_space_to_string(
|
, fdfs_storage_reserved_space_to_string( \
|
||||||
&g_storage_reserved_space, reserved_space_str)
|
&g_storage_reserved_space, reserved_space_str) \
|
||||||
, g_avg_storage_reserved_mb
|
, g_avg_storage_reserved_mb
|
||||||
, g_store_path_index
|
, g_store_path_index
|
||||||
, g_current_trunk_file_id
|
, g_current_trunk_file_id
|
||||||
, g_trunk_sync_thread_count
|
, g_trunk_sync_thread_count
|
||||||
, formatted_ip
|
, g_trunk_server.connections[0].ip_addr
|
||||||
, g_trunk_server.connections[0].port
|
, g_trunk_server.connections[0].port
|
||||||
, g_trunk_total_free_space
|
, g_trunk_total_free_space
|
||||||
, g_use_connection_pool
|
, g_use_connection_pool
|
||||||
, g_connection_pool_max_idle_time
|
, g_connection_pool_max_idle_time
|
||||||
, g_use_connection_pool ? conn_pool_get_connection_count(
|
, g_use_connection_pool ? conn_pool_get_connection_count( \
|
||||||
&g_connection_pool) : 0
|
&g_connection_pool) : 0
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
, g_http_params.disabled
|
, g_http_params.disabled
|
||||||
|
|
@ -274,7 +270,6 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
||||||
int total_len;
|
int total_len;
|
||||||
TrackerServerInfo *pTrackerServer;
|
TrackerServerInfo *pTrackerServer;
|
||||||
TrackerServerInfo *pTrackerEnd;
|
TrackerServerInfo *pTrackerEnd;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
total_len = snprintf(buff, buffSize, \
|
total_len = snprintf(buff, buffSize, \
|
||||||
"\ng_tracker_group.server_count=%d, " \
|
"\ng_tracker_group.server_count=%d, " \
|
||||||
|
|
@ -290,12 +285,11 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
||||||
for (pTrackerServer=g_tracker_group.servers; \
|
for (pTrackerServer=g_tracker_group.servers; \
|
||||||
pTrackerServer<pTrackerEnd; pTrackerServer++)
|
pTrackerServer<pTrackerEnd; pTrackerServer++)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->connections[0].
|
|
||||||
ip_addr, formatted_ip);
|
|
||||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||||
"\t%d. tracker server=%s:%u\n",
|
"\t%d. tracker server=%s:%u\n",
|
||||||
(int)(pTrackerServer - g_tracker_group.servers) + 1,
|
(int)(pTrackerServer - g_tracker_group.servers) + 1,
|
||||||
formatted_ip, pTrackerServer->connections[0].port);
|
pTrackerServer->connections[0].ip_addr,
|
||||||
|
pTrackerServer->connections[0].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_len;
|
return total_len;
|
||||||
|
|
@ -371,9 +365,9 @@ static int fdfs_dump_storage_stat(char *buff, const int buffSize)
|
||||||
"last_synced_timestamp=%s\n"
|
"last_synced_timestamp=%s\n"
|
||||||
"last_heart_beat_time=%s\n",
|
"last_heart_beat_time=%s\n",
|
||||||
g_stat_change_count, g_sync_change_count,
|
g_stat_change_count, g_sync_change_count,
|
||||||
free_queue_alloc_connections(&g_sf_context.free_queue),
|
free_queue_alloc_connections(),
|
||||||
SF_G_CONN_CURRENT_COUNT,
|
g_storage_stat.connection.current_count,
|
||||||
SF_G_CONN_MAX_COUNT,
|
g_storage_stat.connection.max_count,
|
||||||
g_storage_stat.total_upload_count,
|
g_storage_stat.total_upload_count,
|
||||||
g_storage_stat.success_upload_count,
|
g_storage_stat.success_upload_count,
|
||||||
g_storage_stat.total_set_meta_count,
|
g_storage_stat.total_set_meta_count,
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,6 @@ static int storage_check_and_make_data_dirs();
|
||||||
static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + 4];
|
char out_buff[sizeof(TrackerHeader) + 4];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -155,11 +154,12 @@ static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
||||||
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, send data fail, " \
|
||||||
"tracker server %s:%u, send data fail, errno: %d, "
|
"errno: %d, error info: %s.", \
|
||||||
"error info: %s.", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,11 +175,11 @@ static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
||||||
|
|
||||||
if (in_bytes != FDFS_GROUP_NAME_MAX_LEN)
|
if (in_bytes != FDFS_GROUP_NAME_MAX_LEN)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, recv body length: " \
|
||||||
"tracker server %s:%u, recv body length: %"PRId64" != %d",
|
"%"PRId64" != %d", \
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
pTrackerServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,55 +219,19 @@ static int storage_get_group_name_from_tracker()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_my_server_id_by_local_ip()
|
static int tracker_get_my_server_id()
|
||||||
{
|
{
|
||||||
FDFSStorageIdInfo *idInfo;
|
struct in_addr ip_addr;
|
||||||
const char *ip_addr;
|
|
||||||
|
|
||||||
ip_addr = get_first_local_ip();
|
|
||||||
while (ip_addr != NULL) {
|
|
||||||
if ((idInfo=fdfs_get_storage_id_by_ip(g_group_name,
|
|
||||||
ip_addr)) != NULL)
|
|
||||||
{
|
|
||||||
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str),
|
|
||||||
"%s", idInfo->id);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_addr = get_next_local_ip(ip_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"can't find my server id by local ip address, "
|
|
||||||
"local ip count: %d", __LINE__, g_local_host_ip_count);
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tracker_get_my_server_id(const char *conf_filename,
|
|
||||||
const char *server_id_in_conf)
|
|
||||||
{
|
|
||||||
struct in_addr ipv4_addr;
|
|
||||||
struct in6_addr ipv6_addr;
|
|
||||||
char ip_str[256];
|
char ip_str[256];
|
||||||
bool flag = false;
|
|
||||||
|
|
||||||
if (inet_pton(AF_INET, g_tracker_client_ip.ips[0].
|
if (inet_pton(AF_INET, g_tracker_client_ip.ips[0].address, &ip_addr) == 1)
|
||||||
address, &ipv4_addr) == 1)
|
|
||||||
{
|
{
|
||||||
g_server_id_in_filename = ipv4_addr.s_addr;
|
g_server_id_in_filename = ip_addr.s_addr;
|
||||||
flag = true;
|
|
||||||
}
|
}
|
||||||
else if (inet_pton(AF_INET6, g_tracker_client_ip.ips[0].
|
else
|
||||||
address, &ipv6_addr) == 1)
|
|
||||||
{
|
{
|
||||||
g_server_id_in_filename = *((in_addr_64_t *)((char *)&ipv6_addr + 8));
|
logError("file: "__FILE__", line: %d, " \
|
||||||
flag = true;
|
"call inet_pton for ip: %s fail", \
|
||||||
}
|
|
||||||
|
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
logWarning("file: "__FILE__", line: %d, "
|
|
||||||
"call inet_pton for ip: %s fail",
|
|
||||||
__LINE__, g_tracker_client_ip.ips[0].address);
|
__LINE__, g_tracker_client_ip.ips[0].address);
|
||||||
g_server_id_in_filename = INADDR_NONE;
|
g_server_id_in_filename = INADDR_NONE;
|
||||||
}
|
}
|
||||||
|
|
@ -277,24 +241,6 @@ static int tracker_get_my_server_id(const char *conf_filename,
|
||||||
ConnectionInfo *pTrackerServer;
|
ConnectionInfo *pTrackerServer;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (g_trust_storage_server_id) {
|
|
||||||
if (server_id_in_conf == NULL) {
|
|
||||||
if ((result=get_my_server_id_by_local_ip()) != 0) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} else if (*server_id_in_conf != '\0') {
|
|
||||||
if (!fdfs_is_server_id_valid(server_id_in_conf)) {
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"config file: %s, server_id: %s is invalid",
|
|
||||||
__LINE__, conf_filename, server_id_in_conf);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str),
|
|
||||||
"%s", server_id_in_conf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*g_my_server_id_str == '\0') {
|
|
||||||
pTrackerServer = tracker_get_connection();
|
pTrackerServer = tracker_get_connection();
|
||||||
if (pTrackerServer == NULL)
|
if (pTrackerServer == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -308,7 +254,6 @@ static int tracker_get_my_server_id(const char *conf_filename,
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID)
|
if (g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID)
|
||||||
|
|
@ -317,25 +262,16 @@ static int tracker_get_my_server_id(const char *conf_filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// 当IP地址为IPv6时,其storage_id值为IP地址的short code
|
|
||||||
if (is_ipv6_addr(g_tracker_client_ip.ips[0].address))
|
|
||||||
{
|
|
||||||
fdfs_ip_to_shortcode(g_tracker_client_ip.ips[0].address,
|
|
||||||
g_my_server_id_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str), "%s",
|
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str), "%s",
|
||||||
g_tracker_client_ip.ips[0].address);
|
g_tracker_client_ip.ips[0].address);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
||||||
ip_str, sizeof(ip_str));
|
ip_str, sizeof(ip_str));
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"tracker_client_ip: %s, my_server_id_str: %s, "
|
"tracker_client_ip: %s, my_server_id_str: %s, "
|
||||||
"g_server_id_in_filename: %"PRIu64, __LINE__,
|
"g_server_id_in_filename: %d", __LINE__,
|
||||||
ip_str, g_my_server_id_str, g_server_id_in_filename);
|
ip_str, g_my_server_id_str, g_server_id_in_filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1410,7 +1346,6 @@ static int storage_check_tracker_ipaddr(const char *filename)
|
||||||
TrackerServerInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo *conn_end;
|
ConnectionInfo *conn_end;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
pEnd = g_tracker_group.servers + g_tracker_group.server_count;
|
pEnd = g_tracker_group.servers + g_tracker_group.server_count;
|
||||||
for (pServer=g_tracker_group.servers; pServer<pEnd; pServer++)
|
for (pServer=g_tracker_group.servers; pServer<pEnd; pServer++)
|
||||||
|
|
@ -1418,13 +1353,13 @@ static int storage_check_tracker_ipaddr(const char *filename)
|
||||||
conn_end = pServer->connections + pServer->count;
|
conn_end = pServer->connections + pServer->count;
|
||||||
for (conn=pServer->connections; conn<conn_end; conn++)
|
for (conn=pServer->connections; conn<conn_end; conn++)
|
||||||
{
|
{
|
||||||
if (is_loopback_ip(conn->ip_addr))
|
//logInfo("server=%s:%u\n", conn->ip_addr, conn->port);
|
||||||
|
if (strcmp(conn->ip_addr, "127.0.0.1") == 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"conf file \"%s\", tracker: \"%s:%u\" is invalid, "
|
"conf file \"%s\", tracker: \"%s:%u\" is invalid, "
|
||||||
"tracker server ip can't be loopback address",
|
"tracker server ip can't be 127.0.0.1",
|
||||||
__LINE__, filename, formatted_ip, conn->port);
|
__LINE__, filename, conn->ip_addr, conn->port);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1468,7 +1403,6 @@ static int init_my_result_per_tracker()
|
||||||
|
|
||||||
int storage_func_init(const char *filename)
|
int storage_func_init(const char *filename)
|
||||||
{
|
{
|
||||||
const int fixed_buffer_size = 0;
|
|
||||||
const int task_buffer_extra_size = 0;
|
const int task_buffer_extra_size = 0;
|
||||||
const bool need_set_run_by = false;
|
const bool need_set_run_by = false;
|
||||||
char *pGroupName;
|
char *pGroupName;
|
||||||
|
|
@ -1476,7 +1410,6 @@ int storage_func_init(const char *filename)
|
||||||
char *pIfAliasPrefix;
|
char *pIfAliasPrefix;
|
||||||
char *pHttpDomain;
|
char *pHttpDomain;
|
||||||
char *pRotateAccessLogSize;
|
char *pRotateAccessLogSize;
|
||||||
char *server_id_in_conf;
|
|
||||||
IniContext iniContext;
|
IniContext iniContext;
|
||||||
SFContextIniConfig config;
|
SFContextIniConfig config;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -1506,11 +1439,11 @@ int storage_func_init(const char *filename)
|
||||||
|
|
||||||
sf_set_current_time();
|
sf_set_current_time();
|
||||||
|
|
||||||
SF_SET_CONTEXT_INI_CONFIG_EX(config, fc_comm_type_sock, filename,
|
SF_SET_CONTEXT_INI_CONFIG_EX(config, filename, &iniContext,
|
||||||
&iniContext, NULL, FDFS_STORAGE_SERVER_DEF_PORT,
|
NULL, FDFS_STORAGE_SERVER_DEF_PORT,
|
||||||
FDFS_STORAGE_SERVER_DEF_PORT, DEFAULT_WORK_THREADS,
|
FDFS_STORAGE_SERVER_DEF_PORT, DEFAULT_WORK_THREADS,
|
||||||
"buff_size", 0);
|
"buff_size");
|
||||||
if ((result=sf_load_config_ex("storaged", &config, fixed_buffer_size,
|
if ((result=sf_load_config_ex("storaged", &config,
|
||||||
task_buffer_extra_size, need_set_run_by)) != 0)
|
task_buffer_extra_size, need_set_run_by)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1669,12 +1602,12 @@ int storage_func_init(const char *filename)
|
||||||
(g_sync_end_time.hour == 23 && \
|
(g_sync_end_time.hour == 23 && \
|
||||||
g_sync_end_time.minute == 59));
|
g_sync_end_time.minute == 59));
|
||||||
|
|
||||||
if (g_sf_global_vars.net_buffer_cfg.min_buff_size <
|
if (g_sf_global_vars.min_buff_size < sizeof(TrackerHeader) +
|
||||||
sizeof(TrackerHeader) + TRUNK_BINLOG_BUFFER_SIZE)
|
TRUNK_BINLOG_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"item \"buff_size\" is too small, value: %d < %d!",
|
"item \"buff_size\" is too small, value: %d < %d!",
|
||||||
__LINE__, g_sf_global_vars.net_buffer_cfg.min_buff_size,
|
__LINE__, g_sf_global_vars.min_buff_size,
|
||||||
(int)sizeof(TrackerHeader) + TRUNK_BINLOG_BUFFER_SIZE);
|
(int)sizeof(TrackerHeader) + TRUNK_BINLOG_BUFFER_SIZE);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1995,9 +1928,6 @@ int storage_func_init(const char *filename)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_id_in_conf = iniGetStrValue(NULL,
|
|
||||||
"server_id", &iniContext);
|
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
{
|
{
|
||||||
char *pHttpTrunkSize;
|
char *pHttpTrunkSize;
|
||||||
|
|
@ -2146,16 +2076,7 @@ int storage_func_init(const char *filename)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_use_storage_id)
|
if ((result=tracker_get_my_server_id()) != 0)
|
||||||
{
|
|
||||||
if ((result=fdfs_get_storage_ids_from_tracker_group(
|
|
||||||
&g_tracker_group)) != 0)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=tracker_get_my_server_id(filename, server_id_in_conf)) != 0)
|
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
"get my server id from tracker server fail, " \
|
"get my server id from tracker server fail, " \
|
||||||
|
|
@ -2164,6 +2085,15 @@ int storage_func_init(const char *filename)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_use_storage_id)
|
||||||
|
{
|
||||||
|
if ((result=fdfs_get_storage_ids_from_tracker_group( \
|
||||||
|
&g_tracker_group)) != 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((result=storage_check_ip_changed()) != 0)
|
if ((result=storage_check_ip_changed()) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2257,7 +2187,6 @@ static int storage_get_my_ip_from_tracker(ConnectionInfo *conn,
|
||||||
char *ip_addrs, const int buff_size)
|
char *ip_addrs, const int buff_size)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -2271,21 +2200,21 @@ static int storage_get_my_ip_from_tracker(ConnectionInfo *conn,
|
||||||
if((result=tcpsenddata_nb(conn->sock, out_buff,
|
if((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, send data fail, errno: %d, "
|
"tracker server %s:%u, send data fail, "
|
||||||
"error info: %s.", __LINE__, formatted_ip,
|
"errno: %d, error info: %s.",
|
||||||
conn->port, result, STRERROR(result));
|
__LINE__, conn->ip_addr, conn->port,
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=fdfs_recv_response(conn, &ip_addrs,
|
if ((result=fdfs_recv_response(conn, &ip_addrs,
|
||||||
buff_size - 1, &in_bytes)) != 0)
|
buff_size - 1, &in_bytes)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, recv response fail, errno: %d, "
|
"tracker server %s:%u, recv response fail, "
|
||||||
"error info: %s.", __LINE__, formatted_ip, conn->port,
|
"errno: %d, error info: %s.",
|
||||||
|
__LINE__, conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -2299,7 +2228,6 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
||||||
{
|
{
|
||||||
char my_ip_addrs[256];
|
char my_ip_addrs[256];
|
||||||
char error_info[256];
|
char error_info[256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
FDFSMultiIP multi_ip;
|
FDFSMultiIP multi_ip;
|
||||||
int result;
|
int result;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -2330,12 +2258,13 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
||||||
if ((result=fdfs_check_and_format_ips(&g_tracker_client_ip,
|
if ((result=fdfs_check_and_format_ips(&g_tracker_client_ip,
|
||||||
error_info, sizeof(error_info))) != 0)
|
error_info, sizeof(error_info))) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logCrit("file: "__FILE__", line: %d, "
|
logCrit("file: "__FILE__", line: %d, "
|
||||||
"as a client of tracker server %s:%u, "
|
"as a client of tracker server %s:%u, "
|
||||||
"my ip: %s not valid, error info: %s. "
|
"my ip: %s not valid, error info: %s. "
|
||||||
"program exit!", __LINE__, formatted_ip,
|
"program exit!", __LINE__,
|
||||||
conn->port, multi_ip.ips[i].address, error_info);
|
conn->ip_addr, conn->port,
|
||||||
|
multi_ip.ips[i].address, error_info);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2347,12 +2276,11 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
||||||
|
|
||||||
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
||||||
ip_str, sizeof(ip_str));
|
ip_str, sizeof(ip_str));
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"as a client of tracker server %s:%u, "
|
"as a client of tracker server %s:%u, "
|
||||||
"my ip: %s not consistent with client ips: %s "
|
"my ip: %s not consistent with client ips: %s "
|
||||||
"of other tracker client. program exit!",
|
"of other tracker client. program exit!", __LINE__,
|
||||||
__LINE__, formatted_ip, conn->port,
|
conn->ip_addr, conn->port,
|
||||||
multi_ip.ips[i].address, ip_str);
|
multi_ip.ips[i].address, ip_str);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,11 @@ FDFSMultiIP g_last_storage_ip = {0, 0}; //the last storage ip address
|
||||||
|
|
||||||
LogContext g_access_log_context = {LOG_INFO, STDERR_FILENO, NULL};
|
LogContext g_access_log_context = {LOG_INFO, STDERR_FILENO, NULL};
|
||||||
|
|
||||||
in_addr_64_t g_server_id_in_filename = 0;
|
in_addr_t g_server_id_in_filename = 0;
|
||||||
bool g_use_access_log = false; //if log to access log
|
bool g_use_access_log = false; //if log to access log
|
||||||
bool g_rotate_access_log = false; //if rotate the access log every day
|
bool g_rotate_access_log = false; //if rotate the access log every day
|
||||||
bool g_compress_old_access_log = false; //if compress the old access log
|
bool g_compress_old_access_log = false; //if compress the old access log
|
||||||
bool g_use_storage_id = false; //identify storage by ID instead of IP address
|
bool g_use_storage_id = false; //identify storage by ID instead of IP address
|
||||||
bool g_trust_storage_server_id = false;
|
|
||||||
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
|
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
|
||||||
bool g_store_slave_file_use_link = false; //if store slave file use symbol link
|
bool g_store_slave_file_use_link = false; //if store slave file use symbol link
|
||||||
|
|
||||||
|
|
@ -83,7 +82,7 @@ byte g_file_signature_method = STORAGE_FILE_SIGNATURE_METHOD_HASH;
|
||||||
char g_key_namespace[FDHT_MAX_NAMESPACE_LEN+1] = {0};
|
char g_key_namespace[FDHT_MAX_NAMESPACE_LEN+1] = {0};
|
||||||
int g_namespace_len = 0;
|
int g_namespace_len = 0;
|
||||||
int g_allow_ip_count = 0;
|
int g_allow_ip_count = 0;
|
||||||
in_addr_64_t *g_allow_ip_addrs = NULL;
|
in_addr_t *g_allow_ip_addrs = NULL;
|
||||||
StorageStatusPerTracker *g_my_report_status = NULL; //returned by tracker server
|
StorageStatusPerTracker *g_my_report_status = NULL; //returned by tracker server
|
||||||
|
|
||||||
TimeInfo g_access_log_rotate_time = {0, 0}; //rotate access log time base
|
TimeInfo g_access_log_rotate_time = {0, 0}; //rotate access log time base
|
||||||
|
|
|
||||||
|
|
@ -100,10 +100,9 @@ extern FDFSMultiIP g_last_storage_ip; //the last storage ip address
|
||||||
|
|
||||||
extern LogContext g_access_log_context;
|
extern LogContext g_access_log_context;
|
||||||
|
|
||||||
extern in_addr_64_t g_server_id_in_filename;
|
extern in_addr_t g_server_id_in_filename;
|
||||||
extern bool g_store_slave_file_use_link; //if store slave file use symbol link
|
extern bool g_store_slave_file_use_link; //if store slave file use symbol link
|
||||||
extern bool g_use_storage_id; //identify storage by ID instead of IP address
|
extern bool g_use_storage_id; //identify storage by ID instead of IP address
|
||||||
extern bool g_trust_storage_server_id;
|
|
||||||
extern byte g_id_type_in_filename; //id type of the storage server in the filename
|
extern byte g_id_type_in_filename; //id type of the storage server in the filename
|
||||||
extern bool g_use_access_log; //if log to access log
|
extern bool g_use_access_log; //if log to access log
|
||||||
extern bool g_rotate_access_log; //if rotate the access log every day
|
extern bool g_rotate_access_log; //if rotate the access log every day
|
||||||
|
|
@ -117,7 +116,7 @@ extern char g_key_namespace[FDHT_MAX_NAMESPACE_LEN+1];
|
||||||
extern int g_namespace_len;
|
extern int g_namespace_len;
|
||||||
|
|
||||||
extern int g_allow_ip_count; /* -1 means match any ip address */
|
extern int g_allow_ip_count; /* -1 means match any ip address */
|
||||||
extern in_addr_64_t *g_allow_ip_addrs; /* sorted array, asc order */
|
extern in_addr_t *g_allow_ip_addrs; /* sorted array, asc order */
|
||||||
|
|
||||||
extern StorageStatusPerTracker *g_my_report_status; //returned by tracker server
|
extern StorageStatusPerTracker *g_my_report_status; //returned by tracker server
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ static int storage_do_changelog_req(ConnectionInfo *pTrackerServer)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE];
|
FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
|
@ -45,14 +44,15 @@ static int storage_do_changelog_req(ConnectionInfo *pTrackerServer)
|
||||||
strcpy(out_buff + sizeof(TrackerHeader), g_group_name);
|
strcpy(out_buff + sizeof(TrackerHeader), g_group_name);
|
||||||
strcpy(out_buff + sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
strcpy(out_buff + sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||||
g_my_server_id_str);
|
g_my_server_id_str);
|
||||||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff,
|
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, send data fail, " \
|
||||||
"tracker server %s:%u, send data fail, "
|
"errno: %d, error info: %s.", \
|
||||||
"errno: %d, error info: %s.", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +64,6 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
2 * IP_ADDRESS_SIZE];
|
2 * IP_ADDRESS_SIZE];
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -84,10 +83,10 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
||||||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, send data fail, " \
|
||||||
"tracker server %s:%u, send data fail, "
|
"errno: %d, error info: %s", \
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -109,12 +108,12 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, recv data fail or "
|
"tracker server %s:%u, recv data fail or "
|
||||||
"response status != 0, errno: %d, error info: %s",
|
"response status != 0, "
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
"errno: %d, error info: %s",
|
||||||
result, STRERROR(result));
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, result, STRERROR(result));
|
||||||
return result == EBUSY ? 0 : result;
|
return result == EBUSY ? 0 : result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +126,6 @@ int storage_get_my_tracker_client_ip()
|
||||||
TrackerServerInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
char tracker_client_ip[IP_ADDRESS_SIZE];
|
char tracker_client_ip[IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int success_count;
|
int success_count;
|
||||||
int result;
|
int result;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -148,8 +146,7 @@ int storage_get_my_tracker_client_ip()
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR4 : NULL),
|
g_client_bind_addr ? SF_G_INNER_BIND_ADDR : NULL,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR6 : NULL),
|
|
||||||
&result, false);
|
&result, false);
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -161,11 +158,12 @@ int storage_get_my_tracker_client_ip()
|
||||||
|
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to tracker server %s:%u fail, "
|
"connect to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s",
|
||||||
pTServer->connections[0].port, result, STRERROR(result));
|
__LINE__, pTServer->connections[0].ip_addr,
|
||||||
|
pTServer->connections[0].port,
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +198,6 @@ static int storage_report_storage_ip_addr()
|
||||||
TrackerServerInfo *pTServer;
|
TrackerServerInfo *pTServer;
|
||||||
TrackerServerInfo *pTServerEnd;
|
TrackerServerInfo *pTServerEnd;
|
||||||
TrackerServerInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
int success_count;
|
int success_count;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -237,8 +234,7 @@ static int storage_report_storage_ip_addr()
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR4 : NULL),
|
g_client_bind_addr ? SF_G_INNER_BIND_ADDR : NULL,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR6 : NULL),
|
|
||||||
&result, false);
|
&result, false);
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -250,11 +246,12 @@ static int storage_report_storage_ip_addr()
|
||||||
|
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to tracker server %s:%u fail, "
|
"connect to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s",
|
||||||
pTServer->connections[0].port, result, STRERROR(result));
|
__LINE__, pTServer->connections[0].ip_addr,
|
||||||
|
pTServer->connections[0].port,
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +284,6 @@ int storage_changelog_req()
|
||||||
TrackerServerInfo *pTServer;
|
TrackerServerInfo *pTServer;
|
||||||
TrackerServerInfo *pTServerEnd;
|
TrackerServerInfo *pTServerEnd;
|
||||||
TrackerServerInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
int success_count;
|
int success_count;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -308,8 +304,7 @@ int storage_changelog_req()
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR4 : NULL),
|
g_client_bind_addr ? SF_G_INNER_BIND_ADDR : NULL,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR6 : NULL),
|
|
||||||
&result, false);
|
&result, false);
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -321,11 +316,12 @@ int storage_changelog_req()
|
||||||
|
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to tracker server %s:%u fail, "
|
"connect to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s",
|
||||||
pTServer->connections[0].port, result, STRERROR(result));
|
__LINE__, pTServer->connections[0].ip_addr,
|
||||||
|
pTServer->connections[0].port,
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,9 @@ int storage_get_params_from_tracker()
|
||||||
char reserved_space_str[32];
|
char reserved_space_str[32];
|
||||||
char *pIdType;
|
char *pIdType;
|
||||||
|
|
||||||
if ((result=fdfs_get_ini_context_from_tracker_ex(&g_tracker_group,
|
if ((result=fdfs_get_ini_context_from_tracker(&g_tracker_group,
|
||||||
&iniContext, (bool * volatile)&SF_G_CONTINUE_FLAG,
|
&iniContext, (bool * volatile)&SF_G_CONTINUE_FLAG,
|
||||||
g_client_bind_addr, SF_G_INNER_BIND_ADDR4,
|
g_client_bind_addr, SF_G_INNER_BIND_ADDR)) != 0)
|
||||||
SF_G_INNER_BIND_ADDR6)) != 0)
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -179,8 +178,6 @@ int storage_get_params_from_tracker()
|
||||||
{
|
{
|
||||||
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
|
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
|
||||||
}
|
}
|
||||||
g_trust_storage_server_id = iniGetBoolValue(NULL,
|
|
||||||
"trust_storage_server_id", &iniContext, false);
|
|
||||||
|
|
||||||
iniFreeContext(&iniContext);
|
iniFreeContext(&iniContext);
|
||||||
|
|
||||||
|
|
@ -196,7 +193,6 @@ int storage_get_params_from_tracker()
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"use_storage_id=%d, "
|
"use_storage_id=%d, "
|
||||||
"id_type_in_filename=%s, "
|
"id_type_in_filename=%s, "
|
||||||
"trust_storage_server_id=%d, "
|
|
||||||
"storage_ip_changed_auto_adjust=%d, "
|
"storage_ip_changed_auto_adjust=%d, "
|
||||||
"store_path=%d, "
|
"store_path=%d, "
|
||||||
"reserved_storage_space=%s, "
|
"reserved_storage_space=%s, "
|
||||||
|
|
@ -220,7 +216,6 @@ int storage_get_params_from_tracker()
|
||||||
"store_slave_file_use_link=%d",
|
"store_slave_file_use_link=%d",
|
||||||
__LINE__, g_use_storage_id,
|
__LINE__, g_use_storage_id,
|
||||||
g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
|
g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
|
||||||
g_trust_storage_server_id,
|
|
||||||
g_storage_ip_changed_auto_adjust,
|
g_storage_ip_changed_auto_adjust,
|
||||||
g_store_path_mode, fdfs_storage_reserved_space_to_string(
|
g_store_path_mode, fdfs_storage_reserved_space_to_string(
|
||||||
&g_storage_reserved_space, reserved_space_str),
|
&g_storage_reserved_space, reserved_space_str),
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "fastcommon/logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fastcommon/fast_task_queue.h"
|
#include "fastcommon/fast_task_queue.h"
|
||||||
#include "fastcommon/fc_atomic.h"
|
|
||||||
#include "sf/sf_service.h"
|
#include "sf/sf_service.h"
|
||||||
#include "fdfs_define.h"
|
#include "fdfs_define.h"
|
||||||
#include "storage_types.h"
|
#include "storage_types.h"
|
||||||
|
|
@ -40,6 +39,27 @@ int storage_get_storage_path_index(int *store_path_index);
|
||||||
void storage_get_store_path(const char *filename, const int filename_len,
|
void storage_get_store_path(const char *filename, const int filename_len,
|
||||||
int *sub_path_high, int *sub_path_low);
|
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);
|
||||||
|
}
|
||||||
|
memset(pTask->arg, 0, sizeof(StorageClientInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void storage_release_task(struct fast_task_info *pTask)
|
||||||
|
{
|
||||||
|
if (__sync_sub_and_fetch(&pTask->reffer_count, 0) == 1)
|
||||||
|
{
|
||||||
|
storage_clear_task(pTask);
|
||||||
|
}
|
||||||
|
sf_release_task(pTask);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
||||||
char *pBuff;
|
char *pBuff;
|
||||||
char full_filename[MAX_PATH_SIZE];
|
char full_filename[MAX_PATH_SIZE];
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
FDFSTrunkFullInfo trunkInfo;
|
FDFSTrunkFullInfo trunkInfo;
|
||||||
|
|
@ -146,26 +145,26 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
||||||
{
|
{
|
||||||
if (file_info.file_size == stat_buf.st_size)
|
if (file_info.file_size == stat_buf.st_size)
|
||||||
{
|
{
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
"sync data file, logic file: %s " \
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
"on dest server %s:%u already exists, "\
|
||||||
"sync data file, logic file: %s "
|
"and same as mine, ignore it", \
|
||||||
"on dest server %s:%u already exists, "
|
__LINE__, pRecord->filename, \
|
||||||
"and same as mine, ignore it", __LINE__,
|
pStorageServer->ip_addr, \
|
||||||
pRecord->filename, formatted_ip,
|
|
||||||
pStorageServer->port);
|
pStorageServer->port);
|
||||||
}
|
|
||||||
need_sync_file = false;
|
need_sync_file = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logWarning("file: "__FILE__", line: %d, " \
|
||||||
logWarning("file: "__FILE__", line: %d, "
|
"sync data file, logic file: %s " \
|
||||||
"sync data file, logic file: %s "
|
"on dest server %s:%u already exists, "\
|
||||||
"on dest server %s:%u already exists, "
|
"but file size: %"PRId64 \
|
||||||
"but file size: %"PRId64" not same as mine: %"PRId64
|
" not same as mine: %"PRId64 \
|
||||||
", need re-sync it", __LINE__, pRecord->filename,
|
", need re-sync it", __LINE__, \
|
||||||
formatted_ip, pStorageServer->port, file_info.file_size,
|
pRecord->filename, pStorageServer->ip_addr,\
|
||||||
|
pStorageServer->port, \
|
||||||
|
file_info.file_size, \
|
||||||
(int64_t)stat_buf.st_size);
|
(int64_t)stat_buf.st_size);
|
||||||
|
|
||||||
proto_cmd = STORAGE_PROTO_CMD_SYNC_UPDATE_FILE;
|
proto_cmd = STORAGE_PROTO_CMD_SYNC_UPDATE_FILE;
|
||||||
|
|
@ -228,14 +227,16 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
||||||
memcpy(p, pRecord->filename, pRecord->filename_len);
|
memcpy(p, pRecord->filename, pRecord->filename_len);
|
||||||
p += pRecord->filename_len;
|
p += pRecord->filename_len;
|
||||||
|
|
||||||
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"sync data to storage server %s:%u fail, " \
|
||||||
"sync data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,11 +245,13 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
||||||
full_filename, file_offset, stat_buf.st_size, \
|
full_filename, file_offset, stat_buf.st_size, \
|
||||||
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0))
|
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0))
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"sync data to storage server %s:%u fail, " \
|
||||||
"sync data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,13 +276,13 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
||||||
|
|
||||||
if (result == EEXIST)
|
if (result == EEXIST)
|
||||||
{
|
{
|
||||||
if (need_sync_file && pRecord->op_type ==
|
if (need_sync_file && pRecord->op_type == \
|
||||||
STORAGE_OP_TYPE_SOURCE_CREATE_FILE)
|
STORAGE_OP_TYPE_SOURCE_CREATE_FILE)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logWarning("file: "__FILE__", line: %d, " \
|
||||||
logWarning("file: "__FILE__", line: %d, "
|
"storage server ip: %s:%u, data file: %s " \
|
||||||
"storage server ip: %s:%u, data file: %s already exists, "
|
"already exists, maybe some mistake?", \
|
||||||
"maybe some mistake?", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, pRecord->filename);
|
pStorageServer->port, pRecord->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +320,6 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
||||||
char *fields[SYNC_MODIFY_FIELD_COUNT];
|
char *fields[SYNC_MODIFY_FIELD_COUNT];
|
||||||
char full_filename[MAX_PATH_SIZE];
|
char full_filename[MAX_PATH_SIZE];
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -425,11 +427,13 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
||||||
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"sync data to storage server %s:%u fail, " \
|
||||||
"sync data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,11 +441,13 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
||||||
full_filename, start_offset, modify_length, \
|
full_filename, start_offset, modify_length, \
|
||||||
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0)
|
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"sync data to storage server %s:%u fail, " \
|
||||||
"sync data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,7 +491,6 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
|
||||||
char *fields[SYNC_TRUNCATE_FIELD_COUNT];
|
char *fields[SYNC_TRUNCATE_FIELD_COUNT];
|
||||||
char full_filename[MAX_PATH_SIZE];
|
char full_filename[MAX_PATH_SIZE];
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -584,14 +589,16 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
|
||||||
memcpy(p, pRecord->filename, pRecord->filename_len);
|
memcpy(p, pRecord->filename, pRecord->filename_len);
|
||||||
p += pRecord->filename_len;
|
p += pRecord->filename_len;
|
||||||
|
|
||||||
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"sync data to storage server %s:%u fail, " \
|
||||||
"sync data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -620,7 +627,6 @@ static int storage_sync_delete_file(ConnectionInfo *pStorageServer, \
|
||||||
{
|
{
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
FDFSTrunkFullInfo trunkInfo;
|
FDFSTrunkFullInfo trunkInfo;
|
||||||
FDFSTrunkHeader trunkHeader;
|
FDFSTrunkHeader trunkHeader;
|
||||||
|
|
@ -660,11 +666,12 @@ static int storage_sync_delete_file(ConnectionInfo *pStorageServer, \
|
||||||
sizeof(TrackerHeader) + 4 + FDFS_GROUP_NAME_MAX_LEN + \
|
sizeof(TrackerHeader) + 4 + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
pRecord->filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
pRecord->filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("FILE: "__FILE__", line: %d, " \
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -695,7 +702,6 @@ static int storage_report_my_server_id(ConnectionInfo *pStorageServer)
|
||||||
int result;
|
int result;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE];
|
char out_buff[sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pBuff;
|
char *pBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -703,18 +709,19 @@ static int storage_report_my_server_id(ConnectionInfo *pStorageServer)
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
memset(out_buff, 0, sizeof(out_buff));
|
memset(out_buff, 0, sizeof(out_buff));
|
||||||
|
|
||||||
long2buff(FDFS_STORAGE_ID_MAX_SIZE, pHeader->pkg_len);
|
long2buff(IP_ADDRESS_SIZE, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_REPORT_SERVER_ID;
|
pHeader->cmd = STORAGE_PROTO_CMD_REPORT_SERVER_ID;
|
||||||
strcpy(out_buff + sizeof(TrackerHeader), g_my_server_id_str);
|
strcpy(out_buff + sizeof(TrackerHeader), g_my_server_id_str);
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE, \
|
sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("FILE: "__FILE__", line: %d, " \
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -744,7 +751,6 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
|
||||||
int result;
|
int result;
|
||||||
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE + \
|
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE + \
|
||||||
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
FDFSTrunkFullInfo trunkInfo;
|
FDFSTrunkFullInfo trunkInfo;
|
||||||
FDFSTrunkHeader trunkHeader;
|
FDFSTrunkHeader trunkHeader;
|
||||||
|
|
@ -931,15 +937,16 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
|
||||||
long2buff(out_body_len, pHeader->pkg_len);
|
long2buff(out_body_len, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_SYNC_CREATE_LINK;
|
pHeader->cmd = STORAGE_PROTO_CMD_SYNC_CREATE_LINK;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader) + out_body_len,
|
sizeof(TrackerHeader) + out_body_len, \
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("FILE: "__FILE__", line: %d, " \
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -977,7 +984,6 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
||||||
int result;
|
int result;
|
||||||
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE +
|
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE +
|
||||||
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
int out_body_len;
|
int out_body_len;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -1043,10 +1049,10 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
||||||
sizeof(TrackerHeader) + out_body_len,
|
sizeof(TrackerHeader) + out_body_len,
|
||||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
logError("FILE: "__FILE__", line: %d, "
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"send data to storage server %s:%u fail, "
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s",
|
||||||
|
__LINE__, pStorageServer->ip_addr,
|
||||||
pStorageServer->port, result, STRERROR(result));
|
pStorageServer->port, result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -1063,13 +1069,10 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
||||||
}
|
}
|
||||||
else if (result == EEXIST)
|
else if (result == EEXIST)
|
||||||
{
|
{
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"storage server ip: %s:%u, data file: %s "
|
"storage server ip: %s:%u, data file: %s "
|
||||||
"already exists", __LINE__, formatted_ip,
|
"already exists", __LINE__, pStorageServer->ip_addr,
|
||||||
pStorageServer->port, pRecord->filename);
|
pStorageServer->port, pRecord->filename);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1994,7 +1997,6 @@ int storage_report_storage_status(const char *storage_id, \
|
||||||
TrackerServerInfo *pGlobalServer;
|
TrackerServerInfo *pGlobalServer;
|
||||||
TrackerServerInfo *pTServer;
|
TrackerServerInfo *pTServer;
|
||||||
TrackerServerInfo *pTServerEnd;
|
TrackerServerInfo *pTServerEnd;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
int result;
|
int result;
|
||||||
int report_count;
|
int report_count;
|
||||||
|
|
@ -2048,9 +2050,7 @@ int storage_report_storage_status(const char *storage_id, \
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR4 : NULL),
|
g_client_bind_addr ? SF_G_INNER_BIND_ADDR : NULL, &result, false);
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR6 : NULL),
|
|
||||||
&result, false);
|
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -2061,12 +2061,12 @@ int storage_report_storage_status(const char *storage_id, \
|
||||||
|
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(pTServer->connections[0].
|
|
||||||
ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to tracker server %s:%u fail, errno: %d, "
|
"connect to tracker server %s:%u fail, "
|
||||||
"error info: %s", __LINE__, formatted_ip, pTServer->
|
"errno: %d, error info: %s",
|
||||||
connections[0].port, result, STRERROR(result));
|
__LINE__, pTServer->connections[0].ip_addr,
|
||||||
|
pTServer->connections[0].port,
|
||||||
|
result, STRERROR(result));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2146,9 +2146,7 @@ static int storage_reader_sync_init_req(StorageBinLogReader *pReader)
|
||||||
while (SF_G_CONTINUE_FLAG)
|
while (SF_G_CONTINUE_FLAG)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR4 : NULL),
|
g_client_bind_addr ? SF_G_INNER_BIND_ADDR : NULL, &result, true);
|
||||||
(g_client_bind_addr ? SF_G_INNER_BIND_ADDR6 : NULL),
|
|
||||||
&result, true);
|
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -2859,7 +2857,6 @@ static void storage_sync_thread_exit(ConnectionInfo *pStorage)
|
||||||
int i;
|
int i;
|
||||||
int thread_count;
|
int thread_count;
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if ((result=pthread_mutex_lock(&sync_thread_lock)) != 0)
|
if ((result=pthread_mutex_lock(&sync_thread_lock)) != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2895,12 +2892,9 @@ static void storage_sync_thread_exit(ConnectionInfo *pStorage)
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"sync thread to storage server %s:%u exit",
|
"sync thread to storage server %s:%u exit",
|
||||||
__LINE__, formatted_ip, pStorage->port);
|
__LINE__, pStorage->ip_addr, pStorage->port);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* storage_sync_thread_entrance(void* arg)
|
static void* storage_sync_thread_entrance(void* arg)
|
||||||
|
|
@ -2910,7 +2904,6 @@ static void* storage_sync_thread_entrance(void* arg)
|
||||||
StorageBinLogRecord record;
|
StorageBinLogRecord record;
|
||||||
ConnectionInfo storage_server;
|
ConnectionInfo storage_server;
|
||||||
char local_ip_addr[IP_ADDRESS_SIZE];
|
char local_ip_addr[IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int read_result;
|
int read_result;
|
||||||
int sync_result;
|
int sync_result;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -2957,12 +2950,9 @@ static void* storage_sync_thread_entrance(void* arg)
|
||||||
start_time = 0;
|
start_time = 0;
|
||||||
end_time = 0;
|
end_time = 0;
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(storage_server.ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"sync thread to storage server %s:%u started",
|
"sync thread to storage server %s:%u started",
|
||||||
__LINE__, formatted_ip, storage_server.port);
|
__LINE__, storage_server.ip_addr, storage_server.port);
|
||||||
}
|
|
||||||
|
|
||||||
while (SF_G_CONTINUE_FLAG && \
|
while (SF_G_CONTINUE_FLAG && \
|
||||||
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
||||||
|
|
@ -3330,20 +3320,17 @@ int storage_sync_thread_start(const FDFSStorageBrief *pStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_count = FC_ATOMIC_INC(g_storage_sync_thread_count);
|
thread_count = FC_ATOMIC_INC(g_storage_sync_thread_count);
|
||||||
pthread_t *new_sync_tids = (pthread_t *)realloc(sync_tids,
|
sync_tids = (pthread_t *)realloc(sync_tids,
|
||||||
sizeof(pthread_t) * thread_count);
|
sizeof(pthread_t) * thread_count);
|
||||||
if (new_sync_tids == NULL)
|
if (sync_tids == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"malloc %d bytes fail, errno: %d, error info: %s",
|
"malloc %d bytes fail, errno: %d, error info: %s",
|
||||||
__LINE__, (int)sizeof(pthread_t) * thread_count,
|
__LINE__, (int)sizeof(pthread_t) * thread_count,
|
||||||
errno, STRERROR(errno));
|
errno, STRERROR(errno));
|
||||||
free(sync_tids);
|
|
||||||
sync_tids = NULL;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sync_tids = new_sync_tids;
|
|
||||||
sync_tids[thread_count - 1] = tid;
|
sync_tids[thread_count - 1] = tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
||||||
int i;
|
int i;
|
||||||
FDFSMultiIP ip_addrs;
|
FDFSMultiIP ip_addrs;
|
||||||
FDFSMultiIP *multi_ip;
|
FDFSMultiIP *multi_ip;
|
||||||
const char *bind_addr;
|
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
multi_ip = NULL;
|
multi_ip = NULL;
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
|
|
@ -85,17 +83,9 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
||||||
for (i=0; i<ip_addrs.count; i++)
|
for (i=0; i<ip_addrs.count; i++)
|
||||||
{
|
{
|
||||||
strcpy(conn->ip_addr, ip_addrs.ips[i].address);
|
strcpy(conn->ip_addr, ip_addrs.ips[i].address);
|
||||||
if (g_client_bind_addr)
|
|
||||||
{
|
|
||||||
bind_addr = is_ipv6_addr(conn->ip_addr) ?
|
|
||||||
SF_G_INNER_BIND_ADDR6 : SF_G_INNER_BIND_ADDR4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bind_addr = NULL;
|
|
||||||
}
|
|
||||||
conn->sock = socketCreateExAuto(conn->ip_addr,
|
conn->sock = socketCreateExAuto(conn->ip_addr,
|
||||||
O_NONBLOCK, bind_addr, &result);
|
O_NONBLOCK, g_client_bind_addr ?
|
||||||
|
SF_G_INNER_BIND_ADDR : NULL, &result);
|
||||||
if (conn->sock < 0)
|
if (conn->sock < 0)
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d, "
|
logCrit("file: "__FILE__", line: %d, "
|
||||||
|
|
@ -119,12 +109,10 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
||||||
", continuous fail count: %d",
|
", continuous fail count: %d",
|
||||||
nContinuousFail);
|
nContinuousFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"successfully connect to "
|
"successfully connect to "
|
||||||
"storage server %s:%u%s", __LINE__,
|
"storage server %s:%u%s", __LINE__,
|
||||||
formatted_ip, SF_G_INNER_PORT, szFailPrompt);
|
conn->ip_addr, SF_G_INNER_PORT, szFailPrompt);
|
||||||
nContinuousFail = 0;
|
nContinuousFail = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -132,11 +120,10 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
||||||
nContinuousFail++;
|
nContinuousFail++;
|
||||||
if (previousCodes[i] != conn_results[i])
|
if (previousCodes[i] != conn_results[i])
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to storage server %s:%u fail, "
|
"connect to storage server %s:%u fail, "
|
||||||
"errno: %d, error info: %s",
|
"errno: %d, error info: %s",
|
||||||
__LINE__, formatted_ip, SF_G_INNER_PORT,
|
__LINE__, conn->ip_addr, SF_G_INNER_PORT,
|
||||||
conn_results[i], STRERROR(conn_results[i]));
|
conn_results[i], STRERROR(conn_results[i]));
|
||||||
previousCodes[i] = conn_results[i];
|
previousCodes[i] = conn_results[i];
|
||||||
}
|
}
|
||||||
|
|
@ -159,11 +146,10 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
||||||
avg_fails = (nContinuousFail + ip_addrs.count - 1) / ip_addrs.count;
|
avg_fails = (nContinuousFail + ip_addrs.count - 1) / ip_addrs.count;
|
||||||
for (i=0; i<ip_addrs.count; i++)
|
for (i=0; i<ip_addrs.count; i++)
|
||||||
{
|
{
|
||||||
format_ip_address(ip_addrs.ips[i].address, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to storage server %s:%u fail, "
|
"connect to storage server %s:%u fail, "
|
||||||
"try count: %d, errno: %d, error info: %s",
|
"try count: %d, errno: %d, error info: %s",
|
||||||
__LINE__, formatted_ip, SF_G_INNER_PORT, avg_fails,
|
__LINE__, ip_addrs.ips[i].address, SF_G_INNER_PORT, avg_fails,
|
||||||
conn_results[i], STRERROR(conn_results[i]));
|
conn_results[i], STRERROR(conn_results[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@
|
||||||
#define FDFS_STORAGE_FILE_OP_DELETE 'D'
|
#define FDFS_STORAGE_FILE_OP_DELETE 'D'
|
||||||
#define FDFS_STORAGE_FILE_OP_DISCARD 'd'
|
#define FDFS_STORAGE_FILE_OP_DISCARD 'd'
|
||||||
|
|
||||||
#define FDFS_TRUNK_FILE_CREATOR_TASK_ID 88
|
|
||||||
#define FDFS_TRUNK_BINLOG_COMPRESS_TASK_ID 89
|
|
||||||
#define FDFS_CLEAR_EXPIRED_FILE_ID_TASK_ID 90
|
|
||||||
|
|
||||||
typedef int (*TaskDealFunc)(struct fast_task_info *pTask);
|
typedef int (*TaskDealFunc)(struct fast_task_info *pTask);
|
||||||
|
|
||||||
/* this clean func will be called when connection disconnected */
|
/* this clean func will be called when connection disconnected */
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -35,7 +35,6 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
||||||
char *p;
|
char *p;
|
||||||
int result;
|
int result;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 5];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 5];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
FDFSTrunkInfoBuff trunkBuff;
|
FDFSTrunkInfoBuff trunkBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
||||||
|
|
@ -51,14 +50,15 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
||||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + 5, pHeader->pkg_len);
|
long2buff(FDFS_GROUP_NAME_MAX_LEN + 5, pHeader->pkg_len);
|
||||||
pHeader->cmd = STORAGE_PROTO_CMD_TRUNK_ALLOC_SPACE;
|
pHeader->cmd = STORAGE_PROTO_CMD_TRUNK_ALLOC_SPACE;
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pTrunkServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pTrunkServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||||
pTrunkServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,12 +74,11 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
||||||
|
|
||||||
if (in_bytes != sizeof(FDFSTrunkInfoBuff))
|
if (in_bytes != sizeof(FDFSTrunkInfoBuff))
|
||||||
{
|
{
|
||||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u, recv body length: %d invalid, " \
|
||||||
"storage server %s:%u, recv body length: %d invalid, "
|
"expect body length: %d", __LINE__, \
|
||||||
"expect body length: %d", __LINE__, formatted_ip,
|
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||||
pTrunkServer->port, (int)in_bytes,
|
(int)in_bytes, (int)sizeof(FDFSTrunkInfoBuff));
|
||||||
(int)sizeof(FDFSTrunkInfoBuff));
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +97,6 @@ static int trunk_client_connect_trunk_server(TrackerServerInfo *trunk_server,
|
||||||
ConnectionInfo **conn, const char *prompt)
|
ConnectionInfo **conn, const char *prompt)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if (g_trunk_server.count == 0)
|
if (g_trunk_server.count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -110,11 +108,10 @@ static int trunk_client_connect_trunk_server(TrackerServerInfo *trunk_server,
|
||||||
memcpy(trunk_server, &g_trunk_server, sizeof(TrackerServerInfo));
|
memcpy(trunk_server, &g_trunk_server, sizeof(TrackerServerInfo));
|
||||||
if ((*conn=tracker_connect_server(trunk_server, &result)) == NULL)
|
if ((*conn=tracker_connect_server(trunk_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(trunk_server->connections[0].
|
|
||||||
ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"%s because connect to trunk server %s:%u fail, "
|
"%s because connect to trunk "
|
||||||
"errno: %d", __LINE__, prompt, formatted_ip,
|
"server %s:%u fail, errno: %d", __LINE__,
|
||||||
|
prompt, trunk_server->connections[0].ip_addr,
|
||||||
trunk_server->connections[0].port, result);
|
trunk_server->connections[0].port, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +167,6 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
||||||
int result;
|
int result;
|
||||||
char out_buff[sizeof(TrackerHeader) \
|
char out_buff[sizeof(TrackerHeader) \
|
||||||
+ STORAGE_TRUNK_ALLOC_CONFIRM_REQ_BODY_LEN];
|
+ STORAGE_TRUNK_ALLOC_CONFIRM_REQ_BODY_LEN];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
pTrunkBuff = (FDFSTrunkInfoBuff *)(out_buff + sizeof(TrackerHeader) \
|
pTrunkBuff = (FDFSTrunkInfoBuff *)(out_buff + sizeof(TrackerHeader) \
|
||||||
|
|
@ -189,14 +185,15 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
||||||
int2buff(pTrunkInfo->file.offset, pTrunkBuff->offset);
|
int2buff(pTrunkInfo->file.offset, pTrunkBuff->offset);
|
||||||
int2buff(pTrunkInfo->file.size, pTrunkBuff->size);
|
int2buff(pTrunkInfo->file.size, pTrunkBuff->size);
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pTrunkServer->sock, out_buff,
|
if ((result=tcpsenddata_nb(pTrunkServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||||
pTrunkServer->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,11 +207,11 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
||||||
|
|
||||||
if (in_bytes != 0)
|
if (in_bytes != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u response data " \
|
||||||
"storage server %s:%u response data length: "
|
"length: %"PRId64" is invalid, " \
|
||||||
"%"PRId64" is invalid, should == 0", __LINE__,
|
"should == 0", __LINE__, pTrunkServer->ip_addr, \
|
||||||
formatted_ip, pTrunkServer->port, in_bytes);
|
pTrunkServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
|
|
||||||
FDFSStorePaths g_fdfs_store_paths = {0, NULL};
|
FDFSStorePaths g_fdfs_store_paths = {0, NULL};
|
||||||
|
struct base64_context g_fdfs_base64_context;
|
||||||
BufferInfo g_zero_buffer = {NULL, 0, 0};
|
BufferInfo g_zero_buffer = {NULL, 0, 0};
|
||||||
|
|
||||||
int trunk_shared_init()
|
int trunk_shared_init()
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern FDFSStorePaths g_fdfs_store_paths; //file store paths
|
extern FDFSStorePaths g_fdfs_store_paths; //file store paths
|
||||||
|
extern struct base64_context g_fdfs_base64_context; //base64 context
|
||||||
extern BufferInfo g_zero_buffer; //zero buffer for reset
|
extern BufferInfo g_zero_buffer; //zero buffer for reset
|
||||||
|
|
||||||
typedef int (*stat_func)(const char *filename, struct stat *buf);
|
typedef int (*stat_func)(const char *filename, struct stat *buf);
|
||||||
|
|
|
||||||
|
|
@ -1953,7 +1953,6 @@ static void trunk_sync_thread_exit(TrunkSyncThreadInfo *thread_data,
|
||||||
const int port)
|
const int port)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if ((result=pthread_mutex_lock(&trunk_sync_thread_lock)) != 0)
|
if ((result=pthread_mutex_lock(&trunk_sync_thread_lock)) != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1974,10 +1973,9 @@ static void trunk_sync_thread_exit(TrunkSyncThreadInfo *thread_data,
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(thread_data->pStorage->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"trunk sync thread to storage server %s:%u exit",
|
"trunk sync thread to storage server %s:%u exit",
|
||||||
__LINE__, formatted_ip, port);
|
__LINE__, thread_data->pStorage->ip_addr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
||||||
|
|
@ -1987,7 +1985,6 @@ static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
||||||
char *p;
|
char *p;
|
||||||
int result;
|
int result;
|
||||||
TrackerHeader header;
|
TrackerHeader header;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pBuff;
|
char *pBuff;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
|
|
@ -2012,25 +2009,25 @@ static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
long2buff(length, header.pkg_len);
|
long2buff(length, header.pkg_len);
|
||||||
header.cmd = STORAGE_PROTO_CMD_TRUNK_SYNC_BINLOG;
|
header.cmd = STORAGE_PROTO_CMD_TRUNK_SYNC_BINLOG;
|
||||||
if ((result=tcpsenddata_nb(pStorage->sock, &header,
|
if ((result=tcpsenddata_nb(pStorage->sock, &header, \
|
||||||
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
logError("FILE: "__FILE__", line: %d, " \
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorage->ip_addr, pStorage->port, \
|
||||||
pStorage->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(pStorage->sock, pReader->binlog_buff.buffer,
|
if ((result=tcpsenddata_nb(pStorage->sock, pReader->binlog_buff.buffer,\
|
||||||
length, SF_G_NETWORK_TIMEOUT)) != 0)
|
length, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
logError("FILE: "__FILE__", line: %d, " \
|
||||||
logError("FILE: "__FILE__", line: %d, "
|
"send data to storage server %s:%u fail, " \
|
||||||
"send data to storage server %s:%u fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pStorage->ip_addr, pStorage->port, \
|
||||||
pStorage->port, result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2060,7 +2057,6 @@ static void *trunk_sync_thread_entrance(void* arg)
|
||||||
TrunkBinLogReader reader;
|
TrunkBinLogReader reader;
|
||||||
ConnectionInfo storage_server;
|
ConnectionInfo storage_server;
|
||||||
char local_ip_addr[IP_ADDRESS_SIZE];
|
char local_ip_addr[IP_ADDRESS_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int read_result;
|
int read_result;
|
||||||
int sync_result;
|
int sync_result;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -2089,10 +2085,9 @@ static void *trunk_sync_thread_entrance(void* arg)
|
||||||
storage_server.port = SF_G_INNER_PORT;
|
storage_server.port = SF_G_INNER_PORT;
|
||||||
storage_server.sock = -1;
|
storage_server.sock = -1;
|
||||||
|
|
||||||
format_ip_address(storage_server.ip_addr, formatted_ip);
|
logInfo("file: "__FILE__", line: %d, " \
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
|
||||||
"trunk sync thread to storage server %s:%u started",
|
"trunk sync thread to storage server %s:%u started",
|
||||||
__LINE__, formatted_ip, storage_server.port);
|
__LINE__, storage_server.ip_addr, storage_server.port);
|
||||||
|
|
||||||
while (SF_G_CONTINUE_FLAG && g_if_trunker_self && \
|
while (SF_G_CONTINUE_FLAG && g_if_trunker_self && \
|
||||||
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ After=network-online.target
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/opt/fastdfs/data/fdfs_storaged.pid
|
PIDFile=/opt/fastdfs/data/fdfs_storaged.pid
|
||||||
ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
|
ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
|
||||||
ExecStartPost=/bin/sleep 0.1
|
|
||||||
ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
|
ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
|
||||||
|
|
||||||
# No artificial start/stop timeout
|
# No artificial start/stop timeout
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ After=network-online.target
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/opt/fastdfs/data/fdfs_trackerd.pid
|
PIDFile=/opt/fastdfs/data/fdfs_trackerd.pid
|
||||||
ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
|
ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
|
||||||
ExecStartPost=/bin/sleep 0.1
|
|
||||||
ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
|
ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
|
||||||
|
|
||||||
# No artificial start/stop timeout
|
# No artificial start/stop timeout
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ static ConnectionInfo *getConnectedStorageServer(
|
||||||
{
|
{
|
||||||
if (pServer->sock < 0)
|
if (pServer->sock < 0)
|
||||||
{
|
{
|
||||||
*err_no = conn_pool_connect_server(pServer,
|
*err_no = conn_pool_connect_server(pServer, \
|
||||||
SF_G_CONNECT_TIMEOUT * 1000);
|
SF_G_CONNECT_TIMEOUT);
|
||||||
if (*err_no != 0)
|
if (*err_no != 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -46,8 +46,8 @@ static ConnectionInfo *getConnectedStorageServer(
|
||||||
pServer = pEnd;
|
pServer = pEnd;
|
||||||
memcpy(pServer, pStorageServer, sizeof(ConnectionInfo));
|
memcpy(pServer, pStorageServer, sizeof(ConnectionInfo));
|
||||||
pServer->sock = -1;
|
pServer->sock = -1;
|
||||||
if ((*err_no=conn_pool_connect_server(pServer,
|
if ((*err_no=conn_pool_connect_server(pServer, \
|
||||||
SF_G_CONNECT_TIMEOUT * 1000)) != 0)
|
SF_G_CONNECT_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#define FILENAME_FILE_ID "file_id"
|
#define FILENAME_FILE_ID "file_id"
|
||||||
#define FILENAME_FAIL "fail"
|
#define FILENAME_FAIL "fail"
|
||||||
|
|
||||||
|
#define IP_ADDRESS_SIZE 16
|
||||||
#define SRAND_SEED 1225420780
|
#define SRAND_SEED 1225420780
|
||||||
|
|
||||||
#define TIME_SUB_MS(tv1, tv2) ((tv1.tv_sec - tv2.tv_sec) * 1000 + (tv1.tv_usec - tv2.tv_usec) / 1000)
|
#define TIME_SUB_MS(tv1, tv2) ((tv1.tv_sec - tv2.tv_sec) * 1000 + (tv1.tv_usec - tv2.tv_usec) / 1000)
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_index >= FILE_TYPE_COUNT || files[file_index].upload_count >= files[file_index].count)
|
if (files[file_index].upload_count >= files[file_index].count)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,6 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
||||||
char *group_name;
|
char *group_name;
|
||||||
char *pHost;
|
char *pHost;
|
||||||
char *pPort;
|
char *pPort;
|
||||||
char *pSquare;
|
|
||||||
FDFSStorageIdInfo *pStorageIdInfo;
|
FDFSStorageIdInfo *pStorageIdInfo;
|
||||||
char error_info[256];
|
char error_info[256];
|
||||||
int alloc_bytes;
|
int alloc_bytes;
|
||||||
|
|
@ -406,17 +405,18 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
pHost = group_name;
|
pHost = group_name;
|
||||||
while (!(*pHost == ' ' || *pHost == '\t' || *pHost == '\0'))
|
while (!(*pHost == ' ' || *pHost == '\t' \
|
||||||
|
|| *pHost == '\0'))
|
||||||
{
|
{
|
||||||
pHost++;
|
pHost++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*pHost == '\0')
|
if (*pHost == '\0')
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"config file: %s, line no: %d, "
|
"config file: %s, line no: %d, " \
|
||||||
"content: %s, invalid format, "
|
"content: %s, invalid format, " \
|
||||||
"expect ip address!", __LINE__,
|
"expect ip address!", __LINE__, \
|
||||||
pStorageIdsFilename, i + 1, line);
|
pStorageIdsFilename, i + 1, line);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -429,33 +429,6 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
||||||
pHost++;
|
pHost++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*pHost == '[') //IPv6 address
|
|
||||||
{
|
|
||||||
pHost++; //skip [
|
|
||||||
pSquare = strchr(pHost, ']');
|
|
||||||
if (pSquare == NULL)
|
|
||||||
{
|
|
||||||
result = EINVAL;
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"config file: %s, line no: %d, invalid IPv6 "
|
|
||||||
"address: %s", __LINE__, pStorageIdsFilename,
|
|
||||||
i + 1, pHost - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pSquare = '\0';
|
|
||||||
pPort = pSquare + 1;
|
|
||||||
if (*pPort == ':')
|
|
||||||
{
|
|
||||||
pStorageIdInfo->port = atoi(pPort + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pStorageIdInfo->port = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pPort = strchr(pHost, ':');
|
pPort = strchr(pHost, ':');
|
||||||
if (pPort != NULL)
|
if (pPort != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -466,7 +439,6 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
||||||
{
|
{
|
||||||
pStorageIdInfo->port = 0;
|
pStorageIdInfo->port = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=fdfs_parse_multi_ips(pHost, &pStorageIdInfo->ip_addrs,
|
if ((result=fdfs_parse_multi_ips(pHost, &pStorageIdInfo->ip_addrs,
|
||||||
error_info, sizeof(error_info))) != 0)
|
error_info, sizeof(error_info))) != 0)
|
||||||
|
|
@ -488,9 +460,9 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
||||||
|
|
||||||
if (!fdfs_is_server_id_valid(id))
|
if (!fdfs_is_server_id_valid(id))
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"invalid server id: \"%s\", "
|
"invalid server id: \"%s\", " \
|
||||||
"which must be a none zero start "
|
"which must be a none zero start " \
|
||||||
"integer, such as 100001", __LINE__, id);
|
"integer, such as 100001", __LINE__, id);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -566,8 +538,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
#define MAX_REQUEST_LOOP 32
|
#define MAX_REQUEST_LOOP 32
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
char out_buff[sizeof(TrackerHeader) + sizeof(FDFSFetchStorageIdsBody)];
|
char out_buff[sizeof(TrackerHeader) + sizeof(int)];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *p;
|
char *p;
|
||||||
char *response;
|
char *response;
|
||||||
struct data_info {
|
struct data_info {
|
||||||
|
|
@ -593,7 +564,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
p = out_buff + sizeof(TrackerHeader);
|
p = out_buff + sizeof(TrackerHeader);
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_FETCH_STORAGE_IDS;
|
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_FETCH_STORAGE_IDS;
|
||||||
long2buff(sizeof(FDFSFetchStorageIdsBody), pHeader->pkg_len);
|
long2buff(sizeof(int), pHeader->pkg_len);
|
||||||
|
|
||||||
start_index = 0;
|
start_index = 0;
|
||||||
list_count = 0;
|
list_count = 0;
|
||||||
|
|
@ -604,11 +575,10 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"errno: %d, error info: %s", __LINE__,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
formatted_ip, conn->port,
|
conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -630,10 +600,9 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
|
|
||||||
if (in_bytes < 2 * sizeof(int))
|
if (in_bytes < 2 * sizeof(int))
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, recv data length: %d "
|
"tracker server %s:%u, recv data length: %d "
|
||||||
"is invalid", __LINE__, formatted_ip,
|
"is invalid", __LINE__, conn->ip_addr,
|
||||||
conn->port, (int)in_bytes);
|
conn->port, (int)in_bytes);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -643,11 +612,10 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
current_count = buff2int(response + sizeof(int));
|
current_count = buff2int(response + sizeof(int));
|
||||||
if (total_count <= start_index)
|
if (total_count <= start_index)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, total storage "
|
"tracker server %s:%u, total storage "
|
||||||
"count: %d is invalid, which <= start "
|
"count: %d is invalid, which <= start "
|
||||||
"index: %d", __LINE__, formatted_ip,
|
"index: %d", __LINE__, conn->ip_addr,
|
||||||
conn->port, total_count, start_index);
|
conn->port, total_count, start_index);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -655,11 +623,10 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
|
|
||||||
if (current_count <= 0)
|
if (current_count <= 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, current storage "
|
"tracker server %s:%u, current storage "
|
||||||
"count: %d is invalid, which <= 0", __LINE__,
|
"count: %d is invalid, which <= 0", __LINE__,
|
||||||
formatted_ip, conn->port, current_count);
|
conn->ip_addr, conn->port, current_count);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -682,11 +649,10 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
|
|
||||||
if (list_count == MAX_REQUEST_LOOP)
|
if (list_count == MAX_REQUEST_LOOP)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"response data from tracker server "
|
"response data from tracker "
|
||||||
"%s:%u is too large", __LINE__,
|
"server %s:%u is too large",
|
||||||
formatted_ip, conn->port);
|
__LINE__, conn->ip_addr, conn->port);
|
||||||
result = ENOSPC;
|
result = ENOSPC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include "fastcommon/logger.h"
|
#include "fastcommon/logger.h"
|
||||||
#include "fastcommon/sockopt.h"
|
#include "fastcommon/sockopt.h"
|
||||||
#include "fastcommon/shared_func.h"
|
#include "fastcommon/shared_func.h"
|
||||||
#include "fastcommon/local_ip_func.h"
|
#include "fastcommon/local_ip_func.h"
|
||||||
#include "fastcommon/md5.h"
|
|
||||||
#include "tracker_proto.h"
|
#include "tracker_proto.h"
|
||||||
#include "fdfs_global.h"
|
#include "fdfs_global.h"
|
||||||
#include "fdfs_shared_func.h"
|
#include "fdfs_shared_func.h"
|
||||||
|
|
@ -203,19 +201,19 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
||||||
char *pReservedSpaceStr;
|
char *pReservedSpaceStr;
|
||||||
int64_t storage_reserved;
|
int64_t storage_reserved;
|
||||||
|
|
||||||
pReservedSpaceStr = iniGetStrValue(NULL,
|
pReservedSpaceStr = iniGetStrValue(NULL, \
|
||||||
"reserved_storage_space", pIniContext);
|
"reserved_storage_space", pIniContext);
|
||||||
if (pReservedSpaceStr == NULL)
|
if (pReservedSpaceStr == NULL)
|
||||||
{
|
{
|
||||||
pStorageReservedSpace->flag =
|
pStorageReservedSpace->flag = \
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB;
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB;
|
||||||
pStorageReservedSpace->rs.mb = FDFS_DEF_STORAGE_RESERVED_MB;
|
pStorageReservedSpace->rs.mb = FDFS_DEF_STORAGE_RESERVED_MB;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*pReservedSpaceStr == '\0')
|
if (*pReservedSpaceStr == '\0')
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"item \"reserved_storage_space\" is empty!",
|
"item \"reserved_storage_space\" is empty!", \
|
||||||
__LINE__);
|
__LINE__);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -227,22 +225,24 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
||||||
pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO;
|
pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO;
|
||||||
endptr = NULL;
|
endptr = NULL;
|
||||||
*(pReservedSpaceStr + len - 1) = '\0';
|
*(pReservedSpaceStr + len - 1) = '\0';
|
||||||
pStorageReservedSpace->rs.ratio =
|
pStorageReservedSpace->rs.ratio = \
|
||||||
strtod(pReservedSpaceStr, &endptr);
|
strtod(pReservedSpaceStr, &endptr);
|
||||||
if (endptr != NULL && *endptr != '\0')
|
if (endptr != NULL && *endptr != '\0')
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"item \"reserved_storage_space\": %s%%"
|
"item \"reserved_storage_space\": %s%%"\
|
||||||
" is invalid!", __LINE__, pReservedSpaceStr);
|
" is invalid!", __LINE__, \
|
||||||
|
pReservedSpaceStr);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStorageReservedSpace->rs.ratio <= 0.00 ||
|
if (pStorageReservedSpace->rs.ratio <= 0.00 || \
|
||||||
pStorageReservedSpace->rs.ratio >= 100.00)
|
pStorageReservedSpace->rs.ratio >= 100.00)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"item \"reserved_storage_space\": %s%%"
|
"item \"reserved_storage_space\": %s%%"\
|
||||||
" is invalid!", __LINE__, pReservedSpaceStr);
|
" is invalid!", __LINE__, \
|
||||||
|
pReservedSpaceStr);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,7 +310,7 @@ int64_t fdfs_get_storage_reserved_space_mb(const int64_t total_mb,
|
||||||
bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag ==
|
if (pStorageReservedSpace->flag == \
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return pGroup->free_mb > pStorageReservedSpace->rs.mb;
|
return pGroup->free_mb > pStorageReservedSpace->rs.mb;
|
||||||
|
|
@ -328,7 +328,7 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
pStorageReservedSpace->rs.ratio);
|
pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)pGroup->free_mb / (double)pGroup->total_mb) >
|
return ((double)pGroup->free_mb / (double)pGroup->total_mb) > \
|
||||||
pStorageReservedSpace->rs.ratio;
|
pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag ==
|
if (pStorageReservedSpace->flag == \
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return (pGroup->free_mb + pGroup->trunk_free_mb >
|
return (pGroup->free_mb + pGroup->trunk_free_mb >
|
||||||
|
|
@ -351,20 +351,20 @@ bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("storage trunk=%.4f, rs.ratio=%.4f",
|
logInfo("storage trunk=%.4f, rs.ratio=%.4f",
|
||||||
((double)(pGroup->free_mb + pGroup->trunk_free_mb) /
|
((double)(pGroup->free_mb + pGroup->trunk_free_mb) / \
|
||||||
(double)pGroup->total_mb), pStorageReservedSpace->rs.ratio);
|
(double)pGroup->total_mb), pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)(pGroup->free_mb + pGroup->trunk_free_mb) /
|
return ((double)(pGroup->free_mb + pGroup->trunk_free_mb) / \
|
||||||
(double)pGroup->total_mb) > pStorageReservedSpace->rs.ratio;
|
(double)pGroup->total_mb) > pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fdfs_check_reserved_space_path(const int64_t total_mb,
|
bool fdfs_check_reserved_space_path(const int64_t total_mb, \
|
||||||
const int64_t free_mb, const int64_t avg_mb,
|
const int64_t free_mb, const int64_t avg_mb, \
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag ==
|
if (pStorageReservedSpace->flag == \
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return free_mb > avg_mb;
|
return free_mb > avg_mb;
|
||||||
|
|
@ -377,14 +377,14 @@ bool fdfs_check_reserved_space_path(const int64_t total_mb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("storage path, free_mb=%"PRId64
|
logInfo("storage path, free_mb=%"PRId64 \
|
||||||
", total_mb=%"PRId64", "
|
", total_mb=%"PRId64", " \
|
||||||
"real ratio=%.4f, rs.ratio=%.4f",
|
"real ratio=%.4f, rs.ratio=%.4f", \
|
||||||
free_mb, total_mb, ((double)free_mb / total_mb),
|
free_mb, total_mb, ((double)free_mb / total_mb), \
|
||||||
pStorageReservedSpace->rs.ratio);
|
pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)free_mb / (double)total_mb) >
|
return ((double)free_mb / (double)total_mb) > \
|
||||||
pStorageReservedSpace->rs.ratio;
|
pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -437,7 +437,6 @@ void fdfs_set_log_rotate_size(LogContext *pContext, const int64_t log_rotate_siz
|
||||||
int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
||||||
TrackerServerInfo *pServer, const bool resolve)
|
TrackerServerInfo *pServer, const bool resolve)
|
||||||
{
|
{
|
||||||
char *pSquare;
|
|
||||||
char *pColon;
|
char *pColon;
|
||||||
char *hosts[FDFS_MULTI_IP_MAX_COUNT];
|
char *hosts[FDFS_MULTI_IP_MAX_COUNT];
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
|
|
@ -445,30 +444,7 @@ int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(pServer, 0, sizeof(TrackerServerInfo));
|
memset(pServer, 0, sizeof(TrackerServerInfo));
|
||||||
if (*server_str == '[')
|
if ((pColon=strrchr(server_str, ':')) == NULL)
|
||||||
{
|
|
||||||
server_str++;
|
|
||||||
if ((pSquare=strchr(server_str, ']')) == NULL)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"host \"%s\" is invalid",
|
|
||||||
__LINE__, server_str - 1);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pSquare = '\0';
|
|
||||||
pColon = pSquare + 1; //skip ]
|
|
||||||
if (*pColon != ':')
|
|
||||||
{
|
|
||||||
pColon = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pColon = strrchr(server_str, ':');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pColon == NULL)
|
|
||||||
{
|
{
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"no port part in %s, set port to %d",
|
"no port part in %s, set port to %d",
|
||||||
|
|
@ -488,8 +464,8 @@ int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
||||||
{
|
{
|
||||||
if (resolve)
|
if (resolve)
|
||||||
{
|
{
|
||||||
if (getIpaddrByNameEx(hosts[i], conn->ip_addr,
|
if (getIpaddrByName(hosts[i], conn->ip_addr,
|
||||||
sizeof(conn->ip_addr), &conn->af) == INADDR_NONE)
|
sizeof(conn->ip_addr)) == INADDR_NONE)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"host \"%s\" is invalid, error info: %s",
|
"host \"%s\" is invalid, error info: %s",
|
||||||
|
|
@ -500,9 +476,7 @@ int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(conn->ip_addr, sizeof(conn->ip_addr), "%s", hosts[i]);
|
snprintf(conn->ip_addr, sizeof(conn->ip_addr), "%s", hosts[i]);
|
||||||
conn->af = is_ipv6_addr(conn->ip_addr) ? AF_INET6 : AF_INET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->port = port;
|
conn->port = port;
|
||||||
conn->sock = -1;
|
conn->sock = -1;
|
||||||
conn++;
|
conn++;
|
||||||
|
|
@ -517,60 +491,25 @@ int fdfs_server_info_to_string_ex(const TrackerServerInfo *pServer,
|
||||||
const ConnectionInfo *conn;
|
const ConnectionInfo *conn;
|
||||||
const ConnectionInfo *end;
|
const ConnectionInfo *end;
|
||||||
int len;
|
int len;
|
||||||
bool is_ipv6;
|
|
||||||
|
|
||||||
if (pServer->count <= 0)
|
if (pServer->count <= 0)
|
||||||
{
|
{
|
||||||
*buff = '\0';
|
*buff = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pServer->count == 1)
|
if (pServer->count == 1)
|
||||||
{
|
|
||||||
if (is_ipv6_addr(pServer->connections[0].ip_addr))
|
|
||||||
{
|
|
||||||
return snprintf(buff, buffSize, "[%s]:%u",
|
|
||||||
pServer->connections[0].ip_addr, port);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return snprintf(buff, buffSize, "%s:%u",
|
return snprintf(buff, buffSize, "%s:%u",
|
||||||
pServer->connections[0].ip_addr, port);
|
pServer->connections[0].ip_addr, port);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
is_ipv6 = false;
|
len = snprintf(buff, buffSize, "%s", pServer->connections[0].ip_addr);
|
||||||
end = pServer->connections + pServer->count;
|
end = pServer->connections + pServer->count;
|
||||||
for (conn=pServer->connections; conn<end; conn++)
|
|
||||||
{
|
|
||||||
if (is_ipv6_addr(conn->ip_addr))
|
|
||||||
{
|
|
||||||
is_ipv6 = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_ipv6)
|
|
||||||
{
|
|
||||||
*buff = '[';
|
|
||||||
len = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
len += snprintf(buff + len, buffSize - len, "%s",
|
|
||||||
pServer->connections[0].ip_addr);
|
|
||||||
for (conn=pServer->connections + 1; conn<end; conn++)
|
for (conn=pServer->connections + 1; conn<end; conn++)
|
||||||
{
|
{
|
||||||
len += snprintf(buff + len, buffSize - len, ",%s", conn->ip_addr);
|
len += snprintf(buff + len, buffSize - len, ",%s", conn->ip_addr);
|
||||||
}
|
}
|
||||||
if (is_ipv6 && len < buffSize - 2)
|
len += snprintf(buff + len, buffSize - len, ":%d", port);
|
||||||
{
|
|
||||||
*(buff + len++) = ']';
|
|
||||||
}
|
|
||||||
len += snprintf(buff + len, buffSize - len, ":%u", port);
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -842,12 +781,3 @@ void fdfs_set_server_info_ex(TrackerServerInfo *pServer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fdfs_ip_to_shortcode(const char *ipAddr, char *shortCode)
|
|
||||||
{
|
|
||||||
int64_t crc64;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
crc64 = CRC32_ex(ipAddr, strlen(ipAddr), CRC32_XINIT);
|
|
||||||
return base64_encode(&g_fdfs_base64_context, (const char *)&crc64,
|
|
||||||
sizeof(crc64), shortCode, &len);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,6 @@ void fdfs_set_server_info(TrackerServerInfo *pServer,
|
||||||
void fdfs_set_server_info_ex(TrackerServerInfo *pServer,
|
void fdfs_set_server_info_ex(TrackerServerInfo *pServer,
|
||||||
const FDFSMultiIP *ip_addrs, const int port);
|
const FDFSMultiIP *ip_addrs, const int port);
|
||||||
|
|
||||||
char *fdfs_ip_to_shortcode(const char *ipAddr, char *shortCode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ int main(int argc, char *argv[])
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
base64_init_ex(&g_fdfs_base64_context, 0, '-', '_', '.');
|
base64_init_ex(&g_base64_context, 0, '-', '_', '.');
|
||||||
if ((result=set_rand_seed()) != 0)
|
if ((result=set_rand_seed()) != 0)
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -289,8 +289,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((result=set_run_by(g_sf_global_vars.run_by.group,
|
if ((result=set_run_by(g_sf_global_vars.run_by_group,
|
||||||
g_sf_global_vars.run_by.user)) != 0)
|
g_sf_global_vars.run_by_user)) != 0)
|
||||||
{
|
{
|
||||||
logCrit("exit abnormally!\n");
|
logCrit("exit abnormally!\n");
|
||||||
log_destroy();
|
log_destroy();
|
||||||
|
|
@ -423,34 +423,18 @@ static void sigAlarmHandler(int sig)
|
||||||
logDebug("file: "__FILE__", line: %d, " \
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
"signal server to quit...", __LINE__);
|
"signal server to quit...", __LINE__);
|
||||||
|
|
||||||
if (SF_G_IPV4_ENABLED)
|
if (*g_sf_context.inner_bind_addr != '\0')
|
||||||
{
|
{
|
||||||
server.af = AF_INET;
|
strcpy(server.ip_addr, g_sf_context.inner_bind_addr);
|
||||||
if (*SF_G_INNER_BIND_ADDR4 != '\0')
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, SF_G_INNER_BIND_ADDR4);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(server.ip_addr, LOCAL_LOOPBACK_IPv4);
|
strcpy(server.ip_addr, "127.0.0.1");
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server.af = AF_INET6;
|
|
||||||
if (*SF_G_INNER_BIND_ADDR6 != '\0')
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, SF_G_INNER_BIND_ADDR6);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(server.ip_addr, LOCAL_LOOPBACK_IPv6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
server.port = SF_G_INNER_PORT;
|
server.port = SF_G_INNER_PORT;
|
||||||
server.sock = -1;
|
server.sock = -1;
|
||||||
|
|
||||||
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT * 1000) != 0)
|
if (conn_pool_connect_server(&server, SF_G_CONNECT_TIMEOUT) != 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
"SF_G_CONTINUE_FLAG=%d\n"
|
"SF_G_CONTINUE_FLAG=%d\n"
|
||||||
"g_schedule_flag=%d\n"
|
"g_schedule_flag=%d\n"
|
||||||
"SF_G_INNER_PORT=%d\n"
|
"SF_G_INNER_PORT=%d\n"
|
||||||
"SF_G_MAX_CONNECTIONS=%d\n"
|
"g_max_connections=%d\n"
|
||||||
"g_tracker_thread_count=%d\n"
|
"g_tracker_thread_count=%d\n"
|
||||||
"g_sync_log_buff_interval=%ds\n"
|
"g_sync_log_buff_interval=%ds\n"
|
||||||
"g_check_active_interval=%ds\n"
|
"g_check_active_interval=%ds\n"
|
||||||
|
|
@ -352,7 +352,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, g_fdfs_version.patch, SF_G_CONTINUE_FLAG
|
, g_fdfs_version.patch, SF_G_CONTINUE_FLAG
|
||||||
, g_schedule_flag
|
, g_schedule_flag
|
||||||
, SF_G_INNER_PORT
|
, SF_G_INNER_PORT
|
||||||
, SF_G_MAX_CONNECTIONS
|
, g_sf_global_vars.max_connections
|
||||||
, g_sf_context.thread_count
|
, g_sf_context.thread_count
|
||||||
, g_sf_global_vars.error_log.sync_log_buff_interval
|
, g_sf_global_vars.error_log.sync_log_buff_interval
|
||||||
, g_check_active_interval
|
, g_check_active_interval
|
||||||
|
|
@ -361,8 +361,8 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
, fdfs_storage_reserved_space_to_string( \
|
, fdfs_storage_reserved_space_to_string( \
|
||||||
&g_storage_reserved_space, reserved_space_str) \
|
&g_storage_reserved_space, reserved_space_str) \
|
||||||
, g_allow_ip_count
|
, g_allow_ip_count
|
||||||
, g_sf_global_vars.run_by.group
|
, g_sf_global_vars.run_by_group
|
||||||
, g_sf_global_vars.run_by.user
|
, g_sf_global_vars.run_by_user
|
||||||
, g_storage_ip_changed_auto_adjust
|
, g_storage_ip_changed_auto_adjust
|
||||||
, SF_G_THREAD_STACK_SIZE
|
, SF_G_THREAD_STACK_SIZE
|
||||||
, g_if_use_trunk_file
|
, g_if_use_trunk_file
|
||||||
|
|
@ -444,8 +444,9 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
||||||
fdfs_server_info_to_string(pTrackerServer, ip_str, sizeof(ip_str));
|
fdfs_server_info_to_string(pTrackerServer, ip_str, sizeof(ip_str));
|
||||||
|
|
||||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||||
"\t%d. tracker server=%s\n", (int)(pTrackerServer -
|
"\t%d. tracker server=%s:%u\n", \
|
||||||
g_tracker_servers.servers) + 1, ip_str);
|
(int)(pTrackerServer - g_tracker_servers.servers) + 1, \
|
||||||
|
ip_str, pTrackerServer->connections[0].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_len;
|
return total_len;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ static int tracker_load_store_lookup(const char *filename, \
|
||||||
if (fdfs_validate_group_name(g_groups.store_group) != 0) \
|
if (fdfs_validate_group_name(g_groups.store_group) != 0) \
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"config file \"%s\", " \
|
"conf file \"%s\", " \
|
||||||
"the group name \"%s\" is invalid!", \
|
"the group name \"%s\" is invalid!", \
|
||||||
__LINE__, filename, g_groups.store_group);
|
__LINE__, filename, g_groups.store_group);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
@ -98,51 +98,34 @@ static int tracker_load_store_lookup(const char *filename, \
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tracker_load_storage_id_info(const char *config_filename,
|
static int tracker_load_storage_id_info(const char *config_filename, \
|
||||||
IniContext *iniContext)
|
IniContext *pItemContext)
|
||||||
{
|
{
|
||||||
char *pIdType;
|
char *pIdType;
|
||||||
|
|
||||||
g_use_storage_id = iniGetBoolValue(NULL, "use_storage_id",
|
g_use_storage_id = iniGetBoolValue(NULL, "use_storage_id", \
|
||||||
iniContext, false);
|
pItemContext, false);
|
||||||
if (!g_use_storage_id)
|
if (!g_use_storage_id)
|
||||||
{
|
{
|
||||||
if (SF_G_IPV6_ENABLED)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"config file: %s, use_storage_id MUST set to true "
|
|
||||||
"when IPv6 enabled!", __LINE__, config_filename);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pIdType = iniGetStrValue(NULL, "id_type_in_filename", iniContext);
|
pIdType = iniGetStrValue(NULL, "id_type_in_filename", \
|
||||||
|
pItemContext);
|
||||||
if (pIdType != NULL && strcasecmp(pIdType, "id") == 0)
|
if (pIdType != NULL && strcasecmp(pIdType, "id") == 0)
|
||||||
{
|
{
|
||||||
g_id_type_in_filename = FDFS_ID_TYPE_SERVER_ID;
|
g_id_type_in_filename = FDFS_ID_TYPE_SERVER_ID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SF_G_IPV6_ENABLED)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"config file: %s, id_type_in_filename MUST set to id "
|
|
||||||
"when IPv6 enabled!", __LINE__, config_filename);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
|
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_trust_storage_server_id = iniGetBoolValue(NULL,
|
return fdfs_load_storage_ids_from_file(config_filename, pItemContext);
|
||||||
"trust_storage_server_id", iniContext, true);
|
|
||||||
return fdfs_load_storage_ids_from_file(config_filename, iniContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tracker_load_from_conf_file(const char *filename)
|
int tracker_load_from_conf_file(const char *filename)
|
||||||
{
|
{
|
||||||
const int fixed_buffer_size = 0;
|
|
||||||
const int task_buffer_extra_size = 0;
|
const int task_buffer_extra_size = 0;
|
||||||
const bool need_set_run_by = false;
|
const bool need_set_run_by = false;
|
||||||
char *pSlotMinSize;
|
char *pSlotMinSize;
|
||||||
|
|
@ -188,11 +171,11 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
|
|
||||||
sf_set_current_time();
|
sf_set_current_time();
|
||||||
|
|
||||||
SF_SET_CONTEXT_INI_CONFIG_EX(config, fc_comm_type_sock, filename,
|
SF_SET_CONTEXT_INI_CONFIG_EX(config, filename, &iniContext,
|
||||||
&iniContext, NULL, FDFS_TRACKER_SERVER_DEF_PORT,
|
NULL, FDFS_TRACKER_SERVER_DEF_PORT,
|
||||||
FDFS_TRACKER_SERVER_DEF_PORT, DEFAULT_WORK_THREADS,
|
FDFS_TRACKER_SERVER_DEF_PORT, DEFAULT_WORK_THREADS,
|
||||||
"buff_size", 0);
|
"buff_size");
|
||||||
if ((result=sf_load_config_ex("trackerd", &config, fixed_buffer_size,
|
if ((result=sf_load_config_ex("trackerd", &config,
|
||||||
task_buffer_extra_size, need_set_run_by)) != 0)
|
task_buffer_extra_size, need_set_run_by)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -536,7 +519,6 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
"trunk_binlog_max_backups=%d, "
|
"trunk_binlog_max_backups=%d, "
|
||||||
"use_storage_id=%d, "
|
"use_storage_id=%d, "
|
||||||
"id_type_in_filename=%s, "
|
"id_type_in_filename=%s, "
|
||||||
"trust_storage_server_id=%d, "
|
|
||||||
"storage_id/ip_count=%d / %d, "
|
"storage_id/ip_count=%d / %d, "
|
||||||
"store_slave_file_use_link=%d, "
|
"store_slave_file_use_link=%d, "
|
||||||
"use_connection_pool=%d, "
|
"use_connection_pool=%d, "
|
||||||
|
|
@ -572,7 +554,6 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
g_trunk_binlog_max_backups,
|
g_trunk_binlog_max_backups,
|
||||||
g_use_storage_id, g_id_type_in_filename ==
|
g_use_storage_id, g_id_type_in_filename ==
|
||||||
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
|
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
|
||||||
g_trust_storage_server_id,
|
|
||||||
g_storage_ids_by_id.count, g_storage_ids_by_ip.count,
|
g_storage_ids_by_id.count, g_storage_ids_by_ip.count,
|
||||||
g_store_slave_file_use_link,
|
g_store_slave_file_use_link,
|
||||||
g_use_connection_pool, g_connection_pool_max_idle_time);
|
g_use_connection_pool, g_connection_pool_max_idle_time);
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@ FDFSStorageReservedSpace g_storage_reserved_space = { \
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB};
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB};
|
||||||
|
|
||||||
int g_allow_ip_count = 0;
|
int g_allow_ip_count = 0;
|
||||||
in_addr_64_t *g_allow_ip_addrs = NULL;
|
in_addr_t *g_allow_ip_addrs = NULL;
|
||||||
|
|
||||||
|
struct base64_context g_base64_context;
|
||||||
|
|
||||||
bool g_storage_ip_changed_auto_adjust = true;
|
bool g_storage_ip_changed_auto_adjust = true;
|
||||||
bool g_use_storage_id = false; //if use storage ID instead of IP address
|
bool g_use_storage_id = false; //if use storage ID instead of IP address
|
||||||
bool g_trust_storage_server_id = true;
|
|
||||||
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
|
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
|
||||||
|
|
||||||
int g_storage_sync_file_max_delay = DEFAULT_STORAGE_SYNC_FILE_MAX_DELAY;
|
int g_storage_sync_file_max_delay = DEFAULT_STORAGE_SYNC_FILE_MAX_DELAY;
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ extern FDFSStorageReservedSpace g_storage_reserved_space;
|
||||||
extern int g_check_active_interval; //check storage server alive every interval seconds
|
extern int g_check_active_interval; //check storage server alive every interval seconds
|
||||||
|
|
||||||
extern int g_allow_ip_count; /* -1 means match any ip address */
|
extern int g_allow_ip_count; /* -1 means match any ip address */
|
||||||
extern in_addr_64_t *g_allow_ip_addrs; /* sorted array, asc order */
|
extern in_addr_t *g_allow_ip_addrs; /* sorted array, asc order */
|
||||||
|
extern struct base64_context g_base64_context;
|
||||||
|
|
||||||
extern bool g_storage_ip_changed_auto_adjust;
|
extern bool g_storage_ip_changed_auto_adjust;
|
||||||
extern bool g_use_storage_id; //identify storage by ID instead of IP address
|
extern bool g_use_storage_id; //identify storage by ID instead of IP address
|
||||||
extern bool g_trust_storage_server_id;
|
|
||||||
extern byte g_id_type_in_filename; //id type of the storage server in the filename
|
extern byte g_id_type_in_filename; //id type of the storage server in the filename
|
||||||
|
|
||||||
extern int g_storage_sync_file_max_delay;
|
extern int g_storage_sync_file_max_delay;
|
||||||
|
|
|
||||||
|
|
@ -655,21 +655,18 @@ static int tracker_load_groups_new(FDFSGroups *pGroups, const char *data_path,
|
||||||
if (nStorageSyncSize <= *nTrunkServerCount)
|
if (nStorageSyncSize <= *nTrunkServerCount)
|
||||||
{
|
{
|
||||||
nStorageSyncSize += 8;
|
nStorageSyncSize += 8;
|
||||||
FDFSStorageSync *new_trunk_servers = (FDFSStorageSync *)
|
*ppTrunkServers = (FDFSStorageSync *)realloc( \
|
||||||
realloc(*ppTrunkServers, \
|
*ppTrunkServers, \
|
||||||
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
||||||
if (new_trunk_servers == NULL)
|
if (*ppTrunkServers == NULL)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : ENOMEM;
|
result = errno != 0 ? errno : ENOMEM;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"realloc %d bytes fail", __LINE__, \
|
"realloc %d bytes fail", __LINE__, \
|
||||||
(int)sizeof(FDFSStorageSync) * \
|
(int)sizeof(FDFSStorageSync) * \
|
||||||
nStorageSyncSize);
|
nStorageSyncSize);
|
||||||
free(*ppTrunkServers);
|
|
||||||
*ppTrunkServers = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*ppTrunkServers = new_trunk_servers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy((*ppTrunkServers)[*nTrunkServerCount].group_name, \
|
strcpy((*ppTrunkServers)[*nTrunkServerCount].group_name, \
|
||||||
|
|
@ -994,21 +991,18 @@ static int tracker_load_storages_old(FDFSGroups *pGroups, const char *data_path)
|
||||||
if (nStorageSyncSize <= nStorageSyncCount)
|
if (nStorageSyncSize <= nStorageSyncCount)
|
||||||
{
|
{
|
||||||
nStorageSyncSize += 8;
|
nStorageSyncSize += 8;
|
||||||
FDFSStorageSync *pNewStorageSyncs = (FDFSStorageSync *)
|
pStorageSyncs = (FDFSStorageSync *)realloc( \
|
||||||
realloc(pStorageSyncs, \
|
pStorageSyncs, \
|
||||||
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
||||||
if (pNewStorageSyncs == NULL)
|
if (pStorageSyncs == NULL)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : ENOMEM;
|
result = errno != 0 ? errno : ENOMEM;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"realloc %d bytes fail", __LINE__, \
|
"realloc %d bytes fail", __LINE__, \
|
||||||
(int)sizeof(FDFSStorageSync) * \
|
(int)sizeof(FDFSStorageSync) * \
|
||||||
nStorageSyncSize);
|
nStorageSyncSize);
|
||||||
free(pStorageSyncs);
|
|
||||||
pStorageSyncs = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pStorageSyncs = pNewStorageSyncs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pStorageSyncs[nStorageSyncCount].group_name, \
|
strcpy(pStorageSyncs[nStorageSyncCount].group_name, \
|
||||||
|
|
@ -1280,21 +1274,18 @@ static int tracker_load_storages_new(FDFSGroups *pGroups, const char *data_path)
|
||||||
{
|
{
|
||||||
nStorageSyncSize *= 2;
|
nStorageSyncSize *= 2;
|
||||||
}
|
}
|
||||||
FDFSStorageSync *pNewStorageSyncs = (FDFSStorageSync *)
|
pStorageSyncs = (FDFSStorageSync *)realloc( \
|
||||||
realloc(pStorageSyncs, \
|
pStorageSyncs, \
|
||||||
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
sizeof(FDFSStorageSync) * nStorageSyncSize);
|
||||||
if (pNewStorageSyncs == NULL)
|
if (pStorageSyncs == NULL)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : ENOMEM;
|
result = errno != 0 ? errno : ENOMEM;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"realloc %d bytes fail", __LINE__, \
|
"realloc %d bytes fail", __LINE__, \
|
||||||
(int)sizeof(FDFSStorageSync) * \
|
(int)sizeof(FDFSStorageSync) * \
|
||||||
nStorageSyncSize);
|
nStorageSyncSize);
|
||||||
free(pStorageSyncs);
|
|
||||||
pStorageSyncs = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pStorageSyncs = pNewStorageSyncs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pStorageSyncs[nStorageSyncCount].group_name, \
|
strcpy(pStorageSyncs[nStorageSyncCount].group_name, \
|
||||||
|
|
@ -1787,7 +1778,6 @@ int tracker_save_storages()
|
||||||
char trueFilename[MAX_PATH_SIZE];
|
char trueFilename[MAX_PATH_SIZE];
|
||||||
char buff[4096];
|
char buff[4096];
|
||||||
char id_buff[128];
|
char id_buff[128];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int fd;
|
int fd;
|
||||||
int len;
|
int len;
|
||||||
FDFSGroupInfo **ppGroup;
|
FDFSGroupInfo **ppGroup;
|
||||||
|
|
@ -1839,7 +1829,6 @@ int tracker_save_storages()
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
format_ip_address(FDFS_CURRENT_IP_ADDR(pStorage), formatted_ip);
|
|
||||||
len = sprintf(buff, \
|
len = sprintf(buff, \
|
||||||
"# storage %s:%u\n" \
|
"# storage %s:%u\n" \
|
||||||
"[%s"STORAGE_SECTION_NO_FORMAT"]\n" \
|
"[%s"STORAGE_SECTION_NO_FORMAT"]\n" \
|
||||||
|
|
@ -1896,7 +1885,8 @@ int tracker_save_storages()
|
||||||
"\t%s=%d\n" \
|
"\t%s=%d\n" \
|
||||||
"\t%s=%d\n" \
|
"\t%s=%d\n" \
|
||||||
"\t%s=%"PRId64"\n\n", \
|
"\t%s=%"PRId64"\n\n", \
|
||||||
formatted_ip, pStorage->storage_port, \
|
FDFS_CURRENT_IP_ADDR(pStorage), \
|
||||||
|
pStorage->storage_port, \
|
||||||
STORAGE_SECTION_NAME_PREFIX, count, id_buff, \
|
STORAGE_SECTION_NAME_PREFIX, count, id_buff, \
|
||||||
STORAGE_ITEM_GROUP_NAME, \
|
STORAGE_ITEM_GROUP_NAME, \
|
||||||
(*ppGroup)->group_name, \
|
(*ppGroup)->group_name, \
|
||||||
|
|
@ -3181,17 +3171,9 @@ static FDFSStorageDetail *tracker_mem_get_active_http_server_by_ip( \
|
||||||
|
|
||||||
memset(&target_storage, 0, sizeof(target_storage));
|
memset(&target_storage, 0, sizeof(target_storage));
|
||||||
if (!g_use_storage_id)
|
if (!g_use_storage_id)
|
||||||
{
|
|
||||||
// 当IP地址为IPv6时,其storage_id值为IP地址的short code
|
|
||||||
if (is_ipv6_addr(ip_addr))
|
|
||||||
{
|
|
||||||
fdfs_ip_to_shortcode(ip_addr, target_storage.id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
strcpy(target_storage.id, ip_addr);
|
strcpy(target_storage.id, ip_addr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FDFSStorageIdInfo *pStorageId;
|
FDFSStorageIdInfo *pStorageId;
|
||||||
|
|
@ -3248,7 +3230,7 @@ static FDFSStorageDetail *tracker_mem_get_active_http_server_by_id( \
|
||||||
FDFSStorageDetail *tracker_mem_get_storage_by_ip(FDFSGroupInfo *pGroup, \
|
FDFSStorageDetail *tracker_mem_get_storage_by_ip(FDFSGroupInfo *pGroup, \
|
||||||
const char *ip_addr)
|
const char *ip_addr)
|
||||||
{
|
{
|
||||||
FDFSStorageId storage_id;
|
const char *storage_id;
|
||||||
|
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
{
|
{
|
||||||
|
|
@ -3259,23 +3241,14 @@ FDFSStorageDetail *tracker_mem_get_storage_by_ip(FDFSGroupInfo *pGroup, \
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
storage_id.ptr = pStorageIdInfo->id;
|
storage_id = pStorageIdInfo->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 当IP地址为IPv6时,其storage_id值为IP地址的short code
|
storage_id = ip_addr;
|
||||||
if (is_ipv6_addr(ip_addr))
|
|
||||||
{
|
|
||||||
storage_id.ptr = fdfs_ip_to_shortcode(ip_addr,
|
|
||||||
storage_id.holder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage_id.ptr = (char *)ip_addr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tracker_mem_get_storage(pGroup, storage_id.ptr);
|
return tracker_mem_get_storage(pGroup, storage_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
FDFSStorageDetail *tracker_mem_get_storage(FDFSGroupInfo *pGroup, \
|
FDFSStorageDetail *tracker_mem_get_storage(FDFSGroupInfo *pGroup, \
|
||||||
|
|
@ -3416,7 +3389,6 @@ int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id)
|
||||||
FDFSStorageDetail *pStorageServer;
|
FDFSStorageDetail *pStorageServer;
|
||||||
FDFSStorageDetail **ppServer;
|
FDFSStorageDetail **ppServer;
|
||||||
FDFSStorageDetail **ppEnd;
|
FDFSStorageDetail **ppEnd;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
pStorageServer = tracker_mem_get_storage(pGroup, id);
|
pStorageServer = tracker_mem_get_storage(pGroup, id);
|
||||||
if (pStorageServer == NULL || pStorageServer->status == \
|
if (pStorageServer == NULL || pStorageServer->status == \
|
||||||
|
|
@ -3447,14 +3419,10 @@ int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(pStorageServer->ip_addrs.
|
|
||||||
ips[0].address, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"delete storage server: %s:%u, group: %s", __LINE__,
|
"delete storage server: %s:%u, group: %s",
|
||||||
formatted_ip, pStorageServer->storage_port,
|
__LINE__, pStorageServer->ip_addrs.ips[0].address,
|
||||||
pGroup->group_name);
|
pStorageServer->storage_port, pGroup->group_name);
|
||||||
}
|
|
||||||
|
|
||||||
tracker_mem_clear_storage_fields(pStorageServer);
|
tracker_mem_clear_storage_fields(pStorageServer);
|
||||||
|
|
||||||
|
|
@ -3465,7 +3433,7 @@ int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tracker_mem_storage_ip_changed(FDFSGroupInfo *pGroup,
|
int tracker_mem_storage_ip_changed(FDFSGroupInfo *pGroup, \
|
||||||
const char *old_storage_ip, const char *new_storage_ip)
|
const char *old_storage_ip, const char *new_storage_ip)
|
||||||
{
|
{
|
||||||
FDFSStorageDetail *pOldStorageServer;
|
FDFSStorageDetail *pOldStorageServer;
|
||||||
|
|
@ -3574,8 +3542,8 @@ static int tracker_mem_add_storage(TrackerClientInfo *pClientInfo,
|
||||||
FDFSStorageDetail *pStorageServer;
|
FDFSStorageDetail *pStorageServer;
|
||||||
|
|
||||||
pStorageServer = NULL;
|
pStorageServer = NULL;
|
||||||
result = _tracker_mem_add_storage(pClientInfo->pGroup,
|
result = _tracker_mem_add_storage(pClientInfo->pGroup, \
|
||||||
&pStorageServer, id, ip_addr, bNeedSleep,
|
&pStorageServer, id, ip_addr, bNeedSleep, \
|
||||||
bNeedLock, bInserted);
|
bNeedLock, bInserted);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3673,7 +3641,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||||
const bool bNeedLock, bool *bInserted)
|
const bool bNeedLock, bool *bInserted)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
FDFSStorageId storage_id;
|
const char *storage_id;
|
||||||
FDFSStorageIdInfo *pStorageIdInfo;
|
FDFSStorageIdInfo *pStorageIdInfo;
|
||||||
FDFSMultiIP multi_ip;
|
FDFSMultiIP multi_ip;
|
||||||
|
|
||||||
|
|
@ -3721,7 +3689,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||||
multi_ip = pStorageIdInfo->ip_addrs;
|
multi_ip = pStorageIdInfo->ip_addrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage_id.ptr = (char *)id;
|
storage_id = id;
|
||||||
}
|
}
|
||||||
else if (g_use_storage_id)
|
else if (g_use_storage_id)
|
||||||
{
|
{
|
||||||
|
|
@ -3737,19 +3705,11 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||||
}
|
}
|
||||||
|
|
||||||
multi_ip = pStorageIdInfo->ip_addrs;
|
multi_ip = pStorageIdInfo->ip_addrs;
|
||||||
storage_id.ptr = pStorageIdInfo->id;
|
storage_id = pStorageIdInfo->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 当IP地址为IPv6时,其storage_id值为IP地址的short code
|
storage_id = ip_addr;
|
||||||
if (is_ipv6_addr(ip_addr))
|
|
||||||
{
|
|
||||||
storage_id.ptr = fdfs_ip_to_shortcode(ip_addr, storage_id.holder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage_id.ptr = (char *)ip_addr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNeedLock && (result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
if (bNeedLock && (result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
||||||
|
|
@ -3765,7 +3725,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||||
{
|
{
|
||||||
result = 0;
|
result = 0;
|
||||||
*bInserted = false;
|
*bInserted = false;
|
||||||
*ppStorageServer = tracker_mem_get_storage(pGroup, storage_id.ptr);
|
*ppStorageServer = tracker_mem_get_storage(pGroup, storage_id);
|
||||||
if (*ppStorageServer != NULL)
|
if (*ppStorageServer != NULL)
|
||||||
{
|
{
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
|
|
@ -3794,7 +3754,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
||||||
|
|
||||||
*ppStorageServer = *(pGroup->all_servers + pGroup->count);
|
*ppStorageServer = *(pGroup->all_servers + pGroup->count);
|
||||||
snprintf((*ppStorageServer)->id, FDFS_STORAGE_ID_MAX_SIZE,
|
snprintf((*ppStorageServer)->id, FDFS_STORAGE_ID_MAX_SIZE,
|
||||||
"%s", storage_id.ptr);
|
"%s", storage_id);
|
||||||
(*ppStorageServer)->ip_addrs = multi_ip;
|
(*ppStorageServer)->ip_addrs = multi_ip;
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
{
|
{
|
||||||
|
|
@ -3846,7 +3806,6 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + 1 + FDFS_PROTO_PKG_LEN_SIZE];
|
char out_buff[sizeof(TrackerHeader) + 1 + FDFS_PROTO_PKG_LEN_SIZE];
|
||||||
char in_buff[TRACKER_MAX_PACKAGE_SIZE];
|
char in_buff[TRACKER_MAX_PACKAGE_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char *p;
|
char *p;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
|
|
@ -3866,12 +3825,13 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
||||||
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"send data to tracker server %s:%u fail, " \
|
||||||
"send data to tracker server %s:%u fail, "
|
"errno: %d, error info: %s", __LINE__, \
|
||||||
"errno: %d, error info: %s", __LINE__,
|
pTrackerServer->ip_addr, \
|
||||||
formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
return (result == ENOENT ? EACCES : result);
|
return (result == ENOENT ? EACCES : result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3888,12 +3848,11 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (in_bytes < FDFS_PROTO_PKG_LEN_SIZE)
|
if (in_bytes < FDFS_PROTO_PKG_LEN_SIZE)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u response data " \
|
||||||
"tracker server %s:%u response data "
|
"length: %"PRId64" is invalid, " \
|
||||||
"length: %"PRId64" is invalid, "
|
"expect length >= %d.", __LINE__, \
|
||||||
"expect length >= %d.", __LINE__,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
formatted_ip, pTrackerServer->port,
|
|
||||||
in_bytes, FDFS_PROTO_PKG_LEN_SIZE);
|
in_bytes, FDFS_PROTO_PKG_LEN_SIZE);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -3903,21 +3862,20 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (*file_size < 0)
|
if (*file_size < 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, file size: %"PRId64\
|
||||||
"tracker server %s:%u, file size: %"PRId64
|
" < 0", __LINE__, pTrackerServer->ip_addr, \
|
||||||
" < 0", __LINE__, formatted_ip,
|
|
||||||
pTrackerServer->port, *file_size);
|
pTrackerServer->port, *file_size);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*file_size > 0 && write_bytes == 0)
|
if (*file_size > 0 && write_bytes == 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, file size: %"PRId64\
|
||||||
"tracker server %s:%u, file size: %"PRId64
|
" > 0, but file content is empty", __LINE__, \
|
||||||
" > 0, but file content is empty", __LINE__,
|
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||||
formatted_ip, pTrackerServer->port, *file_size);
|
*file_size);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4276,7 +4234,6 @@ static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
||||||
TrackerServerInfo *pTrackerEnd;
|
TrackerServerInfo *pTrackerEnd;
|
||||||
TrackerRunningStatus *pStatus;
|
TrackerRunningStatus *pStatus;
|
||||||
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int count;
|
int count;
|
||||||
int result;
|
int result;
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -4318,20 +4275,17 @@ static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
||||||
tracker_mem_cmp_tracker_running_status);
|
tracker_mem_cmp_tracker_running_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
for (i=0; i<count; i++)
|
for (i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
format_ip_address(trackerStatus[i].pTrackerServer->
|
|
||||||
connections[0].ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"%s:%u leader: %d, running time: %d, "
|
"%s:%u leader: %d, running time: %d, "
|
||||||
"restart interval: %d", __LINE__, formatted_ip,
|
"restart interval: %d", __LINE__,
|
||||||
|
trackerStatus[i].pTrackerServer->connections[0].ip_addr,
|
||||||
trackerStatus[i].pTrackerServer->connections[0].port,
|
trackerStatus[i].pTrackerServer->connections[0].port,
|
||||||
trackerStatus[i].if_leader,
|
trackerStatus[i].if_leader,
|
||||||
trackerStatus[i].running_time,
|
trackerStatus[i].running_time,
|
||||||
trackerStatus[i].restart_interval);
|
trackerStatus[i].restart_interval);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//copy the last
|
//copy the last
|
||||||
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
||||||
|
|
@ -4347,7 +4301,6 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
||||||
TrackerServerInfo *pTrackerServer;
|
TrackerServerInfo *pTrackerServer;
|
||||||
FDFSGroups newGroups;
|
FDFSGroups newGroups;
|
||||||
FDFSGroups tempGroups;
|
FDFSGroups tempGroups;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if (pJoinBody->tracker_count == 0)
|
if (pJoinBody->tracker_count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -4365,12 +4318,11 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
||||||
if (tracker_mem_cmp_tracker_running_status(pRunningStatus,
|
if (tracker_mem_cmp_tracker_running_status(pRunningStatus,
|
||||||
&trackerStatus) >= 0)
|
&trackerStatus) >= 0)
|
||||||
{
|
{
|
||||||
format_ip_address(trackerStatus.pTrackerServer->
|
|
||||||
connections[0].ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
logDebug("file: "__FILE__", line: %d, "
|
||||||
"%s:%u running time: %d, restart interval: %d, "
|
"%s:%u running time: %d, restart interval: %d, "
|
||||||
"my running time: %d, restart interval: %d, "
|
"my running time: %d, restart interval: %d, "
|
||||||
"do not need sync system files", __LINE__, formatted_ip,
|
"do not need sync system files", __LINE__,
|
||||||
|
trackerStatus.pTrackerServer->connections[0].ip_addr,
|
||||||
trackerStatus.pTrackerServer->connections[0].port,
|
trackerStatus.pTrackerServer->connections[0].port,
|
||||||
trackerStatus.running_time,
|
trackerStatus.running_time,
|
||||||
trackerStatus.restart_interval,
|
trackerStatus.restart_interval,
|
||||||
|
|
@ -4388,10 +4340,10 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(pTrackerServer->connections[0].ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"sys files loaded from tracker server %s:%u", __LINE__,
|
"sys files loaded from tracker server %s:%u",
|
||||||
formatted_ip, pTrackerServer->connections[0].port);
|
__LINE__, pTrackerServer->connections[0].ip_addr,
|
||||||
|
pTrackerServer->connections[0].port);
|
||||||
|
|
||||||
memset(&newGroups, 0, sizeof(newGroups));
|
memset(&newGroups, 0, sizeof(newGroups));
|
||||||
newGroups.store_lookup = g_groups.store_lookup;
|
newGroups.store_lookup = g_groups.store_lookup;
|
||||||
|
|
@ -4422,8 +4374,8 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
||||||
return tracker_open_changlog_file();
|
return tracker_open_changlog_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
|
||||||
const char *ip_addr, FDFSStorageJoinBody *pJoinBody,
|
const char *ip_addr, FDFSStorageJoinBody *pJoinBody, \
|
||||||
const bool bNeedSleep)
|
const bool bNeedSleep)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -4432,8 +4384,8 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
FDFSStorageDetail *pStorageServer;
|
FDFSStorageDetail *pStorageServer;
|
||||||
FDFSStorageDetail **ppServer;
|
FDFSStorageDetail **ppServer;
|
||||||
FDFSStorageDetail **ppEnd;
|
FDFSStorageDetail **ppEnd;
|
||||||
FDFSStorageId storage_id;
|
FDFSStorageIdInfo *pStorageIdInfo;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
const char *storage_id;
|
||||||
|
|
||||||
tracker_mem_file_lock();
|
tracker_mem_file_lock();
|
||||||
|
|
||||||
|
|
@ -4503,7 +4455,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
|
|
||||||
tracker_mem_file_unlock();
|
tracker_mem_file_unlock();
|
||||||
|
|
||||||
if ((result=tracker_mem_add_group_ex(&g_groups, pClientInfo,
|
if ((result=tracker_mem_add_group_ex(&g_groups, pClientInfo, \
|
||||||
pJoinBody->group_name, bNeedSleep, &bGroupInserted)) != 0)
|
pJoinBody->group_name, bNeedSleep, &bGroupInserted)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -4518,46 +4470,23 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
{
|
|
||||||
FDFSStorageIdInfo *pStorageIdInfo;
|
|
||||||
|
|
||||||
if (g_trust_storage_server_id && *(pJoinBody->storage_id) != '\0')
|
|
||||||
{
|
|
||||||
pStorageIdInfo = fdfs_get_storage_by_id(pJoinBody->storage_id);
|
|
||||||
if (pStorageIdInfo == NULL)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
|
||||||
"get storage id info fail, storage id: %s",
|
|
||||||
__LINE__, pJoinBody->storage_id);
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
pStorageIdInfo = fdfs_get_storage_id_by_ip(
|
pStorageIdInfo = fdfs_get_storage_id_by_ip(
|
||||||
pClientInfo->pGroup->group_name, ip_addr);
|
pClientInfo->pGroup->group_name, ip_addr);
|
||||||
if (pStorageIdInfo == NULL)
|
if (pStorageIdInfo == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, " \
|
||||||
"get storage id info fail, group_name: %s, "
|
"get storage id info fail, group_name: %s, " \
|
||||||
"storage ip: %s", __LINE__,
|
"storage ip: %s", __LINE__, \
|
||||||
pClientInfo->pGroup->group_name, ip_addr);
|
pClientInfo->pGroup->group_name, ip_addr);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
}
|
storage_id = pStorageIdInfo->id;
|
||||||
storage_id.ptr = pStorageIdInfo->id;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 当IP地址为IPv6时,其storage_id值为IP地址的short code
|
pStorageIdInfo = NULL;
|
||||||
if (is_ipv6_addr(ip_addr))
|
storage_id = ip_addr;
|
||||||
{
|
|
||||||
storage_id.ptr = fdfs_ip_to_shortcode(ip_addr, storage_id.holder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage_id.ptr = (char *)ip_addr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pClientInfo->pGroup->storage_port == 0)
|
if (pClientInfo->pGroup->storage_port == 0)
|
||||||
|
|
@ -4578,7 +4507,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
for (ppServer=pClientInfo->pGroup->all_servers; \
|
for (ppServer=pClientInfo->pGroup->all_servers; \
|
||||||
ppServer<ppEnd; ppServer++)
|
ppServer<ppEnd; ppServer++)
|
||||||
{
|
{
|
||||||
if (strcmp((*ppServer)->id, storage_id.ptr) == 0)
|
if (strcmp((*ppServer)->id, storage_id) == 0)
|
||||||
{
|
{
|
||||||
(*ppServer)->storage_port = \
|
(*ppServer)->storage_port = \
|
||||||
pJoinBody->storage_port;
|
pJoinBody->storage_port;
|
||||||
|
|
@ -4636,7 +4565,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
for (ppServer=pClientInfo->pGroup->all_servers; \
|
for (ppServer=pClientInfo->pGroup->all_servers; \
|
||||||
ppServer<ppEnd; ppServer++)
|
ppServer<ppEnd; ppServer++)
|
||||||
{
|
{
|
||||||
if (strcmp((*ppServer)->id, storage_id.ptr) == 0)
|
if (strcmp((*ppServer)->id, storage_id) == 0)
|
||||||
{
|
{
|
||||||
(*ppServer)->storage_http_port = \
|
(*ppServer)->storage_http_port = \
|
||||||
pJoinBody->storage_http_port;
|
pJoinBody->storage_http_port;
|
||||||
|
|
@ -4686,8 +4615,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
pStorageServer = tracker_mem_get_storage(pClientInfo->pGroup,
|
pStorageServer = tracker_mem_get_storage(pClientInfo->pGroup, storage_id);
|
||||||
storage_id.ptr);
|
|
||||||
if (pthread_mutex_unlock(&mem_thread_lock) != 0)
|
if (pthread_mutex_unlock(&mem_thread_lock) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -4704,21 +4632,20 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
||||||
pJoinBody->status == FDFS_STORAGE_STATUS_IP_CHANGED || \
|
pJoinBody->status == FDFS_STORAGE_STATUS_IP_CHANGED || \
|
||||||
pJoinBody->status == FDFS_STORAGE_STATUS_NONE)
|
pJoinBody->status == FDFS_STORAGE_STATUS_NONE)
|
||||||
{
|
{
|
||||||
format_ip_address(ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"client ip: %s:%u, invalid storage " \
|
||||||
"client ip: %s:%u, invalid storage "
|
"status %d, in the group \"%s\"", \
|
||||||
"status %d, in the group \"%s\"",
|
__LINE__, ip_addr, \
|
||||||
__LINE__, formatted_ip,
|
pJoinBody->storage_port, \
|
||||||
pJoinBody->storage_port,
|
pJoinBody->status, \
|
||||||
pJoinBody->status,
|
|
||||||
pJoinBody->group_name);
|
pJoinBody->group_name);
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tracker_mem_add_storage(pClientInfo, storage_id.ptr,
|
if ((result=tracker_mem_add_storage(pClientInfo, storage_id, ip_addr,
|
||||||
ip_addr, bNeedSleep, true, &bStorageInserted)) != 0)
|
bNeedSleep, true, &bStorageInserted)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -4907,7 +4834,6 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageDetail target_storage;
|
FDFSStorageDetail target_storage;
|
||||||
FDFSStorageDetail *pTargetStorage;
|
FDFSStorageDetail *pTargetStorage;
|
||||||
FDFSStorageDetail **ppFound;
|
FDFSStorageDetail **ppFound;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if ((result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
if ((result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -4955,12 +4881,11 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(FDFS_CURRENT_IP_ADDR(*ppFound),
|
|
||||||
formatted_ip);
|
|
||||||
logWarning("file: "__FILE__", line: %d, "
|
logWarning("file: "__FILE__", line: %d, "
|
||||||
"storage server: %s:%u, dest status: %d, "
|
"storage server: %s:%u, dest status: %d, "
|
||||||
"my status: %d, should change my status!",
|
"my status: %d, should change my status!",
|
||||||
__LINE__, formatted_ip, (*ppFound)->storage_port,
|
__LINE__, FDFS_CURRENT_IP_ADDR(*ppFound),
|
||||||
|
(*ppFound)->storage_port,
|
||||||
pServer->status, (*ppFound)->status);
|
pServer->status, (*ppFound)->status);
|
||||||
|
|
||||||
if (pServer->status == \
|
if (pServer->status == \
|
||||||
|
|
@ -5054,7 +4979,6 @@ static int _storage_get_trunk_binlog_size(
|
||||||
ConnectionInfo *pStorageServer, int64_t *file_size)
|
ConnectionInfo *pStorageServer, int64_t *file_size)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader)];
|
char out_buff[sizeof(TrackerHeader)];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[8];
|
char in_buff[8];
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
|
|
@ -5067,11 +4991,11 @@ static int _storage_get_trunk_binlog_size(
|
||||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u, send data fail, " \
|
||||||
"storage server %s:%u, send data fail, "
|
"errno: %d, error info: %s.", \
|
||||||
"errno: %d, error info: %s.", __LINE__,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
formatted_ip, pStorageServer->port,
|
pStorageServer->port, \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -5088,10 +5012,10 @@ static int _storage_get_trunk_binlog_size(
|
||||||
|
|
||||||
if (in_bytes != sizeof(in_buff))
|
if (in_bytes != sizeof(in_buff))
|
||||||
{
|
{
|
||||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"storage server %s:%u, recv body length: " \
|
||||||
"storage server %s:%u, recv body length: "
|
"%"PRId64" != %d", \
|
||||||
"%"PRId64" != %d", __LINE__, formatted_ip,
|
__LINE__, pStorageServer->ip_addr, \
|
||||||
pStorageServer->port, in_bytes, (int)sizeof(in_buff));
|
pStorageServer->port, in_bytes, (int)sizeof(in_buff));
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -5105,7 +5029,6 @@ static int tracker_mem_get_trunk_binlog_size(
|
||||||
{
|
{
|
||||||
ConnectionInfo storage_server;
|
ConnectionInfo storage_server;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
*file_size = 0;
|
*file_size = 0;
|
||||||
|
|
@ -5120,13 +5043,11 @@ static int tracker_mem_get_trunk_binlog_size(
|
||||||
result = _storage_get_trunk_binlog_size(conn, file_size);
|
result = _storage_get_trunk_binlog_size(conn, file_size);
|
||||||
tracker_close_connection_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
format_ip_address(storage_server.ip_addr, formatted_ip);
|
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
|
||||||
"storage %s:%u, trunk binlog file size: %"PRId64,
|
|
||||||
__LINE__, formatted_ip, storage_server.port, *file_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
|
"storage %s:%u, trunk binlog file size: %"PRId64, \
|
||||||
|
__LINE__, storage_server.ip_addr, storage_server.port, \
|
||||||
|
*file_size);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5262,7 +5183,6 @@ static int tracker_set_trunk_server_and_log(FDFSGroupInfo *pGroup, \
|
||||||
static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
||||||
FDFSStorageDetail *pTrunkServer, const bool save)
|
FDFSStorageDetail *pTrunkServer, const bool save)
|
||||||
{
|
{
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (*(pGroup->last_trunk_server_id) != '\0' &&
|
if (*(pGroup->last_trunk_server_id) != '\0' &&
|
||||||
|
|
@ -5284,12 +5204,11 @@ static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
||||||
pGroup->trunk_chg_count++;
|
pGroup->trunk_chg_count++;
|
||||||
g_trunk_server_chg_count++;
|
g_trunk_server_chg_count++;
|
||||||
|
|
||||||
format_ip_address(FDFS_CURRENT_IP_ADDR(pGroup->
|
|
||||||
pTrunkServer), formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"group: %s, trunk server set to %s(%s:%u)", __LINE__,
|
"group: %s, trunk server set to %s(%s:%u)", __LINE__,
|
||||||
pGroup->group_name, pGroup->pTrunkServer->id,
|
pGroup->group_name, pGroup->pTrunkServer->id,
|
||||||
formatted_ip, pGroup->storage_port);
|
FDFS_CURRENT_IP_ADDR(pGroup->pTrunkServer),
|
||||||
|
pGroup->storage_port);
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
return tracker_save_groups();
|
return tracker_save_groups();
|
||||||
|
|
@ -5721,7 +5640,7 @@ int tracker_mem_get_storage_by_filename(const byte cmd,FDFS_DOWNLOAD_TYPE_PARAM\
|
||||||
char name_buff[64];
|
char name_buff[64];
|
||||||
int decoded_len;
|
int decoded_len;
|
||||||
|
|
||||||
base64_decode_auto(&g_fdfs_base64_context, (char *)filename + \
|
base64_decode_auto(&g_base64_context, (char *)filename + \
|
||||||
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
FDFS_LOGIC_FILE_PATH_LEN, FDFS_FILENAME_BASE64_LENGTH, \
|
||||||
name_buff, &decoded_len);
|
name_buff, &decoded_len);
|
||||||
storage_ip = ntohl(buff2int(name_buff));
|
storage_ip = ntohl(buff2int(name_buff));
|
||||||
|
|
@ -6132,7 +6051,6 @@ int tracker_mem_check_alive(void *arg)
|
||||||
FDFSGroupInfo **ppGroup;
|
FDFSGroupInfo **ppGroup;
|
||||||
FDFSGroupInfo **ppGroupEnd;
|
FDFSGroupInfo **ppGroupEnd;
|
||||||
FDFSStorageDetail *deactiveServers[FDFS_MAX_SERVERS_EACH_GROUP];
|
FDFSStorageDetail *deactiveServers[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int deactiveCount;
|
int deactiveCount;
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
|
|
||||||
|
|
@ -6164,7 +6082,6 @@ int tracker_mem_check_alive(void *arg)
|
||||||
ppServerEnd = deactiveServers + deactiveCount;
|
ppServerEnd = deactiveServers + deactiveCount;
|
||||||
for (ppServer=deactiveServers; ppServer<ppServerEnd; ppServer++)
|
for (ppServer=deactiveServers; ppServer<ppServerEnd; ppServer++)
|
||||||
{
|
{
|
||||||
format_ip_address(FDFS_CURRENT_IP_ADDR(*ppServer), formatted_ip);
|
|
||||||
(*ppServer)->status = FDFS_STORAGE_STATUS_OFFLINE;
|
(*ppServer)->status = FDFS_STORAGE_STATUS_OFFLINE;
|
||||||
tracker_mem_deactive_store_server(*ppGroup, *ppServer);
|
tracker_mem_deactive_store_server(*ppGroup, *ppServer);
|
||||||
if (g_use_storage_id)
|
if (g_use_storage_id)
|
||||||
|
|
@ -6172,7 +6089,7 @@ int tracker_mem_check_alive(void *arg)
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"storage server %s(%s:%u) idle too long, "
|
"storage server %s(%s:%u) idle too long, "
|
||||||
"status change to offline!", __LINE__,
|
"status change to offline!", __LINE__,
|
||||||
(*ppServer)->id, formatted_ip,
|
(*ppServer)->id, FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||||
(*ppGroup)->storage_port);
|
(*ppGroup)->storage_port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -6180,7 +6097,8 @@ int tracker_mem_check_alive(void *arg)
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"storage server %s:%u idle too long, "
|
"storage server %s:%u idle too long, "
|
||||||
"status change to offline!", __LINE__,
|
"status change to offline!", __LINE__,
|
||||||
formatted_ip, (*ppGroup)->storage_port);
|
FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||||
|
(*ppGroup)->storage_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6226,13 +6144,12 @@ int tracker_mem_check_alive(void *arg)
|
||||||
g_check_active_interval;
|
g_check_active_interval;
|
||||||
if (last_beat_interval > check_trunk_interval)
|
if (last_beat_interval > check_trunk_interval)
|
||||||
{
|
{
|
||||||
format_ip_address(FDFS_CURRENT_IP_ADDR((*ppGroup)->
|
|
||||||
pTrunkServer), formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"trunk server %s(%s:%u) offline because idle "
|
"trunk server %s(%s:%u) offline because idle "
|
||||||
"time: %d s > threshold: %d s, should "
|
"time: %d s > threshold: %d s, should "
|
||||||
"re-select trunk server", __LINE__,
|
"re-select trunk server", __LINE__,
|
||||||
(*ppGroup)->pTrunkServer->id, formatted_ip,
|
(*ppGroup)->pTrunkServer->id,
|
||||||
|
FDFS_CURRENT_IP_ADDR((*ppGroup)->pTrunkServer),
|
||||||
(*ppGroup)->storage_port, last_beat_interval,
|
(*ppGroup)->storage_port, last_beat_interval,
|
||||||
check_trunk_interval);
|
check_trunk_interval);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,16 +59,16 @@ FDFSStorageDetail *tracker_mem_get_storage(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageDetail *tracker_mem_get_storage_by_ip(FDFSGroupInfo *pGroup, \
|
FDFSStorageDetail *tracker_mem_get_storage_by_ip(FDFSGroupInfo *pGroup, \
|
||||||
const char *ip_addr);
|
const char *ip_addr);
|
||||||
|
|
||||||
const FDFSStorageDetail *tracker_mem_set_trunk_server(
|
const FDFSStorageDetail *tracker_mem_set_trunk_server( \
|
||||||
FDFSGroupInfo *pGroup, const char *pStroageId, int *result);
|
FDFSGroupInfo *pGroup, const char *pStroageId, int *result);
|
||||||
int tracker_mem_delete_group(const char *group_name);
|
int tracker_mem_delete_group(const char *group_name);
|
||||||
int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id);
|
int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id);
|
||||||
|
|
||||||
int tracker_mem_storage_ip_changed(FDFSGroupInfo *pGroup,
|
int tracker_mem_storage_ip_changed(FDFSGroupInfo *pGroup, \
|
||||||
const char *old_storage_ip, const char *new_storage_ip);
|
const char *old_storage_ip, const char *new_storage_ip);
|
||||||
|
|
||||||
int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
|
||||||
const char *ip_addr, FDFSStorageJoinBody *pJoinBody,
|
const char *ip_addr, FDFSStorageJoinBody *pJoinBody, \
|
||||||
const bool bNeedSleep);
|
const bool bNeedSleep);
|
||||||
|
|
||||||
int tracker_mem_offline_store_server(FDFSGroupInfo *pGroup, \
|
int tracker_mem_offline_store_server(FDFSGroupInfo *pGroup, \
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,12 @@
|
||||||
|
|
||||||
int fdfs_set_body_length(struct fast_task_info *pTask)
|
int fdfs_set_body_length(struct fast_task_info *pTask)
|
||||||
{
|
{
|
||||||
pTask->recv.ptr->length = buff2long(((TrackerHeader *)
|
pTask->length = buff2long(((TrackerHeader *)pTask->data)->pkg_len);
|
||||||
pTask->recv.ptr->data)->pkg_len);
|
if (pTask->length < 0)
|
||||||
if (pTask->recv.ptr->length < 0)
|
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"client ip: %s, pkg length: %d < 0", __LINE__,
|
"client ip: %s, pkg length: %d < 0",
|
||||||
pTask->client_ip, pTask->recv.ptr->length);
|
__LINE__, pTask->client_ip, pTask->length);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,16 +42,16 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
||||||
const int network_timeout, int64_t *in_bytes)
|
const int network_timeout, int64_t *in_bytes)
|
||||||
{
|
{
|
||||||
TrackerHeader resp;
|
TrackerHeader resp;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if ((result=tcprecvdata_nb(pTrackerServer->sock, &resp,
|
if ((result=tcprecvdata_nb(pTrackerServer->sock, &resp,
|
||||||
sizeof(resp), network_timeout)) != 0)
|
sizeof(resp), network_timeout)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"server: %s:%u, recv data fail, errno: %d, error info: %s",
|
"server: %s:%u, recv data fail, "
|
||||||
__LINE__, formatted_ip, pTrackerServer->port,
|
"errno: %d, error info: %s",
|
||||||
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
*in_bytes = 0;
|
*in_bytes = 0;
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -60,10 +59,10 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (resp.status != 0)
|
if (resp.status != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"server: %s:%u, response status %d != 0", __LINE__,
|
"server: %s:%u, response status %d != 0",
|
||||||
formatted_ip, pTrackerServer->port, resp.status);
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, resp.status);
|
||||||
|
|
||||||
*in_bytes = 0;
|
*in_bytes = 0;
|
||||||
return resp.status;
|
return resp.status;
|
||||||
|
|
@ -72,10 +71,11 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
||||||
*in_bytes = buff2long(resp.pkg_len);
|
*in_bytes = buff2long(resp.pkg_len);
|
||||||
if (*in_bytes < 0)
|
if (*in_bytes < 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"server: %s:%u, recv package size %"PRId64" is not correct",
|
"server: %s:%u, recv package size "
|
||||||
__LINE__, formatted_ip, pTrackerServer->port, *in_bytes);
|
"%"PRId64" is not correct",
|
||||||
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, *in_bytes);
|
||||||
*in_bytes = 0;
|
*in_bytes = 0;
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,6 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
bool bMalloced;
|
bool bMalloced;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
result = fdfs_recv_header(pTrackerServer, in_bytes);
|
result = fdfs_recv_header(pTrackerServer, in_bytes);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -121,11 +120,11 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
||||||
{
|
{
|
||||||
if (*in_bytes > buff_size)
|
if (*in_bytes > buff_size)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"server: %s:%u, recv body bytes: " \
|
||||||
"server: %s:%u, recv body bytes: %"PRId64" exceed "
|
"%"PRId64" exceed max: %d", \
|
||||||
"max: %d", __LINE__, formatted_ip, pTrackerServer->port,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
*in_bytes, buff_size);
|
pTrackerServer->port, *in_bytes, buff_size);
|
||||||
*in_bytes = 0;
|
*in_bytes = 0;
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
@ -133,14 +132,15 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
||||||
bMalloced = false;
|
bMalloced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tcprecvdata_nb(pTrackerServer->sock, *buff,
|
if ((result=tcprecvdata_nb(pTrackerServer->sock, *buff, \
|
||||||
*in_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
*in_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server: %s:%u, recv data fail, " \
|
||||||
"tracker server: %s:%u, recv data fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
*in_bytes = 0;
|
*in_bytes = 0;
|
||||||
if (bMalloced)
|
if (bMalloced)
|
||||||
{
|
{
|
||||||
|
|
@ -156,20 +156,20 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
||||||
int fdfs_quit(ConnectionInfo *pTrackerServer)
|
int fdfs_quit(ConnectionInfo *pTrackerServer)
|
||||||
{
|
{
|
||||||
TrackerHeader header;
|
TrackerHeader header;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.cmd = FDFS_PROTO_CMD_QUIT;
|
header.cmd = FDFS_PROTO_CMD_QUIT;
|
||||||
result = tcpsenddata_nb(pTrackerServer->sock, &header,
|
result = tcpsenddata_nb(pTrackerServer->sock, &header, \
|
||||||
sizeof(header), SF_G_NETWORK_TIMEOUT);
|
sizeof(header), SF_G_NETWORK_TIMEOUT);
|
||||||
if(result != 0)
|
if(result != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server: %s:%u, send data fail, " \
|
||||||
"tracker server: %s:%u, send data fail, errno: %d, "
|
"errno: %d, error info: %s", \
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, \
|
||||||
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -487,8 +487,7 @@ ConnectionInfo *tracker_connect_server_ex(TrackerServerInfo *pServerInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo,
|
ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo,
|
||||||
const char *bind_addr4, const char *bind_addr6, int *err_no,
|
const char *bind_addr, int *err_no, const bool log_connect_error)
|
||||||
const bool log_connect_error)
|
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo *end;
|
ConnectionInfo *end;
|
||||||
|
|
@ -500,12 +499,12 @@ ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo
|
||||||
return pServerInfo->connections + pServerInfo->index;
|
return pServerInfo->connections + pServerInfo->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = pServerInfo->connections + pServerInfo->index;
|
*err_no = conn_pool_connect_server_ex(pServerInfo->connections
|
||||||
*err_no = conn_pool_connect_server_ex(conn, SF_G_CONNECT_TIMEOUT * 1000,
|
+ pServerInfo->index, SF_G_CONNECT_TIMEOUT,
|
||||||
conn->af == AF_INET ? bind_addr4 : bind_addr6, log_connect_error);
|
bind_addr, log_connect_error);
|
||||||
if (*err_no == 0)
|
if (*err_no == 0)
|
||||||
{
|
{
|
||||||
return conn;
|
return pServerInfo->connections + pServerInfo->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pServerInfo->count == 1)
|
if (pServerInfo->count == 1)
|
||||||
|
|
@ -520,12 +519,11 @@ ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo
|
||||||
if (current_index != pServerInfo->index)
|
if (current_index != pServerInfo->index)
|
||||||
{
|
{
|
||||||
if ((*err_no=conn_pool_connect_server_ex(conn,
|
if ((*err_no=conn_pool_connect_server_ex(conn,
|
||||||
SF_G_CONNECT_TIMEOUT * 1000,
|
SF_G_CONNECT_TIMEOUT, bind_addr,
|
||||||
conn->af == AF_INET ? bind_addr4 :
|
log_connect_error)) == 0)
|
||||||
bind_addr6, log_connect_error)) == 0)
|
|
||||||
{
|
{
|
||||||
pServerInfo->index = current_index;
|
pServerInfo->index = current_index;
|
||||||
return conn;
|
return pServerInfo->connections + pServerInfo->index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -543,7 +541,7 @@ ConnectionInfo *tracker_make_connection_ex(ConnectionInfo *conn,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*err_no = conn_pool_connect_server(conn, connect_timeout * 1000);
|
*err_no = conn_pool_connect_server(conn, connect_timeout);
|
||||||
if (*err_no != 0)
|
if (*err_no != 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -591,11 +589,10 @@ void tracker_disconnect_server_no_pool(TrackerServerInfo *pServerInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \
|
||||||
char *buff, const int buff_size)
|
char *buff, const int buff_size)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader)];
|
char out_buff[sizeof(TrackerHeader)];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -603,14 +600,14 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
||||||
memset(out_buff, 0, sizeof(out_buff));
|
memset(out_buff, 0, sizeof(out_buff));
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_PARAMETER_REQ;
|
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_PARAMETER_REQ;
|
||||||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff,
|
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||||
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"tracker server %s:%u, send data fail, " \
|
||||||
"tracker server %s:%u, send data fail, "
|
"errno: %d, error info: %s.", \
|
||||||
"errno: %d, error info: %s", __LINE__,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -623,12 +620,11 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (in_bytes >= buff_size)
|
if (in_bytes >= buff_size)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
logError("file: "__FILE__", line: %d, " \
|
||||||
logError("file: "__FILE__", line: %d, "
|
"server: %s:%u, recv body bytes: " \
|
||||||
"server: %s:%u, recv body bytes: "
|
"%"PRId64" exceed max: %d", \
|
||||||
"%"PRId64" exceed max: %d", __LINE__,
|
__LINE__, pTrackerServer->ip_addr, \
|
||||||
formatted_ip, pTrackerServer->port,
|
pTrackerServer->port, in_bytes, buff_size);
|
||||||
in_bytes, buff_size);
|
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,10 +632,9 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
int fdfs_get_ini_context_from_tracker(TrackerServerGroup *pTrackerGroup, \
|
||||||
IniContext *iniContext, bool * volatile continue_flag,
|
IniContext *iniContext, bool * volatile continue_flag, \
|
||||||
const bool client_bind_addr, const char *bind_addr4,
|
const bool client_bind_addr, const char *bind_addr)
|
||||||
const char *bind_addr6)
|
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
TrackerServerInfo *pGlobalServer;
|
TrackerServerInfo *pGlobalServer;
|
||||||
|
|
@ -648,7 +643,6 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
TrackerServerInfo *pTServer;
|
TrackerServerInfo *pTServer;
|
||||||
TrackerServerInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
char in_buff[1024];
|
char in_buff[1024];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int result;
|
int result;
|
||||||
int leader_index;
|
int leader_index;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -669,14 +663,7 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
|
|
||||||
if (!client_bind_addr)
|
if (!client_bind_addr)
|
||||||
{
|
{
|
||||||
if (bind_addr4 != NULL)
|
bind_addr = NULL;
|
||||||
{
|
|
||||||
bind_addr4 = NULL;
|
|
||||||
}
|
|
||||||
if (bind_addr6 != NULL)
|
|
||||||
{
|
|
||||||
bind_addr6 = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
@ -690,7 +677,7 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
conn = tracker_connect_server_no_pool_ex(pTServer,
|
conn = tracker_connect_server_no_pool_ex(pTServer,
|
||||||
bind_addr4, bind_addr6, &result, false);
|
bind_addr, &result, false);
|
||||||
if (conn != NULL)
|
if (conn != NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -701,13 +688,11 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
|
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
{
|
{
|
||||||
format_ip_address(pTServer->connections[0].
|
|
||||||
ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"connect to server %s:%u fail, errno: %d, "
|
"connect to server %s:%u fail, errno: %d, "
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
"error info: %s", __LINE__, pTServer->connections[0].
|
||||||
pTServer->connections[0].port, result,
|
ip_addr, pTServer->connections[0].port,
|
||||||
STRERROR(result));
|
result, STRERROR(result));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -720,10 +705,9 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"get parameters from tracker server %s:%u fail",
|
"get parameters from tracker server %s:%u fail",
|
||||||
__LINE__, formatted_ip, conn->port);
|
__LINE__, conn->ip_addr, conn->port);
|
||||||
close(conn->sock);
|
close(conn->sock);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
@ -741,7 +725,6 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
||||||
TrackerRunningStatus *pStatus)
|
TrackerRunningStatus *pStatus)
|
||||||
{
|
{
|
||||||
char in_buff[1 + 2 * FDFS_PROTO_PKG_LEN_SIZE];
|
char in_buff[1 + 2 * FDFS_PROTO_PKG_LEN_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
TrackerHeader header;
|
TrackerHeader header;
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
|
|
@ -761,10 +744,10 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
||||||
if ((result=tcpsenddata_nb(conn->sock, &header,
|
if ((result=tcpsenddata_nb(conn->sock, &header,
|
||||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"error info: %s", __LINE__, formatted_ip, conn->port,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
|
conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
result = (result == ENOENT ? EACCES : result);
|
result = (result == ENOENT ? EACCES : result);
|
||||||
|
|
@ -781,11 +764,11 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
||||||
|
|
||||||
if (in_bytes != sizeof(in_buff))
|
if (in_bytes != sizeof(in_buff))
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u response data length: "
|
"tracker server %s:%u response data "
|
||||||
"%"PRId64" is invalid, expect length: %d",
|
"length: %"PRId64" is invalid, "
|
||||||
__LINE__, formatted_ip, conn->port,
|
"expect length: %d.", __LINE__,
|
||||||
|
conn->ip_addr, conn->port,
|
||||||
in_bytes, (int)sizeof(in_buff));
|
in_bytes, (int)sizeof(in_buff));
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,6 @@ typedef struct
|
||||||
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
|
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
|
||||||
char init_flag;
|
char init_flag;
|
||||||
signed char status;
|
signed char status;
|
||||||
char storage_id[FDFS_STORAGE_ID_MAX_SIZE]; //since 6.11
|
|
||||||
char current_tracker_ip[IP_ADDRESS_SIZE]; //current tracker ip address
|
char current_tracker_ip[IP_ADDRESS_SIZE]; //current tracker ip address
|
||||||
char tracker_count[FDFS_PROTO_PKG_LEN_SIZE]; //all tracker server count
|
char tracker_count[FDFS_PROTO_PKG_LEN_SIZE]; //all tracker server count
|
||||||
} TrackerStorageJoinBody;
|
} TrackerStorageJoinBody;
|
||||||
|
|
@ -213,13 +212,6 @@ typedef struct
|
||||||
char size[4];
|
char size[4];
|
||||||
} FDFSTrunkInfoBuff;
|
} FDFSTrunkInfoBuff;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char start_index[4];
|
|
||||||
char allow_empty;
|
|
||||||
} FDFSFetchStorageIdsBody;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -248,15 +240,13 @@ ConnectionInfo *tracker_connect_server_ex(TrackerServerInfo *pServerInfo,
|
||||||
* connect to the tracker server directly without connection pool
|
* connect to the tracker server directly without connection pool
|
||||||
* params:
|
* params:
|
||||||
* pTrackerServer: tracker server
|
* pTrackerServer: tracker server
|
||||||
* bind_addr4: the ipv4 address to bind, NULL or empty for any
|
* bind_ipaddr: the ip address to bind, NULL or empty for any
|
||||||
* bind_addr6: the ipv6 address to bind, NULL or empty for any
|
|
||||||
* err_no: return the error no
|
* err_no: return the error no
|
||||||
* log_connect_error: if log error info when connect fail
|
* log_connect_error: if log error info when connect fail
|
||||||
* return: ConnectionInfo pointer for success, NULL for fail
|
* return: ConnectionInfo pointer for success, NULL for fail
|
||||||
**/
|
**/
|
||||||
ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo,
|
ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo,
|
||||||
const char *bind_addr4, const char *bind_addr6, int *err_no,
|
const char *bind_addr, int *err_no, const bool log_connect_error);
|
||||||
const bool log_connect_error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connect to the tracker server directly without connection pool
|
* connect to the tracker server directly without connection pool
|
||||||
|
|
@ -268,10 +258,9 @@ ConnectionInfo *tracker_connect_server_no_pool_ex(TrackerServerInfo *pServerInfo
|
||||||
static inline ConnectionInfo *tracker_connect_server_no_pool(
|
static inline ConnectionInfo *tracker_connect_server_no_pool(
|
||||||
TrackerServerInfo *pServerInfo, int *err_no)
|
TrackerServerInfo *pServerInfo, int *err_no)
|
||||||
{
|
{
|
||||||
const char *bind_addr4 = NULL;
|
const char *bind_addr = NULL;
|
||||||
const char *bind_addr6 = NULL;
|
|
||||||
return tracker_connect_server_no_pool_ex(pServerInfo,
|
return tracker_connect_server_no_pool_ex(pServerInfo,
|
||||||
bind_addr4, bind_addr6, err_no, true);
|
bind_addr, err_no, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tracker_close_connection(pTrackerServer) \
|
#define tracker_close_connection(pTrackerServer) \
|
||||||
|
|
@ -327,21 +316,15 @@ int fdfs_deal_no_body_cmd_ex(const char *ip_addr, const int port, const int cmd)
|
||||||
fdfs_split_metadata_ex(meta_buff, FDFS_RECORD_SEPERATOR, \
|
fdfs_split_metadata_ex(meta_buff, FDFS_RECORD_SEPERATOR, \
|
||||||
FDFS_FIELD_SEPERATOR, meta_count, err_no)
|
FDFS_FIELD_SEPERATOR, meta_count, err_no)
|
||||||
|
|
||||||
char *fdfs_pack_metadata(const FDFSMetaData *meta_list, const int meta_count,
|
char *fdfs_pack_metadata(const FDFSMetaData *meta_list, const int meta_count, \
|
||||||
char *meta_buff, int *buff_bytes);
|
char *meta_buff, int *buff_bytes);
|
||||||
FDFSMetaData *fdfs_split_metadata_ex(char *meta_buff,
|
FDFSMetaData *fdfs_split_metadata_ex(char *meta_buff, \
|
||||||
const char recordSeperator, const char filedSeperator,
|
const char recordSeperator, const char filedSeperator, \
|
||||||
int *meta_count, int *err_no);
|
int *meta_count, int *err_no);
|
||||||
|
|
||||||
int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
int fdfs_get_ini_context_from_tracker(TrackerServerGroup *pTrackerGroup, \
|
||||||
IniContext *iniContext, bool * volatile continue_flag,
|
IniContext *iniContext, bool * volatile continue_flag, \
|
||||||
const bool client_bind_addr, const char *bind_addr4,
|
const bool client_bind_addr, const char *bind_addr);
|
||||||
const char *bind_addr6);
|
|
||||||
|
|
||||||
#define fdfs_get_ini_context_from_tracker(pTrackerGroup, \
|
|
||||||
iniContext, continue_flag) \
|
|
||||||
fdfs_get_ini_context_from_tracker_ex(pTrackerGroup, \
|
|
||||||
iniContext, continue_flag, false, NULL, NULL)
|
|
||||||
|
|
||||||
int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
||||||
TrackerRunningStatus *pStatus);
|
TrackerRunningStatus *pStatus);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
int64_t in_bytes;
|
int64_t in_bytes;
|
||||||
char in_buff[(FDFS_GROUP_NAME_MAX_LEN + FDFS_STORAGE_ID_MAX_SIZE) * \
|
char in_buff[(FDFS_GROUP_NAME_MAX_LEN + FDFS_STORAGE_ID_MAX_SIZE) * \
|
||||||
FDFS_MAX_GROUPS];
|
FDFS_MAX_GROUPS];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
char *p;
|
char *p;
|
||||||
char *pEnd;
|
char *pEnd;
|
||||||
|
|
@ -50,26 +49,26 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
|
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.cmd = TRACKER_PROTO_CMD_TRACKER_PING_LEADER;
|
header.cmd = TRACKER_PROTO_CMD_TRACKER_PING_LEADER;
|
||||||
result = tcpsenddata_nb(pTrackerServer->sock, &header,
|
result = tcpsenddata_nb(pTrackerServer->sock, &header, \
|
||||||
sizeof(header), SF_G_NETWORK_TIMEOUT);
|
sizeof(header), SF_G_NETWORK_TIMEOUT);
|
||||||
if(result != 0)
|
if(result != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, send data fail, errno: %d, "
|
"tracker server %s:%u, send data fail, "
|
||||||
"error info: %s", __LINE__, formatted_ip,
|
"errno: %d, error info: %s",
|
||||||
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
pTrackerServer->port, result, STRERROR(result));
|
pTrackerServer->port, result, STRERROR(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInBuff = in_buff;
|
pInBuff = in_buff;
|
||||||
if ((result=fdfs_recv_response(pTrackerServer, &pInBuff,
|
if ((result=fdfs_recv_response(pTrackerServer, &pInBuff, \
|
||||||
sizeof(in_buff), &in_bytes)) != 0)
|
sizeof(in_buff), &in_bytes)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"fdfs_recv_response from %s:%u fail, result: %d",
|
"fdfs_recv_response from %s:%u fail, result: %d",
|
||||||
__LINE__, formatted_ip, pTrackerServer->port, result);
|
__LINE__, pTrackerServer->ip_addr,
|
||||||
|
pTrackerServer->port, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,10 +79,9 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
||||||
else if (in_bytes % (FDFS_GROUP_NAME_MAX_LEN + \
|
else if (in_bytes % (FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE) != 0)
|
FDFS_STORAGE_ID_MAX_SIZE) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u, invalid body length: "
|
"tracker server %s:%u, invalid body length: "
|
||||||
"%"PRId64, __LINE__, formatted_ip,
|
"%"PRId64, __LINE__, pTrackerServer->ip_addr,
|
||||||
pTrackerServer->port, in_bytes);
|
pTrackerServer->port, in_bytes);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +198,6 @@ static int relationship_get_tracker_leader(TrackerRunningStatus *pTrackerStatus)
|
||||||
TrackerServerInfo *pTrackerEnd;
|
TrackerServerInfo *pTrackerEnd;
|
||||||
TrackerRunningStatus *pStatus;
|
TrackerRunningStatus *pStatus;
|
||||||
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
int count;
|
int count;
|
||||||
int result;
|
int result;
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -238,20 +235,17 @@ static int relationship_get_tracker_leader(TrackerRunningStatus *pTrackerStatus)
|
||||||
qsort(trackerStatus, count, sizeof(TrackerRunningStatus), \
|
qsort(trackerStatus, count, sizeof(TrackerRunningStatus), \
|
||||||
relationship_cmp_tracker_status);
|
relationship_cmp_tracker_status);
|
||||||
|
|
||||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
|
||||||
for (i=0; i<count; i++)
|
for (i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
format_ip_address(trackerStatus[i].pTrackerServer->
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
connections->ip_addr, formatted_ip);
|
"%s:%u if_leader: %d, running time: %d, " \
|
||||||
logDebug("file: "__FILE__", line: %d, "
|
"restart interval: %d", __LINE__, \
|
||||||
"%s:%u if_leader: %d, running time: %d, "
|
trackerStatus[i].pTrackerServer->connections->ip_addr, \
|
||||||
"restart interval: %d", __LINE__, formatted_ip,
|
trackerStatus[i].pTrackerServer->connections->port, \
|
||||||
trackerStatus[i].pTrackerServer->connections->port,
|
trackerStatus[i].if_leader, \
|
||||||
trackerStatus[i].if_leader,
|
trackerStatus[i].running_time, \
|
||||||
trackerStatus[i].running_time,
|
|
||||||
trackerStatus[i].restart_interval);
|
trackerStatus[i].restart_interval);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
||||||
sizeof(TrackerRunningStatus));
|
sizeof(TrackerRunningStatus));
|
||||||
|
|
@ -262,7 +256,6 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
||||||
ConnectionInfo *pLeader, const char cmd, bool *bConnectFail)
|
ConnectionInfo *pLeader, const char cmd, bool *bConnectFail)
|
||||||
{
|
{
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_PROTO_IP_PORT_SIZE];
|
char out_buff[sizeof(TrackerHeader) + FDFS_PROTO_IP_PORT_SIZE];
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
|
|
@ -283,41 +276,39 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
||||||
memset(out_buff, 0, sizeof(out_buff));
|
memset(out_buff, 0, sizeof(out_buff));
|
||||||
pHeader = (TrackerHeader *)out_buff;
|
pHeader = (TrackerHeader *)out_buff;
|
||||||
pHeader->cmd = cmd;
|
pHeader->cmd = cmd;
|
||||||
format_ip_port(pLeader->ip_addr, pLeader->port,
|
sprintf(out_buff + sizeof(TrackerHeader), "%s:%u", \
|
||||||
out_buff + sizeof(TrackerHeader));
|
pLeader->ip_addr, pLeader->port);
|
||||||
long2buff(FDFS_PROTO_IP_PORT_SIZE, pHeader->pkg_len);
|
long2buff(FDFS_PROTO_IP_PORT_SIZE, pHeader->pkg_len);
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%u fail, errno: %d, "
|
"send data to tracker server %s:%u fail, "
|
||||||
"error info: %s", __LINE__, formatted_ip, conn->port,
|
"errno: %d, error info: %s", __LINE__,
|
||||||
result, STRERROR(result));
|
conn->ip_addr, conn->port, result, STRERROR(result));
|
||||||
|
|
||||||
result = (result == ENOENT ? EACCES : result);
|
result = (result == ENOENT ? EACCES : result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInBuff = in_buff;
|
pInBuff = in_buff;
|
||||||
result = fdfs_recv_response(conn, &pInBuff, 0, &in_bytes);
|
result = fdfs_recv_response(conn, &pInBuff, \
|
||||||
|
0, &in_bytes);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"fdfs_recv_response from tracker server %s:%u fail, "
|
"fdfs_recv_response from tracker server %s:%u fail, "
|
||||||
"result: %d", __LINE__, formatted_ip, conn->port, result);
|
"result: %d", __LINE__, conn->ip_addr, conn->port, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_bytes != 0)
|
if (in_bytes != 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
"tracker server %s:%u response data "
|
"tracker server %s:%u response data "
|
||||||
"length: %"PRId64" is invalid, "
|
"length: %"PRId64" is invalid, "
|
||||||
"expect length: %d.", __LINE__,
|
"expect length: %d.", __LINE__,
|
||||||
formatted_ip, conn->port, in_bytes, 0);
|
conn->ip_addr, conn->port, in_bytes, 0);
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -339,8 +330,6 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
||||||
void relationship_set_tracker_leader(const int server_index,
|
void relationship_set_tracker_leader(const int server_index,
|
||||||
ConnectionInfo *pLeader, const bool leader_self)
|
ConnectionInfo *pLeader, const bool leader_self)
|
||||||
{
|
{
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
g_tracker_servers.leader_index = server_index;
|
g_tracker_servers.leader_index = server_index;
|
||||||
g_next_leader_index = -1;
|
g_next_leader_index = -1;
|
||||||
|
|
||||||
|
|
@ -351,10 +340,9 @@ void relationship_set_tracker_leader(const int server_index,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
format_ip_address(pLeader->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"the tracker leader is %s:%u", __LINE__,
|
"the tracker leader is %s:%u", __LINE__,
|
||||||
formatted_ip, pLeader->port);
|
pLeader->ip_addr, pLeader->port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,7 +458,6 @@ static int relationship_select_leader()
|
||||||
int result;
|
int result;
|
||||||
TrackerRunningStatus trackerStatus;
|
TrackerRunningStatus trackerStatus;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
if (g_tracker_servers.server_count <= 0)
|
if (g_tracker_servers.server_count <= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -495,10 +482,9 @@ static int relationship_select_leader()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"I am the new tracker leader %s:%u",
|
"I am the new tracker leader %s:%u",
|
||||||
__LINE__, formatted_ip, conn->port);
|
__LINE__, conn->ip_addr, conn->port);
|
||||||
|
|
||||||
tracker_mem_find_trunk_servers();
|
tracker_mem_find_trunk_servers();
|
||||||
}
|
}
|
||||||
|
|
@ -523,17 +509,15 @@ static int relationship_select_leader()
|
||||||
|
|
||||||
if (g_tracker_servers.leader_index >= 0)
|
if (g_tracker_servers.leader_index >= 0)
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"the tracker leader %s:%u", __LINE__,
|
"the tracker leader %s:%u", __LINE__,
|
||||||
formatted_ip, conn->port);
|
conn->ip_addr, conn->port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
format_ip_address(conn->ip_addr, formatted_ip);
|
|
||||||
logInfo("file: "__FILE__", line: %d, "
|
logInfo("file: "__FILE__", line: %d, "
|
||||||
"waiting for the candidate tracker leader %s:%u notify ...",
|
"waiting for the candidate tracker leader %s:%u notify ...",
|
||||||
__LINE__, formatted_ip, conn->port);
|
__LINE__, conn->ip_addr, conn->port);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -576,7 +560,6 @@ static void *relationship_thread_entrance(void* arg)
|
||||||
|
|
||||||
int fail_count;
|
int fail_count;
|
||||||
int sleep_seconds;
|
int sleep_seconds;
|
||||||
char formatted_ip[FORMATTED_IP_SIZE];
|
|
||||||
|
|
||||||
#ifdef OS_LINUX
|
#ifdef OS_LINUX
|
||||||
{
|
{
|
||||||
|
|
@ -624,9 +607,8 @@ static void *relationship_thread_entrance(void* arg)
|
||||||
{
|
{
|
||||||
pLeader = g_tracker_servers.servers
|
pLeader = g_tracker_servers.servers
|
||||||
[leader_index].connections;
|
[leader_index].connections;
|
||||||
format_ip_address(pLeader->ip_addr, formatted_ip);
|
|
||||||
sprintf(leader_str, "leader %s:%u",
|
sprintf(leader_str, "leader %s:%u",
|
||||||
formatted_ip, pLeader->port);
|
pLeader->ip_addr, pLeader->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
++fail_count;
|
++fail_count;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -48,7 +48,7 @@
|
||||||
#define FDFS_TRUNK_LOGIC_FILENAME_LENGTH (FDFS_TRUNK_FILENAME_LENGTH + \
|
#define FDFS_TRUNK_LOGIC_FILENAME_LENGTH (FDFS_TRUNK_FILENAME_LENGTH + \
|
||||||
(FDFS_LOGIC_FILE_PATH_LEN - FDFS_TRUE_FILE_PATH_LEN))
|
(FDFS_LOGIC_FILE_PATH_LEN - FDFS_TRUE_FILE_PATH_LEN))
|
||||||
|
|
||||||
#define FDFS_VERSION_SIZE 8
|
#define FDFS_VERSION_SIZE 6
|
||||||
|
|
||||||
//status order is important!
|
//status order is important!
|
||||||
#define FDFS_STORAGE_STATUS_INIT 0
|
#define FDFS_STORAGE_STATUS_INIT 0
|
||||||
|
|
@ -427,7 +427,6 @@ typedef struct
|
||||||
char version[FDFS_VERSION_SIZE]; //storage version
|
char version[FDFS_VERSION_SIZE]; //storage version
|
||||||
char group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
|
char group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
|
||||||
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
|
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
|
||||||
char storage_id[FDFS_STORAGE_ID_MAX_SIZE];
|
|
||||||
char init_flag;
|
char init_flag;
|
||||||
signed char status;
|
signed char status;
|
||||||
int tracker_count;
|
int tracker_count;
|
||||||
|
|
@ -472,10 +471,5 @@ typedef struct {
|
||||||
bool if_leader; //if leader
|
bool if_leader; //if leader
|
||||||
} TrackerRunningStatus;
|
} TrackerRunningStatus;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *ptr;
|
|
||||||
char holder[FDFS_STORAGE_ID_MAX_SIZE];
|
|
||||||
} FDFSStorageId;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue