log square quoted IPv6 address
parent
ff2aef1735
commit
422c63cc54
4
HISTORY
4
HISTORY
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
Version 6.12.1 2024-02-26
|
||||
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
|
||||
|
|
|
|||
|
|
@ -137,11 +137,12 @@ static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
|||
/*
|
||||
{
|
||||
TrackerServerInfo *pServer;
|
||||
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+ \
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+
|
||||
pTrackerGroup->server_count; pServer++)
|
||||
{
|
||||
//printf("server=%s:%u\n", \
|
||||
pServer->ip_addr, pServer->port);
|
||||
format_ip_address(pServer->connections[0].ip_addr, formatted_ip);
|
||||
printf("server=%s:%u\n", formatted_ip, pServer->connections[0].port);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,12 +35,13 @@ static void usage(char *argv[])
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *conf_filename;
|
||||
int result;
|
||||
char *op_type;
|
||||
char *group_name;
|
||||
char *tracker_server;
|
||||
int arg_index;
|
||||
char *group_name;
|
||||
int result;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
|
|
@ -155,7 +156,9 @@ int main(int argc, char *argv[])
|
|||
fdfs_client_destroy();
|
||||
return errno != 0 ? errno : ECONNREFUSED;
|
||||
}
|
||||
printf("\ntracker server is %s:%u\n\n", pTrackerServer->ip_addr, pTrackerServer->port);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
printf("\ntracker server is %s:%u\n\n", formatted_ip,
|
||||
pTrackerServer->port);
|
||||
|
||||
if (arg_index < argc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ int main(int argc, char *argv[])
|
|||
int meta_count;
|
||||
int i;
|
||||
FDFSMetaData *pMetaList;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char token[32 + 1];
|
||||
char file_id[128];
|
||||
char file_url[256];
|
||||
|
|
@ -460,8 +461,9 @@ g_fdfs_version.patch);
|
|||
printf("server list (%d):\n", server_count);
|
||||
for (i=0; i<server_count; i++)
|
||||
{
|
||||
printf("\t%s:%u\n", \
|
||||
storageServers[i].ip_addr, \
|
||||
format_ip_address(storageServers[i].
|
||||
ip_addr, formatted_ip);
|
||||
printf("\t%s:%u\n", formatted_ip,
|
||||
storageServers[i].port);
|
||||
}
|
||||
printf("\n");
|
||||
|
|
@ -488,8 +490,8 @@ g_fdfs_version.patch);
|
|||
return result;
|
||||
}
|
||||
|
||||
printf("storage=%s:%u\n", storageServer.ip_addr, \
|
||||
storageServer.port);
|
||||
format_ip_address(storageServer.ip_addr, formatted_ip);
|
||||
printf("storage=%s:%u\n", formatted_ip, storageServer.port);
|
||||
|
||||
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||
&result)) == NULL)
|
||||
|
|
@ -670,15 +672,17 @@ g_fdfs_version.patch);
|
|||
/* for test only */
|
||||
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
||||
{
|
||||
printf("active_test to tracker server %s:%u fail, errno: %d\n", \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, result);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
printf("active_test to tracker server %s:%u fail, errno: %d\n",
|
||||
formatted_ip, pTrackerServer->port, result);
|
||||
}
|
||||
|
||||
/* for test only */
|
||||
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
||||
{
|
||||
printf("active_test to storage server %s:%u fail, errno: %d\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
printf("active_test to storage server %s:%u fail, errno: %d\n",
|
||||
formatted_ip, pStorageServer->port, result);
|
||||
}
|
||||
|
||||
tracker_close_connection_ex(pStorageServer, true);
|
||||
|
|
@ -688,4 +692,3 @@ g_fdfs_version.patch);
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ int main(int argc, char *argv[])
|
|||
int meta_count;
|
||||
int i;
|
||||
FDFSMetaData *pMetaList;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char token[32 + 1];
|
||||
char file_id[128];
|
||||
char master_file_id[128];
|
||||
|
|
@ -432,8 +433,9 @@ g_fdfs_version.patch);
|
|||
printf("server list (%d):\n", server_count);
|
||||
for (i=0; i<server_count; i++)
|
||||
{
|
||||
printf("\t%s:%u\n", \
|
||||
storageServers[i].ip_addr, \
|
||||
format_ip_address(storageServers[i].
|
||||
ip_addr, formatted_ip);
|
||||
printf("\t%s:%u\n", formatted_ip,
|
||||
storageServers[i].port);
|
||||
}
|
||||
printf("\n");
|
||||
|
|
@ -455,8 +457,8 @@ g_fdfs_version.patch);
|
|||
return result;
|
||||
}
|
||||
|
||||
printf("storage=%s:%u\n", storageServer.ip_addr, \
|
||||
storageServer.port);
|
||||
format_ip_address(storageServer.ip_addr, formatted_ip);
|
||||
printf("storage=%s:%u\n", formatted_ip, storageServer.port);
|
||||
|
||||
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||
&result)) == NULL)
|
||||
|
|
@ -637,15 +639,17 @@ g_fdfs_version.patch);
|
|||
/* for test only */
|
||||
if ((result=fdfs_active_test(pTrackerServer)) != 0)
|
||||
{
|
||||
printf("active_test to tracker server %s:%u fail, errno: %d\n", \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, result);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
printf("active_test to tracker server %s:%u fail, errno: %d\n",
|
||||
formatted_ip, pTrackerServer->port, result);
|
||||
}
|
||||
|
||||
/* for test only */
|
||||
if ((result=fdfs_active_test(pStorageServer)) != 0)
|
||||
{
|
||||
printf("active_test to storage server %s:%u fail, errno: %d\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
printf("active_test to storage server %s:%u fail, errno: %d\n",
|
||||
formatted_ip, pStorageServer->port, result);
|
||||
}
|
||||
|
||||
tracker_close_connection_ex(pStorageServer, true);
|
||||
|
|
|
|||
|
|
@ -309,6 +309,7 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
|
|||
int result;
|
||||
ConnectionInfo storageServer;
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int64_t in_bytes;
|
||||
int filename_len;
|
||||
char *file_buff;
|
||||
|
|
@ -346,15 +347,15 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
|
|||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||
pHeader->cmd = STORAGE_PROTO_CMD_GET_METADATA;
|
||||
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -410,6 +411,7 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
|||
ConnectionInfo storageServer;
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||
char in_buff[3 * FDFS_PROTO_PKG_LEN_SIZE + IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char buff[64];
|
||||
int64_t in_bytes;
|
||||
int filename_len;
|
||||
|
|
@ -446,15 +448,15 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
|||
pHeader->cmd = STORAGE_PROTO_CMD_QUERY_FILE_INFO;
|
||||
pHeader->status = bSilence ? ENOENT : 0;
|
||||
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -471,11 +473,11 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != sizeof(in_buff))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"recv data from storage server %s:%u fail, " \
|
||||
"recv bytes: %"PRId64" != %d", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
in_bytes, (int)sizeof(in_buff));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"recv data from storage server %s:%u fail, "
|
||||
"recv bytes: %"PRId64" != %d", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes, (int)sizeof(in_buff));
|
||||
result = EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -543,6 +545,7 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
|
|||
int result;
|
||||
ConnectionInfo storageServer;
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
char *pBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -576,15 +579,15 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
|
|||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||
pHeader->cmd = STORAGE_PROTO_CMD_DELETE_FILE;
|
||||
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -632,6 +635,7 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
|||
int result;
|
||||
ConnectionInfo storageServer;
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int out_bytes;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -666,21 +670,21 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
|||
p += 8;
|
||||
snprintf(p, sizeof(out_buff) - (p - out_buff), "%s", group_name);
|
||||
p += FDFS_GROUP_NAME_MAX_LEN;
|
||||
filename_len = snprintf(p, sizeof(out_buff) - (p - out_buff), \
|
||||
"%s", remote_filename);
|
||||
filename_len = snprintf(p, sizeof(out_buff) -
|
||||
(p - out_buff), "%s", remote_filename);
|
||||
p += filename_len;
|
||||
out_bytes = p - out_buff;
|
||||
long2buff(out_bytes - sizeof(TrackerHeader), pHeader->pkg_len);
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -744,15 +748,14 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
|||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"recv data from storage server " \
|
||||
"%s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"recv data from storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
formatted_ip, pStorageServer->port,
|
||||
result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
|
@ -917,6 +920,7 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
|||
int64_t in_bytes;
|
||||
int64_t total_send_bytes;
|
||||
char in_buff[128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
ConnectionInfo storageServer;
|
||||
bool new_connection;
|
||||
|
|
@ -966,8 +970,9 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
|||
*group_name = '\0';
|
||||
|
||||
/*
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
//logInfo("upload to storage %s:%u\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port);
|
||||
formatted_ip, pStorageServer->port);
|
||||
*/
|
||||
|
||||
do
|
||||
|
|
@ -1033,14 +1038,14 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
|||
pHeader->cmd = cmd;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1055,15 +1060,15 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||
{
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||
(char *)file_buff, file_size, \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
||||
(char *)file_buff, file_size,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1089,12 +1094,11 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should > %d", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1254,6 +1258,7 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
|||
ConnectionInfo storageServer;
|
||||
char out_buff[sizeof(TrackerHeader)+2*FDFS_PROTO_PKG_LEN_SIZE+\
|
||||
FDFS_GROUP_NAME_MAX_LEN+128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
int64_t in_bytes;
|
||||
char *pBuff;
|
||||
|
|
@ -1310,30 +1315,29 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
|||
p += filename_len;
|
||||
|
||||
pHeader = (TrackerHeader *)out_buff;
|
||||
long2buff((int)(p - (out_buff + sizeof(TrackerHeader))) + \
|
||||
long2buff((int)(p - (out_buff + sizeof(TrackerHeader))) +
|
||||
meta_bytes, pHeader->pkg_len);
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1434,6 +1438,7 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
|||
FDFS_GROUP_NAME_MAX_LEN + FDFS_FILE_PREFIX_MAX_LEN + \
|
||||
FDFS_FILE_EXT_NAME_MAX_LEN + 256];
|
||||
char in_buff[128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int group_name_len;
|
||||
int master_filename_len;
|
||||
|
|
@ -1531,11 +1536,11 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
|||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1551,12 +1556,11 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should > %d", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1785,6 +1789,7 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
|||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
char out_buff[512];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int64_t in_bytes;
|
||||
int64_t total_send_bytes;
|
||||
|
|
@ -1802,8 +1807,9 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
|
||||
/*
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
//printf("upload to storage %s:%u\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port);
|
||||
formatted_ip, pStorageServer->port);
|
||||
*/
|
||||
|
||||
do
|
||||
|
|
@ -1819,19 +1825,19 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
|||
memcpy(p, appender_filename, 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->cmd = STORAGE_PROTO_CMD_APPEND_FILE;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1846,15 +1852,15 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||
{
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||
(char *)file_buff, file_size, \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
||||
(char *)file_buff, file_size,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1878,10 +1884,10 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -1914,6 +1920,7 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
|||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
char out_buff[512];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int64_t in_bytes;
|
||||
int64_t total_send_bytes;
|
||||
|
|
@ -1930,8 +1937,9 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
|
||||
/*
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
//printf("upload to storage %s:%u\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port);
|
||||
formatted_ip, pStorageServer->port);
|
||||
*/
|
||||
|
||||
do
|
||||
|
|
@ -1950,42 +1958,41 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
|||
memcpy(p, appender_filename, 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->cmd = STORAGE_PROTO_CMD_MODIFY_FILE;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
if (upload_type == FDFS_UPLOAD_BY_FILE)
|
||||
{
|
||||
if ((result=tcpsendfile(pStorageServer->sock, file_buff, \
|
||||
file_size, SF_G_NETWORK_TIMEOUT, \
|
||||
&total_send_bytes)) != 0)
|
||||
if ((result=tcpsendfile(pStorageServer->sock, file_buff,
|
||||
file_size, SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (upload_type == FDFS_UPLOAD_BY_BUFF)
|
||||
{
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, \
|
||||
(char *)file_buff, file_size, \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock,
|
||||
(char *)file_buff, file_size,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2009,10 +2016,10 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -2382,6 +2389,7 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
|||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
char out_buff[512];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int64_t in_bytes;
|
||||
ConnectionInfo storageServer;
|
||||
|
|
@ -2397,8 +2405,9 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
|
||||
/*
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
//printf("upload to storage %s:%u\n", \
|
||||
pStorageServer->ip_addr, pStorageServer->port);
|
||||
formatted_ip, pStorageServer->port);
|
||||
*/
|
||||
|
||||
do
|
||||
|
|
@ -2414,19 +2423,19 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
|||
memcpy(p, appender_filename, appender_filename_len);
|
||||
p += appender_filename_len;
|
||||
|
||||
long2buff((p - out_buff) - sizeof(TrackerHeader), \
|
||||
long2buff((p - out_buff) - sizeof(TrackerHeader),
|
||||
pHeader->pkg_len);
|
||||
pHeader->cmd = STORAGE_PROTO_CMD_TRUNCATE_FILE;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pStorageServer->ip_addr, pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2440,10 +2449,10 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should == 0", __LINE__, pStorageServer->ip_addr, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should == 0", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -2467,6 +2476,7 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
|||
int result;
|
||||
char out_buff[512];
|
||||
char in_buff[256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -2498,11 +2508,11 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
|||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
pStorageServer->ip_addr, pStorageServer->port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2518,12 +2528,11 @@ int storage_regenerate_appender_filename(ConnectionInfo *pTrackerServer,
|
|||
|
||||
if (in_bytes <= FDFS_GROUP_NAME_MAX_LEN)
|
||||
{
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, "
|
||||
"should > %d", __LINE__,
|
||||
pStorageServer->ip_addr, pStorageServer->port,
|
||||
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
"storage server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, should > %d", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
|||
{
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
bool new_connection;
|
||||
TrackerHeader *pHeader;
|
||||
ConnectionInfo *conn;
|
||||
|
|
@ -293,16 +294,15 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + id_len, pHeader->pkg_len);
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_STORAGE;
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + id_len, \
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + id_len,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -330,10 +330,10 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes % sizeof(TrackerStorageStat) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64
|
||||
" is invalid", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
*storage_count = 0;
|
||||
return EINVAL;
|
||||
|
|
@ -342,11 +342,12 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
|||
*storage_count = in_bytes / sizeof(TrackerStorageStat);
|
||||
if (*storage_count > max_storages)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u insufficent space, " \
|
||||
"max storage count: %d, expect count: %d", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, max_storages, *storage_count);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u insufficent space, "
|
||||
"max storage count: %d, expect count: %d",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
max_storages, *storage_count);
|
||||
*storage_count = 0;
|
||||
return ENOSPC;
|
||||
}
|
||||
|
|
@ -484,6 +485,7 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
|||
ConnectionInfo *conn;
|
||||
bool new_connection;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerGroupStat src;
|
||||
char *pInBuff;
|
||||
int result;
|
||||
|
|
@ -497,15 +499,14 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
|||
sizeof(TrackerHeader), "%s", group_name);
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVER_LIST_ONE_GROUP;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -532,10 +533,10 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != sizeof(TrackerGroupStat))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -569,6 +570,7 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
|||
TrackerGroupStat *pSrc;
|
||||
TrackerGroupStat *pEnd;
|
||||
FDFSGroupStat *pDest;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
int64_t in_bytes;
|
||||
|
||||
|
|
@ -577,15 +579,14 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
|||
memset(&header, 0, sizeof(header));
|
||||
header.cmd = TRACKER_PROTO_CMD_SERVER_LIST_ALL_GROUPS;
|
||||
header.status = 0;
|
||||
if ((result=tcpsenddata_nb(conn->sock, &header, \
|
||||
if ((result=tcpsenddata_nb(conn->sock, &header,
|
||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -613,10 +614,10 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes % sizeof(TrackerGroupStat) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
*group_count = 0;
|
||||
return EINVAL;
|
||||
|
|
@ -625,11 +626,12 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
|||
*group_count = in_bytes / sizeof(TrackerGroupStat);
|
||||
if (*group_count > max_groups)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u insufficent space, " \
|
||||
"max group count: %d, expect count: %d", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, max_groups, *group_count);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u insufficent space, "
|
||||
"max group count: %d, expect count: %d",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
max_groups, *group_count);
|
||||
*group_count = 0;
|
||||
return ENOSPC;
|
||||
}
|
||||
|
|
@ -672,6 +674,7 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
|||
bool new_connection;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 128];
|
||||
char in_buff[sizeof(TrackerHeader) + TRACKER_QUERY_STORAGE_FETCH_BODY_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
int result;
|
||||
|
|
@ -693,16 +696,15 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
long2buff(FDFS_GROUP_NAME_MAX_LEN + filename_len, pHeader->pkg_len);
|
||||
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 +
|
||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -729,12 +731,11 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != TRACKER_QUERY_STORAGE_FETCH_BODY_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"expect length: %d", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, in_bytes, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, expect length: %d", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, in_bytes,
|
||||
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -759,6 +760,7 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
|||
char in_buff[sizeof(TrackerHeader) + \
|
||||
TRACKER_QUERY_STORAGE_FETCH_BODY_LEN + \
|
||||
FDFS_MAX_SERVERS_EACH_GROUP * IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
int result;
|
||||
|
|
@ -781,12 +783,11 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
|||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -814,10 +815,10 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
|||
if ((in_bytes - TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) % \
|
||||
(IP_ADDRESS_SIZE - 1) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -826,10 +827,11 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
|||
(IP_ADDRESS_SIZE - 1);
|
||||
if (nMaxServerCount < *server_count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response storage server " \
|
||||
"count: %d, exceeds max server count: %d!", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response storage server "
|
||||
"count: %d, exceeds max server count: %d!", __LINE__,
|
||||
formatted_ip, pTrackerServer->port,
|
||||
*server_count, nMaxServerCount);
|
||||
return ENOSPC;
|
||||
}
|
||||
|
|
@ -864,6 +866,7 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
|||
TrackerHeader header;
|
||||
char in_buff[sizeof(TrackerHeader) + \
|
||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
bool new_connection;
|
||||
ConnectionInfo *conn;
|
||||
char *pInBuff;
|
||||
|
|
@ -880,12 +883,11 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
|||
if ((result=tcpsenddata_nb(conn->sock, &header, \
|
||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -912,12 +914,12 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
|||
|
||||
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"expect length: %d", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid, expect length: %d", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, in_bytes,
|
||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -943,6 +945,7 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
|||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||
char in_buff[sizeof(TrackerHeader) + \
|
||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
int result;
|
||||
|
|
@ -959,16 +962,15 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
long2buff(FDFS_GROUP_NAME_MAX_LEN, pHeader->pkg_len);
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE;
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN, \
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -995,11 +997,11 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes != TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"expect length: %d", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, expect length: %d",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -1027,6 +1029,7 @@ int tracker_query_storage_store_list_with_group( \
|
|||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||
char in_buff[sizeof(TrackerHeader) + FDFS_MAX_SERVERS_EACH_GROUP * \
|
||||
TRACKER_QUERY_STORAGE_STORE_BODY_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char returned_group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
|
||||
char *pInBuff;
|
||||
char *p;
|
||||
|
|
@ -1055,15 +1058,14 @@ int tracker_query_storage_store_list_with_group( \
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1090,11 +1092,11 @@ int tracker_query_storage_store_list_with_group( \
|
|||
|
||||
if (in_bytes < TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"expect length >= %d", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, expect length >= %d",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
in_bytes, TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -1104,22 +1106,23 @@ int tracker_query_storage_store_list_with_group( \
|
|||
ipPortsLen = in_bytes - (FDFS_GROUP_NAME_MAX_LEN + 1);
|
||||
if (ipPortsLen % RECORD_LENGTH != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, in_bytes);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*storage_count = ipPortsLen / RECORD_LENGTH;
|
||||
if (nMaxServerCount < *storage_count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response storage server " \
|
||||
"count: %d, exceeds max server count: %d!", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, *storage_count, nMaxServerCount);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response storage server "
|
||||
"count: %d, exceeds max server count: %d!",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
*storage_count, nMaxServerCount);
|
||||
return ENOSPC;
|
||||
}
|
||||
|
||||
|
|
@ -1157,6 +1160,7 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
|||
FDFSStorageInfo storage_infos[1];
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
FDFS_STORAGE_ID_MAX_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -1228,11 +1232,11 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
|||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
conn->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1280,6 +1284,7 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
|||
TrackerServerInfo *pServer;
|
||||
TrackerServerInfo *pEnd;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -1308,11 +1313,11 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
|||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
conn->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1343,6 +1348,7 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
|||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
FDFS_STORAGE_ID_MAX_SIZE];
|
||||
char in_buff[FDFS_STORAGE_ID_MAX_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
int result;
|
||||
|
|
@ -1380,15 +1386,15 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
||||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||
storage_id_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
conn->port, result, STRERROR(result));
|
||||
|
||||
tracker_close_connection_ex(conn, true);
|
||||
continue;
|
||||
|
|
@ -1438,6 +1444,7 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
|||
bool new_connection;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
char *p;
|
||||
int result;
|
||||
|
|
@ -1467,15 +1474,14 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
|||
}
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_STATUS;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1502,11 +1508,11 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer,
|
|||
|
||||
if (in_bytes != sizeof(FDFSStorageBrief))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, in_bytes);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -1522,6 +1528,7 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
|||
bool new_connection;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int result;
|
||||
int ip_len;
|
||||
|
|
@ -1555,15 +1562,14 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
|||
}
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_GET_SERVER_ID;
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1589,10 +1595,10 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes == 0 || in_bytes >= FDFS_STORAGE_ID_MAX_SIZE)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data length: %"PRId64" "
|
||||
"is invalid", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -1654,4 +1660,3 @@ int tracker_get_storage_max_status(TrackerServerGroup *pTrackerGroup, \
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
make.sh
2
make.sh
|
|
@ -6,7 +6,7 @@ TARGET_SYSTEMD_PATH=$DESTDIR/usr/lib/systemd/system
|
|||
|
||||
WITH_LINUX_SERVICE=1
|
||||
|
||||
DEBUG_FLAG=0
|
||||
DEBUG_FLAG=1
|
||||
|
||||
export CC=gcc
|
||||
CFLAGS='-Wall'
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
|||
{
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 1];
|
||||
char full_binlog_filename[MAX_PATH_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
char *pBasePath;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -142,10 +143,11 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
|||
if((result=tcpsenddata_nb(pSrcStorage->sock, out_buff,
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s.",
|
||||
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port,
|
||||
"errno: %d, error info: %s.", __LINE__,
|
||||
formatted_ip, pSrcStorage->port,
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -170,17 +172,19 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
|
|||
if ((result=tcprecvfile(pSrcStorage->sock, full_binlog_filename,
|
||||
in_bytes, 0, network_timeout, &file_bytes)) != 0)
|
||||
{
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u, tcprecvfile fail, "
|
||||
"errno: %d, error info: %s.",
|
||||
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port,
|
||||
"errno: %d, error info: %s.", __LINE__,
|
||||
formatted_ip, pSrcStorage->port,
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"recovery binlog from %s:%u, file size: %"PRId64, __LINE__,
|
||||
pSrcStorage->ip_addr, pSrcStorage->port, file_bytes);
|
||||
formatted_ip, pSrcStorage->port, file_bytes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -196,6 +200,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
|||
FDFSGroupStat groupStat;
|
||||
FDFSStorageInfo storageStats[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||
FDFSStorageInfo *pStorageStat;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
bool found;
|
||||
|
||||
memset(pSrcStorage, 0, sizeof(ConnectionInfo));
|
||||
|
|
@ -356,9 +361,12 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
|||
return EINTR;
|
||||
}
|
||||
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"disk recovery: get source storage server %s:%u",
|
||||
__LINE__, pSrcStorage->ip_addr, pSrcStorage->port);
|
||||
__LINE__, formatted_ip, pSrcStorage->port);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -721,6 +729,7 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
|||
bool bContinueFlag;
|
||||
char local_filename[MAX_PATH_SIZE];
|
||||
char src_filename[MAX_PATH_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
pTrackerServer = tracker_get_connection_r(&trackerServer, &result);
|
||||
if (pTrackerServer == NULL)
|
||||
|
|
@ -737,10 +746,11 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
|||
noent_count = 0;
|
||||
result = 0;
|
||||
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"disk recovery thread #%d, src storage server %s:%u, "
|
||||
"recovering files of data path: %s ...", __LINE__,
|
||||
pThreadData->thread_index, pSrcStorage->ip_addr,
|
||||
pThreadData->thread_index, formatted_ip,
|
||||
pSrcStorage->port, pThreadData->base_path);
|
||||
|
||||
bContinueFlag = true;
|
||||
|
|
@ -924,10 +934,11 @@ static int storage_do_recovery(RecoveryThreadData *pThreadData,
|
|||
|
||||
if (pThreadData->done)
|
||||
{
|
||||
format_ip_address(pSrcStorage->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"disk recovery thread #%d, src storage server %s:%u, "
|
||||
"recover files of data path: %s done", __LINE__,
|
||||
pThreadData->thread_index, pSrcStorage->ip_addr,
|
||||
pThreadData->thread_index, formatted_ip,
|
||||
pSrcStorage->port, pThreadData->base_path);
|
||||
}
|
||||
|
||||
|
|
@ -1700,10 +1711,11 @@ static int storage_disk_recovery_split_trunk_binlog(const int store_path_index)
|
|||
|
||||
int storage_disk_recovery_prepare(const int store_path_index)
|
||||
{
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
ConnectionInfo srcStorage;
|
||||
ConnectionInfo *pStorageConn;
|
||||
int result;
|
||||
char *pBasePath;
|
||||
int result;
|
||||
|
||||
pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
|
||||
if ((result=recovery_init_flag_file(pBasePath, false, -1)) != 0)
|
||||
|
|
@ -1748,9 +1760,10 @@ int storage_disk_recovery_prepare(const int store_path_index)
|
|||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(pStorageConn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"try to fetch binlog from %s:%u ...", __LINE__,
|
||||
pStorageConn->ip_addr, pStorageConn->port);
|
||||
formatted_ip, pStorageConn->port);
|
||||
|
||||
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
||||
tracker_close_connection_ex(pStorageConn, true);
|
||||
|
|
@ -1759,9 +1772,10 @@ int storage_disk_recovery_prepare(const int store_path_index)
|
|||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(pStorageConn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"fetch binlog from %s:%u successfully.", __LINE__,
|
||||
pStorageConn->ip_addr, pStorageConn->port);
|
||||
formatted_ip, pStorageConn->port);
|
||||
|
||||
if ((result=storage_disk_recovery_split_trunk_binlog(
|
||||
store_path_index)) != 0)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
char reserved_space_str[32];
|
||||
char tracker_client_ip_str[256];
|
||||
char last_storage_ip_str[256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
int total_len;
|
||||
int i;
|
||||
|
|
@ -40,6 +41,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
tracker_client_ip_str, sizeof(tracker_client_ip_str));
|
||||
fdfs_multi_ips_to_string(&g_last_storage_ip,
|
||||
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,
|
||||
"SF_G_CONNECT_TIMEOUT=%ds\n"
|
||||
|
|
@ -49,7 +51,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
"SF_G_CONTINUE_FLAG=%d\n"
|
||||
"g_schedule_flag=%d\n"
|
||||
"SF_G_INNER_PORT=%d\n"
|
||||
"g_max_connections=%d\n"
|
||||
"SF_G_MAX_CONNECTIONS=%d\n"
|
||||
"g_storage_thread_count=%d\n"
|
||||
"g_group_name=%s\n"
|
||||
"g_subdir_count_per_path=%d\n"
|
||||
|
|
@ -143,7 +145,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
, g_fdfs_version.patch, SF_G_CONTINUE_FLAG
|
||||
, g_schedule_flag
|
||||
, SF_G_INNER_PORT
|
||||
, g_sf_global_vars.max_connections
|
||||
, SF_G_MAX_CONNECTIONS
|
||||
, SF_G_ALIVE_THREAD_COUNT
|
||||
, g_group_name
|
||||
, g_subdir_count_per_path
|
||||
|
|
@ -208,18 +210,18 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
, g_slot_min_size
|
||||
, g_trunk_file_size
|
||||
, g_store_path_mode
|
||||
, fdfs_storage_reserved_space_to_string( \
|
||||
&g_storage_reserved_space, reserved_space_str) \
|
||||
, fdfs_storage_reserved_space_to_string(
|
||||
&g_storage_reserved_space, reserved_space_str)
|
||||
, g_avg_storage_reserved_mb
|
||||
, g_store_path_index
|
||||
, g_current_trunk_file_id
|
||||
, g_trunk_sync_thread_count
|
||||
, g_trunk_server.connections[0].ip_addr
|
||||
, formatted_ip
|
||||
, g_trunk_server.connections[0].port
|
||||
, g_trunk_total_free_space
|
||||
, g_use_connection_pool
|
||||
, 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
|
||||
#ifdef WITH_HTTPD
|
||||
, g_http_params.disabled
|
||||
|
|
@ -272,6 +274,7 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
|||
int total_len;
|
||||
TrackerServerInfo *pTrackerServer;
|
||||
TrackerServerInfo *pTrackerEnd;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
total_len = snprintf(buff, buffSize, \
|
||||
"\ng_tracker_group.server_count=%d, " \
|
||||
|
|
@ -287,11 +290,12 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
|||
for (pTrackerServer=g_tracker_group.servers; \
|
||||
pTrackerServer<pTrackerEnd; pTrackerServer++)
|
||||
{
|
||||
format_ip_address(pTrackerServer->connections[0].
|
||||
ip_addr, formatted_ip);
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
"\t%d. tracker server=%s:%u\n",
|
||||
(int)(pTrackerServer - g_tracker_group.servers) + 1,
|
||||
pTrackerServer->connections[0].ip_addr,
|
||||
pTrackerServer->connections[0].port);
|
||||
formatted_ip, pTrackerServer->connections[0].port);
|
||||
}
|
||||
|
||||
return total_len;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ static int storage_check_and_make_data_dirs();
|
|||
static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
||||
{
|
||||
char out_buff[sizeof(TrackerHeader) + 4];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
char *pInBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -154,12 +155,11 @@ static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
|||
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, send data fail, " \
|
||||
"errno: %d, error info: %s.", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, errno: %d, "
|
||||
"error info: %s.", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -175,11 +175,11 @@ static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
|
|||
|
||||
if (in_bytes != FDFS_GROUP_NAME_MAX_LEN)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, recv body length: " \
|
||||
"%"PRId64" != %d", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, recv body length: %"PRId64" != %d",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
in_bytes, FDFS_GROUP_NAME_MAX_LEN);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -1410,6 +1410,7 @@ static int storage_check_tracker_ipaddr(const char *filename)
|
|||
TrackerServerInfo *pEnd;
|
||||
ConnectionInfo *conn;
|
||||
ConnectionInfo *conn_end;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
pEnd = g_tracker_group.servers + g_tracker_group.server_count;
|
||||
for (pServer=g_tracker_group.servers; pServer<pEnd; pServer++)
|
||||
|
|
@ -1417,13 +1418,13 @@ static int storage_check_tracker_ipaddr(const char *filename)
|
|||
conn_end = pServer->connections + pServer->count;
|
||||
for (conn=pServer->connections; conn<conn_end; conn++)
|
||||
{
|
||||
//logInfo("server=%s:%u\n", conn->ip_addr, conn->port);
|
||||
if (strcmp(conn->ip_addr, "127.0.0.1") == 0)
|
||||
if (is_loopback_ip(conn->ip_addr))
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"conf file \"%s\", tracker: \"%s:%u\" is invalid, "
|
||||
"tracker server ip can't be 127.0.0.1",
|
||||
__LINE__, filename, conn->ip_addr, conn->port);
|
||||
"tracker server ip can't be loopback address",
|
||||
__LINE__, filename, formatted_ip, conn->port);
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -2256,6 +2257,7 @@ static int storage_get_my_ip_from_tracker(ConnectionInfo *conn,
|
|||
char *ip_addrs, const int buff_size)
|
||||
{
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -2269,21 +2271,21 @@ static int storage_get_my_ip_from_tracker(ConnectionInfo *conn,
|
|||
if((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s.",
|
||||
__LINE__, conn->ip_addr, conn->port,
|
||||
result, STRERROR(result));
|
||||
"tracker server %s:%u, send data fail, errno: %d, "
|
||||
"error info: %s.", __LINE__, formatted_ip,
|
||||
conn->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result=fdfs_recv_response(conn, &ip_addrs,
|
||||
buff_size - 1, &in_bytes)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, recv response fail, "
|
||||
"errno: %d, error info: %s.",
|
||||
__LINE__, conn->ip_addr, conn->port,
|
||||
"tracker server %s:%u, recv response fail, errno: %d, "
|
||||
"error info: %s.", __LINE__, formatted_ip, conn->port,
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2297,6 +2299,7 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
{
|
||||
char my_ip_addrs[256];
|
||||
char error_info[256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
FDFSMultiIP multi_ip;
|
||||
int result;
|
||||
int i;
|
||||
|
|
@ -2327,13 +2330,12 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
if ((result=fdfs_check_and_format_ips(&g_tracker_client_ip,
|
||||
error_info, sizeof(error_info))) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logCrit("file: "__FILE__", line: %d, "
|
||||
"as a client of tracker server %s:%u, "
|
||||
"my ip: %s not valid, error info: %s. "
|
||||
"program exit!", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
multi_ip.ips[i].address, error_info);
|
||||
|
||||
"program exit!", __LINE__, formatted_ip,
|
||||
conn->port, multi_ip.ips[i].address, error_info);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -2345,11 +2347,12 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
|
||||
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
||||
ip_str, sizeof(ip_str));
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"as a client of tracker server %s:%u, "
|
||||
"my ip: %s not consistent with client ips: %s "
|
||||
"of other tracker client. program exit!", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
"of other tracker client. program exit!",
|
||||
__LINE__, formatted_ip, conn->port,
|
||||
multi_ip.ips[i].address, ip_str);
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ static int storage_do_changelog_req(ConnectionInfo *pTrackerServer)
|
|||
{
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
FDFS_STORAGE_ID_MAX_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
|
||||
|
|
@ -44,15 +45,14 @@ static int storage_do_changelog_req(ConnectionInfo *pTrackerServer)
|
|||
strcpy(out_buff + sizeof(TrackerHeader), g_group_name);
|
||||
strcpy(out_buff + sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, send data fail, " \
|
||||
"errno: %d, error info: %s.", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s.", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +64,7 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
|||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
2 * IP_ADDRESS_SIZE];
|
||||
char in_buff[1];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
TrackerHeader *pHeader;
|
||||
int result;
|
||||
|
|
@ -83,10 +84,10 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
|||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, send data fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -108,12 +109,12 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
|||
}
|
||||
else
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, recv data fail or "
|
||||
"response status != 0, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
"response status != 0, errno: %d, error info: %s",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
result, STRERROR(result));
|
||||
return result == EBUSY ? 0 : result;
|
||||
}
|
||||
}
|
||||
|
|
@ -126,6 +127,7 @@ int storage_get_my_tracker_client_ip()
|
|||
TrackerServerInfo trackerServer;
|
||||
ConnectionInfo *conn;
|
||||
char tracker_client_ip[IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int success_count;
|
||||
int result;
|
||||
int i;
|
||||
|
|
@ -159,12 +161,11 @@ int storage_get_my_tracker_client_ip()
|
|||
|
||||
if (conn == NULL)
|
||||
{
|
||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTServer->connections[0].ip_addr,
|
||||
pTServer->connections[0].port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTServer->connections[0].port, result, STRERROR(result));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
@ -199,6 +200,7 @@ static int storage_report_storage_ip_addr()
|
|||
TrackerServerInfo *pTServer;
|
||||
TrackerServerInfo *pTServerEnd;
|
||||
TrackerServerInfo trackerServer;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
ConnectionInfo *conn;
|
||||
int success_count;
|
||||
int result;
|
||||
|
|
@ -248,12 +250,11 @@ static int storage_report_storage_ip_addr()
|
|||
|
||||
if (conn == NULL)
|
||||
{
|
||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTServer->connections[0].ip_addr,
|
||||
pTServer->connections[0].port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTServer->connections[0].port, result, STRERROR(result));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
@ -286,6 +287,7 @@ int storage_changelog_req()
|
|||
TrackerServerInfo *pTServer;
|
||||
TrackerServerInfo *pTServerEnd;
|
||||
TrackerServerInfo trackerServer;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
ConnectionInfo *conn;
|
||||
int success_count;
|
||||
int result;
|
||||
|
|
@ -319,12 +321,11 @@ int storage_changelog_req()
|
|||
|
||||
if (conn == NULL)
|
||||
{
|
||||
format_ip_address(pTServer->connections[0].ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTServer->connections[0].ip_addr,
|
||||
pTServer->connections[0].port,
|
||||
result, STRERROR(result));
|
||||
"errno: %d, error info: %s", __LINE__, formatted_ip,
|
||||
pTServer->connections[0].port, result, STRERROR(result));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
|||
char *pBuff;
|
||||
char full_filename[MAX_PATH_SIZE];
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
struct stat stat_buf;
|
||||
FDFSTrunkFullInfo trunkInfo;
|
||||
|
|
@ -145,26 +146,26 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
|||
{
|
||||
if (file_info.file_size == stat_buf.st_size)
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"sync data file, logic file: %s " \
|
||||
"on dest server %s:%u already exists, "\
|
||||
"and same as mine, ignore it", \
|
||||
__LINE__, pRecord->filename, \
|
||||
pStorageServer->ip_addr, \
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"sync data file, logic file: %s "
|
||||
"on dest server %s:%u already exists, "
|
||||
"and same as mine, ignore it", __LINE__,
|
||||
pRecord->filename, formatted_ip,
|
||||
pStorageServer->port);
|
||||
}
|
||||
need_sync_file = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, " \
|
||||
"sync data file, logic file: %s " \
|
||||
"on dest server %s:%u already exists, "\
|
||||
"but file size: %"PRId64 \
|
||||
" not same as mine: %"PRId64 \
|
||||
", need re-sync it", __LINE__, \
|
||||
pRecord->filename, pStorageServer->ip_addr,\
|
||||
pStorageServer->port, \
|
||||
file_info.file_size, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"sync data file, logic file: %s "
|
||||
"on dest server %s:%u already exists, "
|
||||
"but file size: %"PRId64" not same as mine: %"PRId64
|
||||
", need re-sync it", __LINE__, pRecord->filename,
|
||||
formatted_ip, pStorageServer->port, file_info.file_size,
|
||||
(int64_t)stat_buf.st_size);
|
||||
|
||||
proto_cmd = STORAGE_PROTO_CMD_SYNC_UPDATE_FILE;
|
||||
|
|
@ -227,16 +228,14 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
|||
memcpy(p, pRecord->filename, 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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"sync data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -245,13 +244,11 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
|||
full_filename, file_offset, stat_buf.st_size, \
|
||||
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"sync data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -276,13 +273,13 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
|
|||
|
||||
if (result == EEXIST)
|
||||
{
|
||||
if (need_sync_file && pRecord->op_type == \
|
||||
if (need_sync_file && pRecord->op_type ==
|
||||
STORAGE_OP_TYPE_SOURCE_CREATE_FILE)
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, " \
|
||||
"storage server ip: %s:%u, data file: %s " \
|
||||
"already exists, maybe some mistake?", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"storage server ip: %s:%u, data file: %s already exists, "
|
||||
"maybe some mistake?", __LINE__, formatted_ip,
|
||||
pStorageServer->port, pRecord->filename);
|
||||
}
|
||||
|
||||
|
|
@ -320,6 +317,7 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
|||
char *fields[SYNC_MODIFY_FIELD_COUNT];
|
||||
char full_filename[MAX_PATH_SIZE];
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
struct stat stat_buf;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -427,13 +425,11 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
|||
if((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
p - out_buff, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"sync data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -441,13 +437,11 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
|
|||
full_filename, start_offset, modify_length, \
|
||||
SF_G_NETWORK_TIMEOUT, &total_send_bytes)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"sync data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -491,6 +485,7 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
|
|||
char *fields[SYNC_TRUNCATE_FIELD_COUNT];
|
||||
char full_filename[MAX_PATH_SIZE];
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
struct stat stat_buf;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -589,16 +584,14 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
|
|||
memcpy(p, pRecord->filename, 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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"sync data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"sync data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -627,6 +620,7 @@ static int storage_sync_delete_file(ConnectionInfo *pStorageServer, \
|
|||
{
|
||||
TrackerHeader *pHeader;
|
||||
char out_buff[sizeof(TrackerHeader)+FDFS_GROUP_NAME_MAX_LEN+256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
struct stat stat_buf;
|
||||
FDFSTrunkFullInfo trunkInfo;
|
||||
FDFSTrunkHeader trunkHeader;
|
||||
|
|
@ -666,12 +660,11 @@ static int storage_sync_delete_file(ConnectionInfo *pStorageServer, \
|
|||
sizeof(TrackerHeader) + 4 + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
pRecord->filename_len, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("FILE: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -702,6 +695,7 @@ static int storage_report_my_server_id(ConnectionInfo *pStorageServer)
|
|||
int result;
|
||||
TrackerHeader *pHeader;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
char *pBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -716,12 +710,11 @@ static int storage_report_my_server_id(ConnectionInfo *pStorageServer)
|
|||
sizeof(TrackerHeader) + FDFS_STORAGE_ID_MAX_SIZE, \
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("FILE: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -751,6 +744,7 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
|
|||
int result;
|
||||
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE + \
|
||||
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
FDFSTrunkFullInfo trunkInfo;
|
||||
FDFSTrunkHeader trunkHeader;
|
||||
|
|
@ -937,16 +931,15 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
|
|||
long2buff(out_body_len, pHeader->pkg_len);
|
||||
pHeader->cmd = STORAGE_PROTO_CMD_SYNC_CREATE_LINK;
|
||||
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
sizeof(TrackerHeader) + out_body_len, \
|
||||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff,
|
||||
sizeof(TrackerHeader) + out_body_len,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("FILE: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -984,6 +977,7 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
|||
int result;
|
||||
char out_buff[sizeof(TrackerHeader) + 2 * FDFS_PROTO_PKG_LEN_SIZE +
|
||||
4 + FDFS_GROUP_NAME_MAX_LEN + 256];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
int out_body_len;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -1049,10 +1043,10 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
|||
sizeof(TrackerHeader) + out_body_len,
|
||||
SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pStorageServer->ip_addr,
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorageServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1069,10 +1063,13 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
|
|||
}
|
||||
else if (result == EEXIST)
|
||||
{
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"storage server ip: %s:%u, data file: %s "
|
||||
"already exists", __LINE__, pStorageServer->ip_addr,
|
||||
"already exists", __LINE__, formatted_ip,
|
||||
pStorageServer->port, pRecord->filename);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
@ -1997,6 +1994,7 @@ int storage_report_storage_status(const char *storage_id, \
|
|||
TrackerServerInfo *pGlobalServer;
|
||||
TrackerServerInfo *pTServer;
|
||||
TrackerServerInfo *pTServerEnd;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
ConnectionInfo *conn;
|
||||
int result;
|
||||
int report_count;
|
||||
|
|
@ -2063,12 +2061,12 @@ int storage_report_storage_status(const char *storage_id, \
|
|||
|
||||
if (conn == NULL)
|
||||
{
|
||||
format_ip_address(pTServer->connections[0].
|
||||
ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTServer->connections[0].ip_addr,
|
||||
pTServer->connections[0].port,
|
||||
result, STRERROR(result));
|
||||
"connect to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip, pTServer->
|
||||
connections[0].port, result, STRERROR(result));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2861,6 +2859,7 @@ static void storage_sync_thread_exit(ConnectionInfo *pStorage)
|
|||
int i;
|
||||
int thread_count;
|
||||
pthread_t tid;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if ((result=pthread_mutex_lock(&sync_thread_lock)) != 0)
|
||||
{
|
||||
|
|
@ -2896,9 +2895,12 @@ static void storage_sync_thread_exit(ConnectionInfo *pStorage)
|
|||
__LINE__, result, STRERROR(result));
|
||||
}
|
||||
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"sync thread to storage server %s:%u exit",
|
||||
__LINE__, pStorage->ip_addr, pStorage->port);
|
||||
__LINE__, formatted_ip, pStorage->port);
|
||||
}
|
||||
}
|
||||
|
||||
static void* storage_sync_thread_entrance(void* arg)
|
||||
|
|
@ -2908,6 +2910,7 @@ static void* storage_sync_thread_entrance(void* arg)
|
|||
StorageBinLogRecord record;
|
||||
ConnectionInfo storage_server;
|
||||
char local_ip_addr[IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int read_result;
|
||||
int sync_result;
|
||||
int result;
|
||||
|
|
@ -2954,9 +2957,12 @@ static void* storage_sync_thread_entrance(void* arg)
|
|||
start_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, "
|
||||
"sync thread to storage server %s:%u started",
|
||||
__LINE__, storage_server.ip_addr, storage_server.port);
|
||||
__LINE__, formatted_ip, storage_server.port);
|
||||
}
|
||||
|
||||
while (SF_G_CONTINUE_FLAG && \
|
||||
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
|||
FDFSMultiIP ip_addrs;
|
||||
FDFSMultiIP *multi_ip;
|
||||
const char *bind_addr;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
multi_ip = NULL;
|
||||
if (g_use_storage_id)
|
||||
|
|
@ -118,10 +119,12 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
|||
", continuous fail count: %d",
|
||||
nContinuousFail);
|
||||
}
|
||||
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"successfully connect to "
|
||||
"storage server %s:%u%s", __LINE__,
|
||||
conn->ip_addr, SF_G_INNER_PORT, szFailPrompt);
|
||||
formatted_ip, SF_G_INNER_PORT, szFailPrompt);
|
||||
nContinuousFail = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -129,10 +132,11 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
|||
nContinuousFail++;
|
||||
if (previousCodes[i] != conn_results[i])
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to storage server %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, conn->ip_addr, SF_G_INNER_PORT,
|
||||
__LINE__, formatted_ip, SF_G_INNER_PORT,
|
||||
conn_results[i], STRERROR(conn_results[i]));
|
||||
previousCodes[i] = conn_results[i];
|
||||
}
|
||||
|
|
@ -155,10 +159,11 @@ void storage_sync_connect_storage_server_ex(const FDFSStorageBrief *pStorage,
|
|||
avg_fails = (nContinuousFail + ip_addrs.count - 1) / ip_addrs.count;
|
||||
for (i=0; i<ip_addrs.count; i++)
|
||||
{
|
||||
format_ip_address(ip_addrs.ips[i].address, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to storage server %s:%u fail, "
|
||||
"try count: %d, errno: %d, error info: %s",
|
||||
__LINE__, ip_addrs.ips[i].address, SF_G_INNER_PORT, avg_fails,
|
||||
__LINE__, formatted_ip, SF_G_INNER_PORT, avg_fails,
|
||||
conn_results[i], STRERROR(conn_results[i]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -35,6 +35,7 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
|||
char *p;
|
||||
int result;
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + 5];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
FDFSTrunkInfoBuff trunkBuff;
|
||||
int64_t in_bytes;
|
||||
|
||||
|
|
@ -50,15 +51,14 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
|||
long2buff(FDFS_GROUP_NAME_MAX_LEN + 5, pHeader->pkg_len);
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrunkServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -74,11 +74,12 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
|
|||
|
||||
if (in_bytes != sizeof(FDFSTrunkInfoBuff))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u, recv body length: %d invalid, " \
|
||||
"expect body length: %d", __LINE__, \
|
||||
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||
(int)in_bytes, (int)sizeof(FDFSTrunkInfoBuff));
|
||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u, recv body length: %d invalid, "
|
||||
"expect body length: %d", __LINE__, formatted_ip,
|
||||
pTrunkServer->port, (int)in_bytes,
|
||||
(int)sizeof(FDFSTrunkInfoBuff));
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +98,7 @@ static int trunk_client_connect_trunk_server(TrackerServerInfo *trunk_server,
|
|||
ConnectionInfo **conn, const char *prompt)
|
||||
{
|
||||
int result;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if (g_trunk_server.count == 0)
|
||||
{
|
||||
|
|
@ -108,10 +110,11 @@ static int trunk_client_connect_trunk_server(TrackerServerInfo *trunk_server,
|
|||
memcpy(trunk_server, &g_trunk_server, sizeof(TrackerServerInfo));
|
||||
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, "
|
||||
"%s because connect to trunk "
|
||||
"server %s:%u fail, errno: %d", __LINE__,
|
||||
prompt, trunk_server->connections[0].ip_addr,
|
||||
"%s because connect to trunk server %s:%u fail, "
|
||||
"errno: %d", __LINE__, prompt, formatted_ip,
|
||||
trunk_server->connections[0].port, result);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -167,6 +170,7 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
|||
int result;
|
||||
char out_buff[sizeof(TrackerHeader) \
|
||||
+ STORAGE_TRUNK_ALLOC_CONFIRM_REQ_BODY_LEN];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
pHeader = (TrackerHeader *)out_buff;
|
||||
pTrunkBuff = (FDFSTrunkInfoBuff *)(out_buff + sizeof(TrackerHeader) \
|
||||
|
|
@ -185,15 +189,14 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
|||
int2buff(pTrunkInfo->file.offset, pTrunkBuff->offset);
|
||||
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)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrunkServer->ip_addr, pTrunkServer->port, \
|
||||
result, STRERROR(result));
|
||||
|
||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrunkServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -207,11 +210,11 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
|
|||
|
||||
if (in_bytes != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"should == 0", __LINE__, pTrunkServer->ip_addr, \
|
||||
pTrunkServer->port, in_bytes);
|
||||
format_ip_address(pTrunkServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u response data length: "
|
||||
"%"PRId64" is invalid, should == 0", __LINE__,
|
||||
formatted_ip, pTrunkServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1953,6 +1953,7 @@ static void trunk_sync_thread_exit(TrunkSyncThreadInfo *thread_data,
|
|||
const int port)
|
||||
{
|
||||
int result;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if ((result=pthread_mutex_lock(&trunk_sync_thread_lock)) != 0)
|
||||
{
|
||||
|
|
@ -1973,9 +1974,10 @@ static void trunk_sync_thread_exit(TrunkSyncThreadInfo *thread_data,
|
|||
__LINE__, result, STRERROR(result));
|
||||
}
|
||||
|
||||
format_ip_address(thread_data->pStorage->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"trunk sync thread to storage server %s:%u exit",
|
||||
__LINE__, thread_data->pStorage->ip_addr, port);
|
||||
__LINE__, formatted_ip, port);
|
||||
}
|
||||
|
||||
static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
||||
|
|
@ -1985,6 +1987,7 @@ static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
|||
char *p;
|
||||
int result;
|
||||
TrackerHeader header;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
char *pBuff;
|
||||
int64_t in_bytes;
|
||||
|
|
@ -2009,25 +2012,25 @@ static int trunk_sync_data(TrunkBinLogReader *pReader, \
|
|||
memset(&header, 0, sizeof(header));
|
||||
long2buff(length, header.pkg_len);
|
||||
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)
|
||||
{
|
||||
logError("FILE: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorage->ip_addr, pStorage->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorage->port, result, STRERROR(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)
|
||||
{
|
||||
logError("FILE: "__FILE__", line: %d, " \
|
||||
"send data to storage server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pStorage->ip_addr, pStorage->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pStorage->ip_addr, formatted_ip);
|
||||
logError("FILE: "__FILE__", line: %d, "
|
||||
"send data to storage server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pStorage->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -2057,6 +2060,7 @@ static void *trunk_sync_thread_entrance(void* arg)
|
|||
TrunkBinLogReader reader;
|
||||
ConnectionInfo storage_server;
|
||||
char local_ip_addr[IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int read_result;
|
||||
int sync_result;
|
||||
int result;
|
||||
|
|
@ -2085,9 +2089,10 @@ static void *trunk_sync_thread_entrance(void* arg)
|
|||
storage_server.port = SF_G_INNER_PORT;
|
||||
storage_server.sock = -1;
|
||||
|
||||
logInfo("file: "__FILE__", line: %d, " \
|
||||
format_ip_address(storage_server.ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"trunk sync thread to storage server %s:%u started",
|
||||
__LINE__, storage_server.ip_addr, storage_server.port);
|
||||
__LINE__, formatted_ip, storage_server.port);
|
||||
|
||||
while (SF_G_CONTINUE_FLAG && g_if_trunker_self && \
|
||||
pStorage->status != FDFS_STORAGE_STATUS_DELETED && \
|
||||
|
|
|
|||
|
|
@ -567,6 +567,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
TrackerHeader *pHeader;
|
||||
ConnectionInfo *conn;
|
||||
char out_buff[sizeof(TrackerHeader) + sizeof(FDFSFetchStorageIdsBody)];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *p;
|
||||
char *response;
|
||||
struct data_info {
|
||||
|
|
@ -603,10 +604,11 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
formatted_ip, conn->port,
|
||||
result, STRERROR(result));
|
||||
}
|
||||
else
|
||||
|
|
@ -628,9 +630,10 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
|
||||
if (in_bytes < 2 * sizeof(int))
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, recv data length: %d "
|
||||
"is invalid", __LINE__, conn->ip_addr,
|
||||
"is invalid", __LINE__, formatted_ip,
|
||||
conn->port, (int)in_bytes);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -640,10 +643,11 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
current_count = buff2int(response + sizeof(int));
|
||||
if (total_count <= start_index)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, total storage "
|
||||
"count: %d is invalid, which <= start "
|
||||
"index: %d", __LINE__, conn->ip_addr,
|
||||
"index: %d", __LINE__, formatted_ip,
|
||||
conn->port, total_count, start_index);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -651,10 +655,11 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
|
||||
if (current_count <= 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, current storage "
|
||||
"count: %d is invalid, which <= 0", __LINE__,
|
||||
conn->ip_addr, conn->port, current_count);
|
||||
formatted_ip, conn->port, current_count);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -677,10 +682,11 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
|
||||
if (list_count == MAX_REQUEST_LOOP)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"response data from tracker "
|
||||
"server %s:%u is too large",
|
||||
__LINE__, conn->ip_addr, conn->port);
|
||||
"response data from tracker server "
|
||||
"%s:%u is too large", __LINE__,
|
||||
formatted_ip, conn->port);
|
||||
result = ENOSPC;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ int fdfs_server_info_to_string_ex(const TrackerServerInfo *pServer,
|
|||
{
|
||||
*(buff + len++) = ']';
|
||||
}
|
||||
len += snprintf(buff + len, buffSize - len, ":%d", port);
|
||||
len += snprintf(buff + len, buffSize - len, ":%u", port);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
|||
"SF_G_CONTINUE_FLAG=%d\n"
|
||||
"g_schedule_flag=%d\n"
|
||||
"SF_G_INNER_PORT=%d\n"
|
||||
"g_max_connections=%d\n"
|
||||
"SF_G_MAX_CONNECTIONS=%d\n"
|
||||
"g_tracker_thread_count=%d\n"
|
||||
"g_sync_log_buff_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_schedule_flag
|
||||
, SF_G_INNER_PORT
|
||||
, g_sf_global_vars.max_connections
|
||||
, SF_G_MAX_CONNECTIONS
|
||||
, g_sf_context.thread_count
|
||||
, g_sf_global_vars.error_log.sync_log_buff_interval
|
||||
, g_check_active_interval
|
||||
|
|
@ -444,9 +444,8 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
|||
fdfs_server_info_to_string(pTrackerServer, ip_str, sizeof(ip_str));
|
||||
|
||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||
"\t%d. tracker server=%s:%u\n", \
|
||||
(int)(pTrackerServer - g_tracker_servers.servers) + 1, \
|
||||
ip_str, pTrackerServer->connections[0].port);
|
||||
"\t%d. tracker server=%s\n", (int)(pTrackerServer -
|
||||
g_tracker_servers.servers) + 1, ip_str);
|
||||
}
|
||||
|
||||
return total_len;
|
||||
|
|
|
|||
|
|
@ -1787,6 +1787,7 @@ int tracker_save_storages()
|
|||
char trueFilename[MAX_PATH_SIZE];
|
||||
char buff[4096];
|
||||
char id_buff[128];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int fd;
|
||||
int len;
|
||||
FDFSGroupInfo **ppGroup;
|
||||
|
|
@ -1838,6 +1839,7 @@ int tracker_save_storages()
|
|||
}
|
||||
|
||||
count++;
|
||||
format_ip_address(FDFS_CURRENT_IP_ADDR(pStorage), formatted_ip);
|
||||
len = sprintf(buff, \
|
||||
"# storage %s:%u\n" \
|
||||
"[%s"STORAGE_SECTION_NO_FORMAT"]\n" \
|
||||
|
|
@ -1894,8 +1896,7 @@ int tracker_save_storages()
|
|||
"\t%s=%d\n" \
|
||||
"\t%s=%d\n" \
|
||||
"\t%s=%"PRId64"\n\n", \
|
||||
FDFS_CURRENT_IP_ADDR(pStorage), \
|
||||
pStorage->storage_port, \
|
||||
formatted_ip, pStorage->storage_port, \
|
||||
STORAGE_SECTION_NAME_PREFIX, count, id_buff, \
|
||||
STORAGE_ITEM_GROUP_NAME, \
|
||||
(*ppGroup)->group_name, \
|
||||
|
|
@ -3415,6 +3416,7 @@ int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id)
|
|||
FDFSStorageDetail *pStorageServer;
|
||||
FDFSStorageDetail **ppServer;
|
||||
FDFSStorageDetail **ppEnd;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
pStorageServer = tracker_mem_get_storage(pGroup, id);
|
||||
if (pStorageServer == NULL || pStorageServer->status == \
|
||||
|
|
@ -3445,10 +3447,14 @@ 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, "
|
||||
"delete storage server: %s:%u, group: %s",
|
||||
__LINE__, pStorageServer->ip_addrs.ips[0].address,
|
||||
pStorageServer->storage_port, pGroup->group_name);
|
||||
"delete storage server: %s:%u, group: %s", __LINE__,
|
||||
formatted_ip, pStorageServer->storage_port,
|
||||
pGroup->group_name);
|
||||
}
|
||||
|
||||
tracker_mem_clear_storage_fields(pStorageServer);
|
||||
|
||||
|
|
@ -3840,6 +3846,7 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
|||
{
|
||||
char out_buff[sizeof(TrackerHeader) + 1 + FDFS_PROTO_PKG_LEN_SIZE];
|
||||
char in_buff[TRACKER_MAX_PACKAGE_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
char *p;
|
||||
char *pInBuff;
|
||||
|
|
@ -3859,13 +3866,12 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
|||
if ((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"send data to tracker server %s:%u fail, " \
|
||||
"errno: %d, error info: %s", __LINE__, \
|
||||
pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
formatted_ip, pTrackerServer->port,
|
||||
result, STRERROR(result));
|
||||
|
||||
return (result == ENOENT ? EACCES : result);
|
||||
}
|
||||
|
||||
|
|
@ -3882,11 +3888,12 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (in_bytes < FDFS_PROTO_PKG_LEN_SIZE)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u response data " \
|
||||
"length: %"PRId64" is invalid, " \
|
||||
"expect length >= %d.", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, "
|
||||
"expect length >= %d.", __LINE__,
|
||||
formatted_ip, pTrackerServer->port,
|
||||
in_bytes, FDFS_PROTO_PKG_LEN_SIZE);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -3896,20 +3903,21 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
|
|||
|
||||
if (*file_size < 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, file size: %"PRId64\
|
||||
" < 0", __LINE__, pTrackerServer->ip_addr, \
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, file size: %"PRId64
|
||||
" < 0", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, *file_size);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (*file_size > 0 && write_bytes == 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server %s:%u, file size: %"PRId64\
|
||||
" > 0, but file content is empty", __LINE__, \
|
||||
pTrackerServer->ip_addr, pTrackerServer->port, \
|
||||
*file_size);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, file size: %"PRId64
|
||||
" > 0, but file content is empty", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, *file_size);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -4268,6 +4276,7 @@ static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
|||
TrackerServerInfo *pTrackerEnd;
|
||||
TrackerRunningStatus *pStatus;
|
||||
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int count;
|
||||
int result;
|
||||
int r;
|
||||
|
|
@ -4309,17 +4318,20 @@ static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
|||
tracker_mem_cmp_tracker_running_status);
|
||||
}
|
||||
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
format_ip_address(trackerStatus[i].pTrackerServer->
|
||||
connections[0].ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"%s:%u leader: %d, running time: %d, "
|
||||
"restart interval: %d", __LINE__,
|
||||
trackerStatus[i].pTrackerServer->connections[0].ip_addr,
|
||||
"restart interval: %d", __LINE__, formatted_ip,
|
||||
trackerStatus[i].pTrackerServer->connections[0].port,
|
||||
trackerStatus[i].if_leader,
|
||||
trackerStatus[i].running_time,
|
||||
trackerStatus[i].restart_interval);
|
||||
}
|
||||
}
|
||||
|
||||
//copy the last
|
||||
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
||||
|
|
@ -4335,6 +4347,7 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
|||
TrackerServerInfo *pTrackerServer;
|
||||
FDFSGroups newGroups;
|
||||
FDFSGroups tempGroups;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if (pJoinBody->tracker_count == 0)
|
||||
{
|
||||
|
|
@ -4352,11 +4365,12 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
|||
if (tracker_mem_cmp_tracker_running_status(pRunningStatus,
|
||||
&trackerStatus) >= 0)
|
||||
{
|
||||
format_ip_address(trackerStatus.pTrackerServer->
|
||||
connections[0].ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"%s:%u running time: %d, restart interval: %d, "
|
||||
"my running time: %d, restart interval: %d, "
|
||||
"do not need sync system files", __LINE__,
|
||||
trackerStatus.pTrackerServer->connections[0].ip_addr,
|
||||
"do not need sync system files", __LINE__, formatted_ip,
|
||||
trackerStatus.pTrackerServer->connections[0].port,
|
||||
trackerStatus.running_time,
|
||||
trackerStatus.restart_interval,
|
||||
|
|
@ -4374,10 +4388,10 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
|
|||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(pTrackerServer->connections[0].ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"sys files loaded from tracker server %s:%u",
|
||||
__LINE__, pTrackerServer->connections[0].ip_addr,
|
||||
pTrackerServer->connections[0].port);
|
||||
"sys files loaded from tracker server %s:%u", __LINE__,
|
||||
formatted_ip, pTrackerServer->connections[0].port);
|
||||
|
||||
memset(&newGroups, 0, sizeof(newGroups));
|
||||
newGroups.store_lookup = g_groups.store_lookup;
|
||||
|
|
@ -4419,6 +4433,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
|||
FDFSStorageDetail **ppServer;
|
||||
FDFSStorageDetail **ppEnd;
|
||||
FDFSStorageId storage_id;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
tracker_mem_file_lock();
|
||||
|
||||
|
|
@ -4689,12 +4704,13 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
|
|||
pJoinBody->status == FDFS_STORAGE_STATUS_IP_CHANGED || \
|
||||
pJoinBody->status == FDFS_STORAGE_STATUS_NONE)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s:%u, invalid storage " \
|
||||
"status %d, in the group \"%s\"", \
|
||||
__LINE__, ip_addr, \
|
||||
pJoinBody->storage_port, \
|
||||
pJoinBody->status, \
|
||||
format_ip_address(ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s:%u, invalid storage "
|
||||
"status %d, in the group \"%s\"",
|
||||
__LINE__, formatted_ip,
|
||||
pJoinBody->storage_port,
|
||||
pJoinBody->status,
|
||||
pJoinBody->group_name);
|
||||
return EFAULT;
|
||||
}
|
||||
|
|
@ -4891,6 +4907,7 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
|||
FDFSStorageDetail target_storage;
|
||||
FDFSStorageDetail *pTargetStorage;
|
||||
FDFSStorageDetail **ppFound;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if ((result=pthread_mutex_lock(&mem_thread_lock)) != 0)
|
||||
{
|
||||
|
|
@ -4938,11 +4955,12 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
|
|||
continue;
|
||||
}
|
||||
|
||||
format_ip_address(FDFS_CURRENT_IP_ADDR(*ppFound),
|
||||
formatted_ip);
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"storage server: %s:%u, dest status: %d, "
|
||||
"my status: %d, should change my status!",
|
||||
__LINE__, FDFS_CURRENT_IP_ADDR(*ppFound),
|
||||
(*ppFound)->storage_port,
|
||||
__LINE__, formatted_ip, (*ppFound)->storage_port,
|
||||
pServer->status, (*ppFound)->status);
|
||||
|
||||
if (pServer->status == \
|
||||
|
|
@ -5036,6 +5054,7 @@ static int _storage_get_trunk_binlog_size(
|
|||
ConnectionInfo *pStorageServer, int64_t *file_size)
|
||||
{
|
||||
char out_buff[sizeof(TrackerHeader)];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[8];
|
||||
TrackerHeader *pHeader;
|
||||
char *pInBuff;
|
||||
|
|
@ -5048,11 +5067,11 @@ static int _storage_get_trunk_binlog_size(
|
|||
if ((result=tcpsenddata_nb(pStorageServer->sock, out_buff, \
|
||||
sizeof(out_buff), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u, send data fail, " \
|
||||
"errno: %d, error info: %s.", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
pStorageServer->port, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s.", __LINE__,
|
||||
formatted_ip, pStorageServer->port,
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -5069,10 +5088,10 @@ static int _storage_get_trunk_binlog_size(
|
|||
|
||||
if (in_bytes != sizeof(in_buff))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"storage server %s:%u, recv body length: " \
|
||||
"%"PRId64" != %d", \
|
||||
__LINE__, pStorageServer->ip_addr, \
|
||||
format_ip_address(pStorageServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u, recv body length: "
|
||||
"%"PRId64" != %d", __LINE__, formatted_ip,
|
||||
pStorageServer->port, in_bytes, (int)sizeof(in_buff));
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -5086,6 +5105,7 @@ static int tracker_mem_get_trunk_binlog_size(
|
|||
{
|
||||
ConnectionInfo storage_server;
|
||||
ConnectionInfo *conn;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
|
||||
*file_size = 0;
|
||||
|
|
@ -5100,11 +5120,13 @@ static int tracker_mem_get_trunk_binlog_size(
|
|||
result = _storage_get_trunk_binlog_size(conn, file_size);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -5240,6 +5262,7 @@ static int tracker_set_trunk_server_and_log(FDFSGroupInfo *pGroup, \
|
|||
static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
||||
FDFSStorageDetail *pTrunkServer, const bool save)
|
||||
{
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
|
||||
if (*(pGroup->last_trunk_server_id) != '\0' &&
|
||||
|
|
@ -5261,11 +5284,12 @@ static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
|
|||
pGroup->trunk_chg_count++;
|
||||
g_trunk_server_chg_count++;
|
||||
|
||||
format_ip_address(FDFS_CURRENT_IP_ADDR(pGroup->
|
||||
pTrunkServer), formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"group: %s, trunk server set to %s(%s:%u)", __LINE__,
|
||||
pGroup->group_name, pGroup->pTrunkServer->id,
|
||||
FDFS_CURRENT_IP_ADDR(pGroup->pTrunkServer),
|
||||
pGroup->storage_port);
|
||||
formatted_ip, pGroup->storage_port);
|
||||
if (save)
|
||||
{
|
||||
return tracker_save_groups();
|
||||
|
|
@ -6108,6 +6132,7 @@ int tracker_mem_check_alive(void *arg)
|
|||
FDFSGroupInfo **ppGroup;
|
||||
FDFSGroupInfo **ppGroupEnd;
|
||||
FDFSStorageDetail *deactiveServers[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int deactiveCount;
|
||||
time_t current_time;
|
||||
|
||||
|
|
@ -6139,6 +6164,7 @@ int tracker_mem_check_alive(void *arg)
|
|||
ppServerEnd = deactiveServers + deactiveCount;
|
||||
for (ppServer=deactiveServers; ppServer<ppServerEnd; ppServer++)
|
||||
{
|
||||
format_ip_address(FDFS_CURRENT_IP_ADDR(*ppServer), formatted_ip);
|
||||
(*ppServer)->status = FDFS_STORAGE_STATUS_OFFLINE;
|
||||
tracker_mem_deactive_store_server(*ppGroup, *ppServer);
|
||||
if (g_use_storage_id)
|
||||
|
|
@ -6146,7 +6172,7 @@ int tracker_mem_check_alive(void *arg)
|
|||
logInfo("file: "__FILE__", line: %d, "
|
||||
"storage server %s(%s:%u) idle too long, "
|
||||
"status change to offline!", __LINE__,
|
||||
(*ppServer)->id, FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
(*ppServer)->id, formatted_ip,
|
||||
(*ppGroup)->storage_port);
|
||||
}
|
||||
else
|
||||
|
|
@ -6154,8 +6180,7 @@ int tracker_mem_check_alive(void *arg)
|
|||
logInfo("file: "__FILE__", line: %d, "
|
||||
"storage server %s:%u idle too long, "
|
||||
"status change to offline!", __LINE__,
|
||||
FDFS_CURRENT_IP_ADDR(*ppServer),
|
||||
(*ppGroup)->storage_port);
|
||||
formatted_ip, (*ppGroup)->storage_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6201,12 +6226,13 @@ int tracker_mem_check_alive(void *arg)
|
|||
g_check_active_interval;
|
||||
if (last_beat_interval > check_trunk_interval)
|
||||
{
|
||||
format_ip_address(FDFS_CURRENT_IP_ADDR((*ppGroup)->
|
||||
pTrunkServer), formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"trunk server %s(%s:%u) offline because idle "
|
||||
"time: %d s > threshold: %d s, should "
|
||||
"re-select trunk server", __LINE__,
|
||||
(*ppGroup)->pTrunkServer->id,
|
||||
FDFS_CURRENT_IP_ADDR((*ppGroup)->pTrunkServer),
|
||||
(*ppGroup)->pTrunkServer->id, formatted_ip,
|
||||
(*ppGroup)->storage_port, last_beat_interval,
|
||||
check_trunk_interval);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
|||
const int network_timeout, int64_t *in_bytes)
|
||||
{
|
||||
TrackerHeader resp;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
|
||||
if ((result=tcprecvdata_nb(pTrackerServer->sock, &resp,
|
||||
sizeof(resp), network_timeout)) != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"server: %s:%u, recv data fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
pTrackerServer->port,
|
||||
"server: %s:%u, recv data fail, errno: %d, error info: %s",
|
||||
__LINE__, formatted_ip, pTrackerServer->port,
|
||||
result, STRERROR(result));
|
||||
*in_bytes = 0;
|
||||
return result;
|
||||
|
|
@ -60,10 +60,10 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
|||
|
||||
if (resp.status != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"server: %s:%u, response status %d != 0",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
pTrackerServer->port, resp.status);
|
||||
"server: %s:%u, response status %d != 0", __LINE__,
|
||||
formatted_ip, pTrackerServer->port, resp.status);
|
||||
|
||||
*in_bytes = 0;
|
||||
return resp.status;
|
||||
|
|
@ -72,11 +72,10 @@ int fdfs_recv_header_ex(ConnectionInfo *pTrackerServer,
|
|||
*in_bytes = buff2long(resp.pkg_len);
|
||||
if (*in_bytes < 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"server: %s:%u, recv package size "
|
||||
"%"PRId64" is not correct",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
pTrackerServer->port, *in_bytes);
|
||||
"server: %s:%u, recv package size %"PRId64" is not correct",
|
||||
__LINE__, formatted_ip, pTrackerServer->port, *in_bytes);
|
||||
*in_bytes = 0;
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -90,6 +89,7 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
|||
{
|
||||
int result;
|
||||
bool bMalloced;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
result = fdfs_recv_header(pTrackerServer, in_bytes);
|
||||
if (result != 0)
|
||||
|
|
@ -121,11 +121,11 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
|||
{
|
||||
if (*in_bytes > buff_size)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"server: %s:%u, recv body bytes: " \
|
||||
"%"PRId64" exceed max: %d", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, *in_bytes, buff_size);
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"server: %s:%u, recv body bytes: %"PRId64" exceed "
|
||||
"max: %d", __LINE__, formatted_ip, pTrackerServer->port,
|
||||
*in_bytes, buff_size);
|
||||
*in_bytes = 0;
|
||||
return ENOSPC;
|
||||
}
|
||||
|
|
@ -133,15 +133,14 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
|||
bMalloced = false;
|
||||
}
|
||||
|
||||
if ((result=tcprecvdata_nb(pTrackerServer->sock, *buff, \
|
||||
if ((result=tcprecvdata_nb(pTrackerServer->sock, *buff,
|
||||
*in_bytes, SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server: %s:%u, recv data fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server: %s:%u, recv data fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
*in_bytes = 0;
|
||||
if (bMalloced)
|
||||
{
|
||||
|
|
@ -157,20 +156,20 @@ int fdfs_recv_response(ConnectionInfo *pTrackerServer, \
|
|||
int fdfs_quit(ConnectionInfo *pTrackerServer)
|
||||
{
|
||||
TrackerHeader header;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.cmd = FDFS_PROTO_CMD_QUIT;
|
||||
result = tcpsenddata_nb(pTrackerServer->sock, &header, \
|
||||
result = tcpsenddata_nb(pTrackerServer->sock, &header,
|
||||
sizeof(header), SF_G_NETWORK_TIMEOUT);
|
||||
if(result != 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"tracker server: %s:%u, send data fail, " \
|
||||
"errno: %d, error info: %s", \
|
||||
__LINE__, pTrackerServer->ip_addr, \
|
||||
pTrackerServer->port, \
|
||||
result, STRERROR(result));
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server: %s:%u, send data fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -596,6 +595,7 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
|||
char *buff, const int buff_size)
|
||||
{
|
||||
char out_buff[sizeof(TrackerHeader)];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader *pHeader;
|
||||
int64_t in_bytes;
|
||||
int result;
|
||||
|
|
@ -606,10 +606,11 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
|||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff,
|
||||
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s.", __LINE__,
|
||||
pTrackerServer->ip_addr, pTrackerServer->port,
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
formatted_ip, pTrackerServer->port,
|
||||
result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -622,10 +623,11 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
|
|||
|
||||
if (in_bytes >= buff_size)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"server: %s:%u, recv body bytes: "
|
||||
"%"PRId64" exceed max: %d", __LINE__,
|
||||
pTrackerServer->ip_addr, pTrackerServer->port,
|
||||
formatted_ip, pTrackerServer->port,
|
||||
in_bytes, buff_size);
|
||||
return ENOSPC;
|
||||
}
|
||||
|
|
@ -646,6 +648,7 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
|||
TrackerServerInfo *pTServer;
|
||||
TrackerServerInfo trackerServer;
|
||||
char in_buff[1024];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int result;
|
||||
int leader_index;
|
||||
int i;
|
||||
|
|
@ -698,11 +701,13 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
|||
|
||||
if (conn == NULL)
|
||||
{
|
||||
format_ip_address(pTServer->connections[0].
|
||||
ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, pTServer->connections[0].
|
||||
ip_addr, pTServer->connections[0].port,
|
||||
result, STRERROR(result));
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTServer->connections[0].port, result,
|
||||
STRERROR(result));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -715,9 +720,10 @@ int fdfs_get_ini_context_from_tracker_ex(TrackerServerGroup *pTrackerGroup,
|
|||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"get parameters from tracker server %s:%u fail",
|
||||
__LINE__, conn->ip_addr, conn->port);
|
||||
__LINE__, formatted_ip, conn->port);
|
||||
close(conn->sock);
|
||||
sleep(1);
|
||||
}
|
||||
|
|
@ -735,6 +741,7 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
|||
TrackerRunningStatus *pStatus)
|
||||
{
|
||||
char in_buff[1 + 2 * FDFS_PROTO_PKG_LEN_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
TrackerHeader header;
|
||||
char *pInBuff;
|
||||
ConnectionInfo *conn;
|
||||
|
|
@ -754,10 +761,10 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
|||
if ((result=tcpsenddata_nb(conn->sock, &header,
|
||||
sizeof(header), SF_G_NETWORK_TIMEOUT)) != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip, conn->port,
|
||||
result, STRERROR(result));
|
||||
|
||||
result = (result == ENOENT ? EACCES : result);
|
||||
|
|
@ -774,11 +781,11 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
|||
|
||||
if (in_bytes != sizeof(in_buff))
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, "
|
||||
"expect length: %d.", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
"tracker server %s:%u response data length: "
|
||||
"%"PRId64" is invalid, expect length: %d",
|
||||
__LINE__, formatted_ip, conn->port,
|
||||
in_bytes, (int)sizeof(in_buff));
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
|||
int64_t in_bytes;
|
||||
char in_buff[(FDFS_GROUP_NAME_MAX_LEN + FDFS_STORAGE_ID_MAX_SIZE) * \
|
||||
FDFS_MAX_GROUPS];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char *pInBuff;
|
||||
char *p;
|
||||
char *pEnd;
|
||||
|
|
@ -49,26 +50,26 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
|||
|
||||
memset(&header, 0, sizeof(header));
|
||||
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);
|
||||
if(result != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, send data fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
"tracker server %s:%u, send data fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip,
|
||||
pTrackerServer->port, result, STRERROR(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
pInBuff = in_buff;
|
||||
if ((result=fdfs_recv_response(pTrackerServer, &pInBuff, \
|
||||
if ((result=fdfs_recv_response(pTrackerServer, &pInBuff,
|
||||
sizeof(in_buff), &in_bytes)) != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"fdfs_recv_response from %s:%u fail, result: %d",
|
||||
__LINE__, pTrackerServer->ip_addr,
|
||||
pTrackerServer->port, result);
|
||||
__LINE__, formatted_ip, pTrackerServer->port, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -79,9 +80,10 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
|
|||
else if (in_bytes % (FDFS_GROUP_NAME_MAX_LEN + \
|
||||
FDFS_STORAGE_ID_MAX_SIZE) != 0)
|
||||
{
|
||||
format_ip_address(pTrackerServer->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u, invalid body length: "
|
||||
"%"PRId64, __LINE__, pTrackerServer->ip_addr,
|
||||
"%"PRId64, __LINE__, formatted_ip,
|
||||
pTrackerServer->port, in_bytes);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -198,6 +200,7 @@ static int relationship_get_tracker_leader(TrackerRunningStatus *pTrackerStatus)
|
|||
TrackerServerInfo *pTrackerEnd;
|
||||
TrackerRunningStatus *pStatus;
|
||||
TrackerRunningStatus trackerStatus[FDFS_MAX_TRACKERS];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int count;
|
||||
int result;
|
||||
int r;
|
||||
|
|
@ -235,17 +238,20 @@ static int relationship_get_tracker_leader(TrackerRunningStatus *pTrackerStatus)
|
|||
qsort(trackerStatus, count, sizeof(TrackerRunningStatus), \
|
||||
relationship_cmp_tracker_status);
|
||||
|
||||
if (FC_LOG_BY_LEVEL(LOG_DEBUG)) {
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"%s:%u if_leader: %d, running time: %d, " \
|
||||
"restart interval: %d", __LINE__, \
|
||||
trackerStatus[i].pTrackerServer->connections->ip_addr, \
|
||||
trackerStatus[i].pTrackerServer->connections->port, \
|
||||
trackerStatus[i].if_leader, \
|
||||
trackerStatus[i].running_time, \
|
||||
format_ip_address(trackerStatus[i].pTrackerServer->
|
||||
connections->ip_addr, formatted_ip);
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"%s:%u if_leader: %d, running time: %d, "
|
||||
"restart interval: %d", __LINE__, formatted_ip,
|
||||
trackerStatus[i].pTrackerServer->connections->port,
|
||||
trackerStatus[i].if_leader,
|
||||
trackerStatus[i].running_time,
|
||||
trackerStatus[i].restart_interval);
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(pTrackerStatus, trackerStatus + (count - 1), \
|
||||
sizeof(TrackerRunningStatus));
|
||||
|
|
@ -256,6 +262,7 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
|||
ConnectionInfo *pLeader, const char cmd, bool *bConnectFail)
|
||||
{
|
||||
char out_buff[sizeof(TrackerHeader) + FDFS_PROTO_IP_PORT_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
char in_buff[1];
|
||||
ConnectionInfo *conn;
|
||||
TrackerHeader *pHeader;
|
||||
|
|
@ -276,39 +283,41 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
|||
memset(out_buff, 0, sizeof(out_buff));
|
||||
pHeader = (TrackerHeader *)out_buff;
|
||||
pHeader->cmd = cmd;
|
||||
sprintf(out_buff + sizeof(TrackerHeader), "%s:%u", \
|
||||
pLeader->ip_addr, pLeader->port);
|
||||
format_ip_port(pLeader->ip_addr, pLeader->port,
|
||||
out_buff + sizeof(TrackerHeader));
|
||||
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)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"send data to tracker server %s:%u fail, "
|
||||
"errno: %d, error info: %s", __LINE__,
|
||||
conn->ip_addr, conn->port, result, STRERROR(result));
|
||||
"send data to tracker server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, formatted_ip, conn->port,
|
||||
result, STRERROR(result));
|
||||
|
||||
result = (result == ENOENT ? EACCES : result);
|
||||
break;
|
||||
}
|
||||
|
||||
pInBuff = in_buff;
|
||||
result = fdfs_recv_response(conn, &pInBuff, \
|
||||
0, &in_bytes);
|
||||
result = fdfs_recv_response(conn, &pInBuff, 0, &in_bytes);
|
||||
if (result != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"fdfs_recv_response from tracker server %s:%u fail, "
|
||||
"result: %d", __LINE__, conn->ip_addr, conn->port, result);
|
||||
"result: %d", __LINE__, formatted_ip, conn->port, result);
|
||||
break;
|
||||
}
|
||||
|
||||
if (in_bytes != 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"tracker server %s:%u response data "
|
||||
"length: %"PRId64" is invalid, "
|
||||
"expect length: %d.", __LINE__,
|
||||
conn->ip_addr, conn->port, in_bytes, 0);
|
||||
formatted_ip, conn->port, in_bytes, 0);
|
||||
result = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -330,6 +339,8 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
|||
void relationship_set_tracker_leader(const int server_index,
|
||||
ConnectionInfo *pLeader, const bool leader_self)
|
||||
{
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
g_tracker_servers.leader_index = server_index;
|
||||
g_next_leader_index = -1;
|
||||
|
||||
|
|
@ -340,9 +351,10 @@ void relationship_set_tracker_leader(const int server_index,
|
|||
}
|
||||
else
|
||||
{
|
||||
format_ip_address(pLeader->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"the tracker leader is %s:%u", __LINE__,
|
||||
pLeader->ip_addr, pLeader->port);
|
||||
formatted_ip, pLeader->port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -458,6 +470,7 @@ static int relationship_select_leader()
|
|||
int result;
|
||||
TrackerRunningStatus trackerStatus;
|
||||
ConnectionInfo *conn;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
if (g_tracker_servers.server_count <= 0)
|
||||
{
|
||||
|
|
@ -482,9 +495,10 @@ static int relationship_select_leader()
|
|||
return result;
|
||||
}
|
||||
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"I am the new tracker leader %s:%u",
|
||||
__LINE__, conn->ip_addr, conn->port);
|
||||
__LINE__, formatted_ip, conn->port);
|
||||
|
||||
tracker_mem_find_trunk_servers();
|
||||
}
|
||||
|
|
@ -509,15 +523,17 @@ static int relationship_select_leader()
|
|||
|
||||
if (g_tracker_servers.leader_index >= 0)
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"the tracker leader %s:%u", __LINE__,
|
||||
conn->ip_addr, conn->port);
|
||||
formatted_ip, conn->port);
|
||||
}
|
||||
else
|
||||
{
|
||||
format_ip_address(conn->ip_addr, formatted_ip);
|
||||
logInfo("file: "__FILE__", line: %d, "
|
||||
"waiting for the candidate tracker leader %s:%u notify ...",
|
||||
__LINE__, conn->ip_addr, conn->port);
|
||||
__LINE__, formatted_ip, conn->port);
|
||||
return ENOENT;
|
||||
}
|
||||
}
|
||||
|
|
@ -560,6 +576,7 @@ static void *relationship_thread_entrance(void* arg)
|
|||
|
||||
int fail_count;
|
||||
int sleep_seconds;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
|
||||
#ifdef OS_LINUX
|
||||
{
|
||||
|
|
@ -607,8 +624,9 @@ static void *relationship_thread_entrance(void* arg)
|
|||
{
|
||||
pLeader = g_tracker_servers.servers
|
||||
[leader_index].connections;
|
||||
format_ip_address(pLeader->ip_addr, formatted_ip);
|
||||
sprintf(leader_str, "leader %s:%u",
|
||||
pLeader->ip_addr, pLeader->port);
|
||||
formatted_ip, pLeader->port);
|
||||
}
|
||||
|
||||
++fail_count;
|
||||
|
|
|
|||
|
|
@ -645,6 +645,7 @@ static int tracker_deal_notify_next_leader(struct fast_task_info *pTask)
|
|||
char *pIpAndPort;
|
||||
char *ipAndPort[2];
|
||||
ConnectionInfo leader;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int server_index;
|
||||
|
||||
if (pTask->recv.ptr->length - sizeof(TrackerHeader) !=
|
||||
|
|
@ -675,14 +676,15 @@ static int tracker_deal_notify_next_leader(struct fast_task_info *pTask)
|
|||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
strcpy(leader.ip_addr, ipAndPort[0]);
|
||||
leader.port = atoi(ipAndPort[1]);
|
||||
server_index = fdfs_get_tracker_leader_index_ex(&g_tracker_servers, \
|
||||
server_index = fdfs_get_tracker_leader_index_ex(&g_tracker_servers,
|
||||
leader.ip_addr, leader.port);
|
||||
if (server_index < 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, leader %s:%u not exist", \
|
||||
__LINE__, pTask->client_ip, \
|
||||
leader.ip_addr, leader.port);
|
||||
format_ip_address(leader.ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, leader %s:%u not exist",
|
||||
__LINE__, pTask->client_ip,
|
||||
formatted_ip, leader.port);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
|
|
@ -693,11 +695,11 @@ static int tracker_deal_notify_next_leader(struct fast_task_info *pTask)
|
|||
g_tracker_servers.leader_index = -1;
|
||||
g_tracker_leader_chg_count++;
|
||||
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, two leaders occur, " \
|
||||
"new leader is %s:%u", \
|
||||
__LINE__, pTask->client_ip, \
|
||||
leader.ip_addr, leader.port);
|
||||
format_ip_address(leader.ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, two leaders occur, new leader "
|
||||
"is %s:%u", __LINE__, pTask->client_ip,
|
||||
formatted_ip, leader.port);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -710,6 +712,7 @@ static int tracker_deal_commit_next_leader(struct fast_task_info *pTask)
|
|||
char *pIpAndPort;
|
||||
char *ipAndPort[2];
|
||||
ConnectionInfo leader;
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
int server_index;
|
||||
bool leader_self;
|
||||
|
||||
|
|
@ -745,18 +748,20 @@ static int tracker_deal_commit_next_leader(struct fast_task_info *pTask)
|
|||
leader.ip_addr, leader.port);
|
||||
if (server_index < 0)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, leader %s:%u not exist", \
|
||||
__LINE__, pTask->client_ip, \
|
||||
leader.ip_addr, leader.port);
|
||||
format_ip_address(leader.ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, leader %s:%u not exist",
|
||||
__LINE__, pTask->client_ip,
|
||||
formatted_ip, leader.port);
|
||||
return ENOENT;
|
||||
}
|
||||
if (server_index != g_next_leader_index)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip: %s, can't commit leader %s:%u", \
|
||||
__LINE__, pTask->client_ip, \
|
||||
leader.ip_addr, leader.port);
|
||||
format_ip_address(leader.ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, can't commit leader %s:%u",
|
||||
__LINE__, pTask->client_ip,
|
||||
formatted_ip, leader.port);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -984,6 +989,7 @@ static int tracker_deal_get_my_ip(struct fast_task_info *pTask)
|
|||
static int tracker_deal_get_storage_group_name(struct fast_task_info *pTask)
|
||||
{
|
||||
char ip_addr[IP_ADDRESS_SIZE];
|
||||
char formatted_ip[FORMATTED_IP_SIZE];
|
||||
FDFSStorageIdInfo *pFDFSStorageIdInfo;
|
||||
char *pPort;
|
||||
int port;
|
||||
|
|
@ -1038,9 +1044,10 @@ static int tracker_deal_get_storage_group_name(struct fast_task_info *pTask)
|
|||
pFDFSStorageIdInfo = fdfs_get_storage_id_by_ip_port(ip_addr, port);
|
||||
if (pFDFSStorageIdInfo == NULL)
|
||||
{
|
||||
format_ip_address(ip_addr, formatted_ip);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip: %s, can't get group name for storage %s:%u",
|
||||
__LINE__, pTask->client_ip, ip_addr, port);
|
||||
__LINE__, pTask->client_ip, formatted_ip, port);
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return ENOENT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue