dual IPs support two different types of inner (intranet) IPs
parent
6712843a80
commit
21c52cf406
3
HISTORY
3
HISTORY
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
Version 6.03 2019-11-14
|
||||
* dual IPs support two different types of inner (intranet) IPs
|
||||
|
||||
Version 6.02 2019-11-12
|
||||
* get_file_info calculate CRC32 for appender file type
|
||||
* disk recovery download file to local temp file then rename it
|
||||
|
|
|
|||
|
|
@ -2181,7 +2181,7 @@ int fdfs_get_file_info_ex(const char *group_name, const char *remote_filename, \
|
|||
if (pStorageId != NULL)
|
||||
{
|
||||
strcpy(pFileInfo->source_ip_addr,
|
||||
pStorageId->ip_addrs.ips[0]);
|
||||
pStorageId->ip_addrs.ips[0].address);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -135,14 +135,14 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
|||
while (g_continue_flag)
|
||||
{
|
||||
result = tracker_get_storage_max_status(&g_tracker_group,
|
||||
g_group_name, g_tracker_client_ip.ips[0],
|
||||
g_group_name, g_tracker_client_ip.ips[0].address,
|
||||
g_my_server_id_str, &saved_storage_status);
|
||||
if (result == ENOENT)
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, " \
|
||||
"current storage: %s does not exist " \
|
||||
"in tracker server", __LINE__, \
|
||||
g_tracker_client_ip.ips[0]);
|
||||
g_tracker_client_ip.ips[0].address);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
|||
logInfo("file: "__FILE__", line: %d, " \
|
||||
"current storage: %s 's status is %d" \
|
||||
", does not need recovery", __LINE__, \
|
||||
g_tracker_client_ip.ips[0], \
|
||||
g_tracker_client_ip.ips[0].address, \
|
||||
saved_storage_status);
|
||||
return ENOENT;
|
||||
}
|
||||
|
|
@ -164,7 +164,8 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
|||
logWarning("file: "__FILE__", line: %d, " \
|
||||
"current storage: %s 's status is %d" \
|
||||
", does not need recovery", __LINE__, \
|
||||
g_tracker_client_ip.ips[0], saved_storage_status);
|
||||
g_tracker_client_ip.ips[0].address,
|
||||
saved_storage_status);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
|
|
@ -861,7 +862,8 @@ int storage_disk_recovery_restore(const char *pBasePath)
|
|||
while (g_continue_flag)
|
||||
{
|
||||
if (storage_report_storage_status(g_my_server_id_str, \
|
||||
g_tracker_client_ip.ips[0], saved_storage_status) == 0)
|
||||
g_tracker_client_ip.ips[0].address,
|
||||
saved_storage_status) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -1147,7 +1149,8 @@ int storage_disk_recovery_start(const int store_path_index)
|
|||
while (g_continue_flag)
|
||||
{
|
||||
if (storage_report_storage_status(g_my_server_id_str, \
|
||||
g_tracker_client_ip.ips[0], FDFS_STORAGE_STATUS_RECOVERY) == 0)
|
||||
g_tracker_client_ip.ips[0].address,
|
||||
FDFS_STORAGE_STATUS_RECOVERY) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ static int tracker_get_my_server_id()
|
|||
struct in_addr ip_addr;
|
||||
char ip_str[256];
|
||||
|
||||
if (inet_pton(AF_INET, g_tracker_client_ip.ips[0], &ip_addr) == 1)
|
||||
if (inet_pton(AF_INET, g_tracker_client_ip.ips[0].address, &ip_addr) == 1)
|
||||
{
|
||||
g_server_id_in_filename = ip_addr.s_addr;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ static int tracker_get_my_server_id()
|
|||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"call inet_pton for ip: %s fail", \
|
||||
__LINE__, g_tracker_client_ip.ips[0]);
|
||||
__LINE__, g_tracker_client_ip.ips[0].address);
|
||||
g_server_id_in_filename = INADDR_NONE;
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ static int tracker_get_my_server_id()
|
|||
}
|
||||
|
||||
result = tracker_get_storage_id(pTrackerServer,
|
||||
g_group_name, g_tracker_client_ip.ips[0],
|
||||
g_group_name, g_tracker_client_ip.ips[0].address,
|
||||
g_my_server_id_str);
|
||||
tracker_close_connection_ex(pTrackerServer, result != 0);
|
||||
if (result != 0)
|
||||
|
|
@ -250,7 +250,7 @@ static int tracker_get_my_server_id()
|
|||
else
|
||||
{
|
||||
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str), "%s",
|
||||
g_tracker_client_ip.ips[0]);
|
||||
g_tracker_client_ip.ips[0].address);
|
||||
}
|
||||
|
||||
fdfs_multi_ips_to_string(&g_tracker_client_ip,
|
||||
|
|
@ -2141,7 +2141,7 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
for (i = 0; i < multi_ip.count; i++)
|
||||
{
|
||||
result = storage_insert_ip_addr_to_multi_ips(&g_tracker_client_ip,
|
||||
multi_ip.ips[i], multi_ip.count);
|
||||
multi_ip.ips[i].address, multi_ip.count);
|
||||
if (result == 0)
|
||||
{
|
||||
if ((result=fdfs_check_and_format_ips(&g_tracker_client_ip,
|
||||
|
|
@ -2152,12 +2152,12 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
"my ip: %s not valid, error info: %s. "
|
||||
"program exit!", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
multi_ip.ips[i], error_info);
|
||||
multi_ip.ips[i].address, error_info);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
insert_into_local_host_ip(multi_ip.ips[i]);
|
||||
insert_into_local_host_ip(multi_ip.ips[i].address);
|
||||
}
|
||||
else if (result != EEXIST)
|
||||
{
|
||||
|
|
@ -2170,7 +2170,7 @@ int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
|||
"my ip: %s not consistent with client ips: %s "
|
||||
"of other tracker client. program exit!", __LINE__,
|
||||
conn->ip_addr, conn->port,
|
||||
multi_ip.ips[i], ip_str);
|
||||
multi_ip.ips[i].address, ip_str);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,13 +141,14 @@ int storage_insert_ip_addr_to_multi_ips(FDFSMultiIP *multi_ip,
|
|||
if (multi_ip->count == 0)
|
||||
{
|
||||
multi_ip->count = 1;
|
||||
strcpy(multi_ip->ips[0], ip_addr);
|
||||
multi_ip->ips[0].type = fdfs_get_ip_type(ip_addr);
|
||||
strcpy(multi_ip->ips[0].address, ip_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < multi_ip->count; i++)
|
||||
{
|
||||
if (strcmp(multi_ip->ips[i], ip_addr) == 0)
|
||||
if (strcmp(multi_ip->ips[i].address, ip_addr) == 0)
|
||||
{
|
||||
return EEXIST;
|
||||
}
|
||||
|
|
@ -158,7 +159,8 @@ int storage_insert_ip_addr_to_multi_ips(FDFSMultiIP *multi_ip,
|
|||
return ENOSPC;
|
||||
}
|
||||
|
||||
strcpy(multi_ip->ips[i], ip_addr);
|
||||
multi_ip->ips[i].type = fdfs_get_ip_type(ip_addr);
|
||||
strcpy(multi_ip->ips[i].address, ip_addr);
|
||||
multi_ip->count++;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
|
|||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_REPORT_IP_CHANGED;
|
||||
strcpy(out_buff + sizeof(TrackerHeader), g_group_name);
|
||||
strcpy(out_buff + sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN, \
|
||||
g_last_storage_ip.ips[0]);
|
||||
g_last_storage_ip.ips[0].address);
|
||||
strcpy(out_buff + sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||
IP_ADDRESS_SIZE, g_tracker_client_ip.ips[0]);
|
||||
IP_ADDRESS_SIZE, g_tracker_client_ip.ips[0].address);
|
||||
|
||||
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \
|
||||
sizeof(out_buff), g_fdfs_network_timeout)) != 0)
|
||||
|
|
@ -208,15 +208,15 @@ static int storage_report_storage_ip_addr()
|
|||
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"last my ip is %s, current my ip is %s",
|
||||
__LINE__, g_last_storage_ip.ips[0],
|
||||
g_tracker_client_ip.ips[0]);
|
||||
__LINE__, g_last_storage_ip.ips[0].address,
|
||||
g_tracker_client_ip.ips[0].address);
|
||||
|
||||
if (g_last_storage_ip.count == 0)
|
||||
{
|
||||
return storage_write_to_sync_ini_file();
|
||||
}
|
||||
else if (strcmp(g_tracker_client_ip.ips[0],
|
||||
g_last_storage_ip.ips[0]) == 0)
|
||||
else if (strcmp(g_tracker_client_ip.ips[0].address,
|
||||
g_last_storage_ip.ips[0].address) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ void storage_sync_connect_storage_server_ex(FDFSStorageBrief *pStorage,
|
|||
{
|
||||
ip_addrs.count = 1;
|
||||
ip_addrs.index = 0;
|
||||
strcpy(ip_addrs.ips[0], pStorage->ip_addr);
|
||||
ip_addrs.ips[0].type = fdfs_get_ip_type(pStorage->ip_addr);
|
||||
strcpy(ip_addrs.ips[0].address, pStorage->ip_addr);
|
||||
}
|
||||
|
||||
conn->sock = -1;
|
||||
|
|
@ -81,7 +82,7 @@ void storage_sync_connect_storage_server_ex(FDFSStorageBrief *pStorage,
|
|||
{
|
||||
for (i=0; i<ip_addrs.count; i++)
|
||||
{
|
||||
strcpy(conn->ip_addr, ip_addrs.ips[i]);
|
||||
strcpy(conn->ip_addr, ip_addrs.ips[i].address);
|
||||
conn->sock = socketCreateExAuto(conn->ip_addr,
|
||||
g_fdfs_connect_timeout, O_NONBLOCK,
|
||||
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||
|
|
@ -148,7 +149,7 @@ void storage_sync_connect_storage_server_ex(FDFSStorageBrief *pStorage,
|
|||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to storage server %s:%d fail, "
|
||||
"try count: %d, errno: %d, error info: %s",
|
||||
__LINE__, ip_addrs.ips[i], g_server_port, avg_fails,
|
||||
__LINE__, ip_addrs.ips[i].address, g_server_port, avg_fails,
|
||||
conn_results[i], STRERROR(conn_results[i]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ static int fdfs_init_ip_array(FDFSStorageIdMapArray *mapArray,
|
|||
{
|
||||
idMap->idInfo = idInfo;
|
||||
idMap->group_name = idInfo->group_name;
|
||||
idMap->ip_addr = idInfo->ip_addrs.ips[i];
|
||||
idMap->ip_addr = idInfo->ip_addrs.ips[i].address;
|
||||
idMap->port = idInfo->port;
|
||||
idMap++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "fdfs_global.h"
|
||||
#include "fdfs_shared_func.h"
|
||||
|
||||
|
||||
bool fdfs_server_contain(TrackerServerInfo *pServerInfo,
|
||||
const char *target_ip, const int target_port)
|
||||
{
|
||||
|
|
@ -495,11 +496,40 @@ int fdfs_server_info_to_string_ex(const TrackerServerInfo *pServer,
|
|||
return len;
|
||||
}
|
||||
|
||||
int fdfs_get_ip_type(const char* ip)
|
||||
{
|
||||
if (ip == NULL || (int)strlen(ip) < 8)
|
||||
{
|
||||
return FDFS_IP_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (memcmp(ip, "10.", 3) == 0)
|
||||
{
|
||||
return FDFS_IP_TYPE_PRIVATE_10;
|
||||
}
|
||||
if (memcmp(ip, "192.168.", 8) == 0)
|
||||
{
|
||||
return FDFS_IP_TYPE_PRIVATE_192;
|
||||
}
|
||||
|
||||
if (memcmp(ip, "172.", 4) == 0)
|
||||
{
|
||||
int b;
|
||||
b = atoi(ip + 4);
|
||||
if (b >= 16 && b < 32)
|
||||
{
|
||||
return FDFS_IP_TYPE_PRIVATE_172;
|
||||
}
|
||||
}
|
||||
|
||||
return FDFS_IP_TYPE_OUTER;
|
||||
}
|
||||
|
||||
int fdfs_check_server_ips(const TrackerServerInfo *pServer,
|
||||
char *error_info, const int error_size)
|
||||
{
|
||||
int private0;
|
||||
int private1;
|
||||
int type0;
|
||||
int type1;
|
||||
if (pServer->count == 1)
|
||||
{
|
||||
*error_info = '\0';
|
||||
|
|
@ -521,13 +551,14 @@ int fdfs_check_server_ips(const TrackerServerInfo *pServer,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
private0 = is_private_ip(pServer->connections[0].ip_addr) ? 1 : 0;
|
||||
private1 = is_private_ip(pServer->connections[1].ip_addr) ? 1 : 0;
|
||||
if ((private0 ^ private1) == 0)
|
||||
type0 = fdfs_get_ip_type(pServer->connections[0].ip_addr);
|
||||
type1 = fdfs_get_ip_type(pServer->connections[1].ip_addr);
|
||||
if (type0 == type1)
|
||||
{
|
||||
snprintf(error_info, error_size,
|
||||
"invalid ip addresses %s and %s, "
|
||||
"one MUST be an inner IP and another is a outer IP",
|
||||
"one MUST be an inner IP and another is a outer IP, "
|
||||
"or two different types of inner IP addresses",
|
||||
pServer->connections[0].ip_addr,
|
||||
pServer->connections[1].ip_addr);
|
||||
return EINVAL;
|
||||
|
|
@ -549,8 +580,8 @@ int fdfs_parse_multi_ips_ex(char *ip_str, FDFSMultiIP *ip_addrs,
|
|||
{
|
||||
if (resolve)
|
||||
{
|
||||
if (getIpaddrByName(hosts[i], ip_addrs->ips[i],
|
||||
sizeof(ip_addrs->ips[i])) == INADDR_NONE)
|
||||
if (getIpaddrByName(hosts[i], ip_addrs->ips[i].address,
|
||||
sizeof(ip_addrs->ips[i].address)) == INADDR_NONE)
|
||||
{
|
||||
snprintf(error_info, error_size,
|
||||
"host \"%s\" is invalid, error info: %s",
|
||||
|
|
@ -560,7 +591,17 @@ int fdfs_parse_multi_ips_ex(char *ip_str, FDFSMultiIP *ip_addrs,
|
|||
}
|
||||
else
|
||||
{
|
||||
snprintf(ip_addrs->ips[i], sizeof(ip_addrs->ips[i]), "%s", hosts[i]);
|
||||
snprintf(ip_addrs->ips[i].address,
|
||||
sizeof(ip_addrs->ips[i].address), "%s", hosts[i]);
|
||||
}
|
||||
|
||||
ip_addrs->ips[i].type = fdfs_get_ip_type(ip_addrs->ips[i].address);
|
||||
if (ip_addrs->ips[i].type == FDFS_IP_TYPE_UNKNOWN)
|
||||
{
|
||||
snprintf(error_info, error_size,
|
||||
"ip address \"%s\" is invalid",
|
||||
ip_addrs->ips[i].address);
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -582,14 +623,14 @@ int fdfs_multi_ips_to_string_ex(const FDFSMultiIP *ip_addrs,
|
|||
if (ip_addrs->count == 1)
|
||||
{
|
||||
return snprintf(buff, buffSize, "%s",
|
||||
ip_addrs->ips[0]);
|
||||
ip_addrs->ips[0].address);
|
||||
}
|
||||
|
||||
len = snprintf(buff, buffSize, "%s", ip_addrs->ips[0]);
|
||||
len = snprintf(buff, buffSize, "%s", ip_addrs->ips[0].address);
|
||||
for (i=1; i<ip_addrs->count; i++)
|
||||
{
|
||||
len += snprintf(buff + len, buffSize - len, "%c%s",
|
||||
seperator, ip_addrs->ips[i]);
|
||||
seperator, ip_addrs->ips[i].address);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
|
@ -597,10 +638,11 @@ int fdfs_multi_ips_to_string_ex(const FDFSMultiIP *ip_addrs,
|
|||
const char *fdfs_get_ipaddr_by_peer_ip(const FDFSMultiIP *ip_addrs,
|
||||
const char *client_ip)
|
||||
{
|
||||
int ip_type;
|
||||
int index;
|
||||
if (ip_addrs->count == 1)
|
||||
{
|
||||
return ip_addrs->ips[0];
|
||||
return ip_addrs->ips[0].address;
|
||||
}
|
||||
|
||||
if (ip_addrs->count <= 0)
|
||||
|
|
@ -608,15 +650,16 @@ const char *fdfs_get_ipaddr_by_peer_ip(const FDFSMultiIP *ip_addrs,
|
|||
return "";
|
||||
}
|
||||
|
||||
index = is_private_ip(client_ip) ? FDFS_MULTI_IP_INDEX_INNER : FDFS_MULTI_IP_INDEX_OUTER;
|
||||
return ip_addrs->ips[index];
|
||||
ip_type = fdfs_get_ip_type(client_ip);
|
||||
index = ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER].type == ip_type ?
|
||||
FDFS_MULTI_IP_INDEX_INNER : FDFS_MULTI_IP_INDEX_OUTER;
|
||||
return ip_addrs->ips[index].address;
|
||||
}
|
||||
|
||||
int fdfs_check_and_format_ips(FDFSMultiIP *ip_addrs,
|
||||
char *error_info, const int error_size)
|
||||
{
|
||||
int privates[FDFS_MULTI_IP_MAX_COUNT];
|
||||
char swap_ip[IP_ADDRESS_SIZE];
|
||||
FDFSIPInfo swap_ip;
|
||||
if (ip_addrs->count == 1)
|
||||
{
|
||||
*error_info = '\0';
|
||||
|
|
@ -638,23 +681,23 @@ int fdfs_check_and_format_ips(FDFSMultiIP *ip_addrs,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
privates[0] = is_private_ip(ip_addrs->ips[0]) ? 1 : 0;
|
||||
privates[1] = is_private_ip(ip_addrs->ips[1]) ? 1 : 0;
|
||||
if ((privates[0] ^ privates[1]) == 0)
|
||||
if (ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER].type ==
|
||||
ip_addrs->ips[FDFS_MULTI_IP_INDEX_OUTER].type)
|
||||
{
|
||||
snprintf(error_info, error_size,
|
||||
"invalid ip addresses %s and %s, "
|
||||
"one MUST be an inner IP and another is a outer IP",
|
||||
ip_addrs->ips[0], ip_addrs->ips[1]);
|
||||
"one MUST be an inner IP and another is a outer IP, "
|
||||
"or two different types of inner IP addresses",
|
||||
ip_addrs->ips[0].address, ip_addrs->ips[1].address);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (!privates[FDFS_MULTI_IP_INDEX_INNER])
|
||||
if (ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER].type == FDFS_IP_TYPE_OUTER)
|
||||
{
|
||||
strcpy(swap_ip, ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER]);
|
||||
strcpy(ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER],
|
||||
ip_addrs->ips[FDFS_MULTI_IP_INDEX_OUTER]);
|
||||
strcpy(ip_addrs->ips[FDFS_MULTI_IP_INDEX_OUTER], swap_ip);
|
||||
swap_ip = ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER];
|
||||
ip_addrs->ips[FDFS_MULTI_IP_INDEX_INNER] =
|
||||
ip_addrs->ips[FDFS_MULTI_IP_INDEX_OUTER];
|
||||
ip_addrs->ips[FDFS_MULTI_IP_INDEX_OUTER] = swap_ip;
|
||||
}
|
||||
|
||||
*error_info = '\0';
|
||||
|
|
@ -671,7 +714,7 @@ void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip)
|
|||
|
||||
for (i=0; i<multi_ip->count; i++)
|
||||
{
|
||||
if (strcmp(multi_ip->ips[i], target_ip) == 0)
|
||||
if (strcmp(multi_ip->ips[i].address, target_ip) == 0)
|
||||
{
|
||||
multi_ip->index = i;
|
||||
break;
|
||||
|
|
@ -697,6 +740,6 @@ void fdfs_set_server_info_ex(TrackerServerInfo *pServer,
|
|||
for (i=0; i<ip_addrs->count; i++)
|
||||
{
|
||||
conn_pool_set_server_info(pServer->connections + i,
|
||||
ip_addrs->ips[i], port);
|
||||
ip_addrs->ips[i].address, port);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@
|
|||
#include "tracker_types.h"
|
||||
#include "fdfs_server_id_func.h"
|
||||
|
||||
#define FDFS_IP_TYPE_UNKNOWN 0
|
||||
#define FDFS_IP_TYPE_PRIVATE_10 1
|
||||
#define FDFS_IP_TYPE_PRIVATE_172 2
|
||||
#define FDFS_IP_TYPE_PRIVATE_192 3
|
||||
#define FDFS_IP_TYPE_OUTER 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -124,6 +130,8 @@ static inline int fdfs_parse_multi_ips(char *ip_str, FDFSMultiIP *ip_addrs,
|
|||
error_info, error_size, resolve);
|
||||
}
|
||||
|
||||
int fdfs_get_ip_type(const char* ip);
|
||||
|
||||
int fdfs_check_server_ips(const TrackerServerInfo *pServer,
|
||||
char *error_info, const int error_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -3448,9 +3448,9 @@ int tracker_mem_delete_storage(FDFSGroupInfo *pGroup, const char *id)
|
|||
}
|
||||
}
|
||||
|
||||
logDebug("file: "__FILE__", line: %d, " \
|
||||
"delete storage server: %s:%d, group: %s", \
|
||||
__LINE__, pStorageServer->ip_addrs.ips[0],
|
||||
logDebug("file: "__FILE__", line: %d, "
|
||||
"delete storage server: %s:%d, group: %s",
|
||||
__LINE__, pStorageServer->ip_addrs.ips[0].address,
|
||||
pStorageServer->storage_port, pGroup->group_name);
|
||||
|
||||
tracker_mem_clear_storage_fields(pStorageServer);
|
||||
|
|
@ -3536,16 +3536,18 @@ int tracker_mem_storage_ip_changed(FDFSGroupInfo *pGroup, \
|
|||
pthread_mutex_lock(&mem_thread_lock);
|
||||
|
||||
//exchange old and new storage server
|
||||
snprintf(pOldStorageServer->id, sizeof(pOldStorageServer->id), \
|
||||
snprintf(pOldStorageServer->id, sizeof(pOldStorageServer->id),
|
||||
"%s", new_storage_ip);
|
||||
snprintf(pOldStorageServer->ip_addrs.ips[0].address,
|
||||
sizeof(pOldStorageServer->ip_addrs.ips[0].address),
|
||||
"%s", new_storage_ip);
|
||||
snprintf(pOldStorageServer->ip_addrs.ips[0],
|
||||
sizeof(pOldStorageServer->ip_addrs.ips[0]), "%s", new_storage_ip);
|
||||
|
||||
snprintf(pNewStorageServer->id, sizeof(pNewStorageServer->id), \
|
||||
snprintf(pNewStorageServer->id, sizeof(pNewStorageServer->id),
|
||||
"%s", old_storage_ip);
|
||||
pNewStorageServer->ip_addrs.count = 1;
|
||||
snprintf(pNewStorageServer->ip_addrs.ips[0],
|
||||
sizeof(pNewStorageServer->ip_addrs.ips[0]), "%s", old_storage_ip);
|
||||
snprintf(pNewStorageServer->ip_addrs.ips[0].address,
|
||||
sizeof(pNewStorageServer->ip_addrs.ips[0].address),
|
||||
"%s", old_storage_ip);
|
||||
pNewStorageServer->status = FDFS_STORAGE_STATUS_IP_CHANGED;
|
||||
|
||||
pGroup->chg_count++;
|
||||
|
|
@ -3684,7 +3686,7 @@ static int _tracker_mem_add_storage(FDFSGroupInfo *pGroup,
|
|||
{
|
||||
multi_ip.count = 1;
|
||||
multi_ip.index = 0;
|
||||
strcpy(multi_ip.ips[0], ip_addr);
|
||||
strcpy(multi_ip.ips[0].address, ip_addr);
|
||||
}
|
||||
|
||||
if (id != NULL)
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ static int tracker_deal_server_get_storage_status(struct fast_task_info *pTask)
|
|||
pDest = (FDFSStorageBrief *)(pTask->data + sizeof(TrackerHeader));
|
||||
memset(pDest, 0, sizeof(FDFSStorageBrief));
|
||||
strcpy(pDest->id, pStorage->id);
|
||||
strcpy(pDest->ip_addr, pStorage->ip_addrs.ips[0]);
|
||||
strcpy(pDest->ip_addr, pStorage->ip_addrs.ips[0].address);
|
||||
pDest->status = pStorage->status;
|
||||
int2buff(pGroup->storage_port, pDest->port);
|
||||
|
||||
|
|
|
|||
|
|
@ -276,15 +276,21 @@ typedef struct
|
|||
char sz_last_heart_beat_time[8];
|
||||
} FDFSStorageStatBuff;
|
||||
|
||||
typedef struct StructFDFSIPInfo
|
||||
{
|
||||
int type; //ip type
|
||||
char address[IP_ADDRESS_SIZE];
|
||||
} FDFSIPInfo;
|
||||
|
||||
typedef struct StructFDFSMultiIP
|
||||
{
|
||||
int count;
|
||||
int index;
|
||||
char ips[FDFS_MULTI_IP_MAX_COUNT][IP_ADDRESS_SIZE];
|
||||
FDFSIPInfo ips[FDFS_MULTI_IP_MAX_COUNT];
|
||||
} FDFSMultiIP;
|
||||
|
||||
#define FDFS_CURRENT_IP_ADDR(pServer) \
|
||||
(pServer)->ip_addrs.ips[(pServer)->ip_addrs.index]
|
||||
(pServer)->ip_addrs.ips[(pServer)->ip_addrs.index].address
|
||||
|
||||
typedef struct StructFDFSStorageDetail
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue