add func fdfs_set_server_info_index1

v6.03_dev
YuQing 2019-11-16 11:30:20 +08:00
parent cb24cd82e1
commit 3b1045268e
6 changed files with 43 additions and 6 deletions

View File

@ -133,6 +133,7 @@ int main(int argc, char *argv[])
{
if (fdfs_server_contain1(g_tracker_group.servers + i, &conn))
{
fdfs_set_server_info_index1(g_tracker_group.servers + i, &conn);
g_tracker_group.server_index = i;
break;
}

View File

@ -13,8 +13,10 @@ base_path=/home/yuqing/fastdfs
# the value format of tracker_server is "HOST:PORT",
# the HOST can be hostname or ip address,
# and the HOST can be dual IPs or hostnames seperated by comma,
# the dual IPS must be an intranet IP and an extranet IP.
# such as: 192.168.2.100,122.244.141.46
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
# or two different types of inner (intranet) IPs.
# for example: 192.168.2.100,122.244.141.46:22122
# another eg.: 192.168.1.10,172.17.4.21:22122
tracker_server=192.168.0.196:22122
tracker_server=192.168.0.197:22122

View File

@ -119,8 +119,10 @@ subdir_count_per_path=256
# the value format of tracker_server is "HOST:PORT",
# the HOST can be hostname or ip address,
# and the HOST can be dual IPs or hostnames seperated by comma,
# the dual IPS must be an intranet IP and an extranet IP.
# such as: 192.168.2.100,122.244.141.46
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
# or two different types of inner (intranet) IPs.
# for example: 192.168.2.100,122.244.141.46:22122
# another eg.: 192.168.1.10,172.17.4.21:22122
tracker_server=192.168.209.121:22122
tracker_server=192.168.209.122:22122

View File

@ -1,7 +1,9 @@
# <id> <group_name> <ip_or_hostname[:port]>
# storage ip or hostname can be dual IPs seperated by comma,
# one is an intranet IP and another is an extranet IP.
# one is an inner (intranet) IP and another is an outer (extranet) IP,
# or two different types of inner (intranet) IPs
# for example: 192.168.2.100,122.244.141.46
# another eg.: 192.168.1.10,172.17.4.21
#
# the port is optional. if you run more than one storaged instances
# in a server, you must specified the port to distinguish different instances.

View File

@ -707,7 +707,7 @@ int fdfs_check_and_format_ips(FDFSMultiIP *ip_addrs,
void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip)
{
int i;
if (multi_ip->count == 1)
if (multi_ip->count <= 1)
{
return;
}
@ -722,6 +722,26 @@ void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip)
}
}
void fdfs_set_server_info_index(TrackerServerInfo *pServer,
const char *target_ip, const int target_port)
{
int i;
if (pServer->count <= 1)
{
return;
}
for (i=0; i<pServer->count; i++)
{
if (FC_CONNECTION_SERVER_EQUAL(pServer->connections[i],
target_ip, target_port))
{
pServer->index = i;
break;
}
}
}
void fdfs_set_server_info(TrackerServerInfo *pServer,
const char *ip_addr, const int port)
{

View File

@ -148,6 +148,16 @@ const char *fdfs_get_ipaddr_by_peer_ip(const FDFSMultiIP *ip_addrs,
void fdfs_set_multi_ip_index(FDFSMultiIP *multi_ip, const char *target_ip);
void fdfs_set_server_info_index(TrackerServerInfo *pServer,
const char *target_ip, const int target_port);
static inline void fdfs_set_server_info_index1(TrackerServerInfo *pServer,
const ConnectionInfo *target)
{
return fdfs_set_server_info_index(pServer,
target->ip_addr, target->port);
}
void fdfs_set_server_info(TrackerServerInfo *pServer,
const char *ip_addr, const int port);