check tracker server list when storage join
parent
0ead100d59
commit
2b8e9137fe
|
|
@ -108,6 +108,24 @@ bool fdfs_server_equal(TrackerServerInfo *pServer1,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrackerServerInfo *fdfs_tracker_group_get_server(TrackerServerGroup *pGroup,
|
||||||
|
const char *target_ip, const int target_port)
|
||||||
|
{
|
||||||
|
TrackerServerInfo *pServer;
|
||||||
|
TrackerServerInfo *pEnd;
|
||||||
|
|
||||||
|
pEnd = pGroup->servers + pGroup->server_count;
|
||||||
|
for (pServer=pGroup->servers; pServer<pEnd; pServer++)
|
||||||
|
{
|
||||||
|
if (fdfs_server_contain(pServer, target_ip, target_port))
|
||||||
|
{
|
||||||
|
return pServer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo)
|
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,17 @@ bool fdfs_server_contain_ex(TrackerServerInfo *pServer1,
|
||||||
bool fdfs_server_equal(TrackerServerInfo *pServer1,
|
bool fdfs_server_equal(TrackerServerInfo *pServer1,
|
||||||
TrackerServerInfo *pServer2);
|
TrackerServerInfo *pServer2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tracker group get server
|
||||||
|
* params:
|
||||||
|
* pGroup: the tracker group
|
||||||
|
* target_ip: the ip address to find
|
||||||
|
* target_port: the port to find
|
||||||
|
* return: TrackerServerInfo pointer contain target ip and port
|
||||||
|
**/
|
||||||
|
TrackerServerInfo *fdfs_tracker_group_get_server(TrackerServerGroup *pGroup,
|
||||||
|
const char *target_ip, const int target_port);
|
||||||
|
|
||||||
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo);
|
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo);
|
||||||
|
|
||||||
int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
int fdfs_parse_server_info_ex(char *server_str, const int default_port,
|
||||||
|
|
|
||||||
|
|
@ -4027,6 +4027,43 @@ static int tracker_mem_cmp_tracker_running_status(const void *p1, const void *p2
|
||||||
return pStatus2->restart_interval - pStatus1->restart_interval;
|
return pStatus2->restart_interval - pStatus1->restart_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int find_my_ip_in_tracker_list()
|
||||||
|
{
|
||||||
|
const char *current_ip;
|
||||||
|
const char *previous_ip;
|
||||||
|
TrackerServerInfo *pServer;
|
||||||
|
char buff[256];
|
||||||
|
|
||||||
|
previous_ip = NULL;
|
||||||
|
while ((current_ip=get_next_local_ip(previous_ip)) != NULL)
|
||||||
|
{
|
||||||
|
pServer = fdfs_tracker_group_get_server(&g_tracker_servers,
|
||||||
|
current_ip, g_server_port);
|
||||||
|
if (pServer != NULL)
|
||||||
|
{
|
||||||
|
if (pServer->count > 1)
|
||||||
|
{
|
||||||
|
ConnectionInfo *conn;
|
||||||
|
ConnectionInfo *end;
|
||||||
|
|
||||||
|
end = pServer->connections + pServer->count;
|
||||||
|
for (conn=pServer->connections; conn<end; conn++)
|
||||||
|
{
|
||||||
|
insert_into_local_host_ip(conn->ip_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
previous_ip = current_ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"my ip NOT in tracker server list. %s",
|
||||||
|
__LINE__, local_host_ip_addrs_to_string(buff, sizeof(buff)));
|
||||||
|
return ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
static int tracker_mem_first_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
static int tracker_mem_first_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
{
|
{
|
||||||
TrackerServerInfo *pLocalTracker;
|
TrackerServerInfo *pLocalTracker;
|
||||||
|
|
@ -4057,7 +4094,7 @@ static int tracker_mem_first_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
|
|
||||||
g_tracker_servers.servers = servers;
|
g_tracker_servers.servers = servers;
|
||||||
g_tracker_servers.server_count = tracker_count;
|
g_tracker_servers.server_count = tracker_count;
|
||||||
return 0;
|
return find_my_ip_in_tracker_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
|
|
@ -4158,7 +4195,7 @@ static int tracker_mem_check_add_tracker_servers(FDFSStorageJoinBody *pJoinBody)
|
||||||
"add %d tracker servers, total tracker servers: %d",
|
"add %d tracker servers, total tracker servers: %d",
|
||||||
__LINE__, add_count, g_tracker_servers.server_count);
|
__LINE__, add_count, g_tracker_servers.server_count);
|
||||||
|
|
||||||
return 0;
|
return find_my_ip_in_tracker_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
static int tracker_mem_get_tracker_server(FDFSStorageJoinBody *pJoinBody, \
|
||||||
|
|
|
||||||
|
|
@ -1529,7 +1529,7 @@ static int tracker_deal_storage_join(struct fast_task_info *pTask)
|
||||||
joinBody.init_flag = pBody->init_flag;
|
joinBody.init_flag = pBody->init_flag;
|
||||||
joinBody.status = pBody->status;
|
joinBody.status = pBody->status;
|
||||||
|
|
||||||
getSockIpaddr(pTask->event.fd, \
|
getSockIpaddr(pTask->event.fd,
|
||||||
tracker_ip, IP_ADDRESS_SIZE);
|
tracker_ip, IP_ADDRESS_SIZE);
|
||||||
insert_into_local_host_ip(tracker_ip);
|
insert_into_local_host_ip(tracker_ip);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue