diff --git a/client/fdfs_monitor.c b/client/fdfs_monitor.c index 6bcc703..ef1c53f 100644 --- a/client/fdfs_monitor.c +++ b/client/fdfs_monitor.c @@ -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; } diff --git a/conf/client.conf b/conf/client.conf index a34e56e..c1173ec 100644 --- a/conf/client.conf +++ b/conf/client.conf @@ -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 diff --git a/conf/storage.conf b/conf/storage.conf index 82dc876..31fb080 100644 --- a/conf/storage.conf +++ b/conf/storage.conf @@ -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 diff --git a/conf/storage_ids.conf b/conf/storage_ids.conf index b444377..1075a43 100644 --- a/conf/storage_ids.conf +++ b/conf/storage_ids.conf @@ -1,7 +1,9 @@ # # 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. diff --git a/tracker/fdfs_shared_func.c b/tracker/fdfs_shared_func.c index 299e00d..6e76ea9 100644 --- a/tracker/fdfs_shared_func.c +++ b/tracker/fdfs_shared_func.c @@ -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; icount; 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) { diff --git a/tracker/fdfs_shared_func.h b/tracker/fdfs_shared_func.h index a82080f..b8903ec 100644 --- a/tracker/fdfs_shared_func.h +++ b/tracker/fdfs_shared_func.h @@ -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);