client support multi ip for tracker server
parent
16bbaf7884
commit
b1adb8889d
|
|
@ -48,24 +48,24 @@ static int storage_cmp_by_ip_and_port(const void *p1, const void *p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insert_into_sorted_servers(TrackerServerGroup *pTrackerGroup, \
|
static void insert_into_sorted_servers(TrackerServerGroup *pTrackerGroup, \
|
||||||
ConnectionInfo *pInsertedServer)
|
TrackerServerInfo *pInsertedServer)
|
||||||
{
|
{
|
||||||
ConnectionInfo *pDestServer;
|
TrackerServerInfo *pDestServer;
|
||||||
for (pDestServer=pTrackerGroup->servers+pTrackerGroup->server_count; \
|
for (pDestServer=pTrackerGroup->servers+pTrackerGroup->server_count;
|
||||||
pDestServer>pTrackerGroup->servers; pDestServer--)
|
pDestServer>pTrackerGroup->servers; pDestServer--)
|
||||||
{
|
{
|
||||||
if (storage_cmp_by_ip_and_port(pInsertedServer, \
|
if (storage_cmp_by_ip_and_port(pInsertedServer,
|
||||||
pDestServer-1) > 0)
|
pDestServer-1) > 0)
|
||||||
{
|
{
|
||||||
memcpy(pDestServer, pInsertedServer, \
|
memcpy(pDestServer, pInsertedServer,
|
||||||
sizeof(ConnectionInfo));
|
sizeof(TrackerServerInfo));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pDestServer, pDestServer-1, sizeof(ConnectionInfo));
|
memcpy(pDestServer, pDestServer-1, sizeof(TrackerServerInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pDestServer, pInsertedServer, sizeof(ConnectionInfo));
|
memcpy(pDestServer, pInsertedServer, sizeof(TrackerServerInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
||||||
|
|
@ -73,55 +73,25 @@ static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
||||||
{
|
{
|
||||||
char **ppSrc;
|
char **ppSrc;
|
||||||
char **ppEnd;
|
char **ppEnd;
|
||||||
ConnectionInfo destServer;
|
TrackerServerInfo destServer;
|
||||||
char *pSeperator;
|
int result;
|
||||||
char szHost[128];
|
|
||||||
int nHostLen;
|
|
||||||
|
|
||||||
memset(&destServer, 0, sizeof(ConnectionInfo));
|
memset(&destServer, 0, sizeof(TrackerServerInfo));
|
||||||
destServer.sock = -1;
|
fdfs_server_sock_reset(&destServer);
|
||||||
|
|
||||||
ppEnd = ppTrackerServers + pTrackerGroup->server_count;
|
ppEnd = ppTrackerServers + pTrackerGroup->server_count;
|
||||||
|
|
||||||
pTrackerGroup->server_count = 0;
|
pTrackerGroup->server_count = 0;
|
||||||
for (ppSrc=ppTrackerServers; ppSrc<ppEnd; ppSrc++)
|
for (ppSrc=ppTrackerServers; ppSrc<ppEnd; ppSrc++)
|
||||||
{
|
{
|
||||||
if ((pSeperator=strrchr(*ppSrc, ':')) == NULL)
|
if ((result=fdfs_parse_server_info(*ppSrc,
|
||||||
{
|
FDFS_TRACKER_SERVER_DEF_PORT, &destServer)) != 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
{
|
||||||
"conf file \"%s\", " \
|
return result;
|
||||||
"tracker_server \"%s\" is invalid, " \
|
}
|
||||||
"correct format is host:port", \
|
|
||||||
__LINE__, filename, *ppSrc);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nHostLen = pSeperator - (*ppSrc);
|
|
||||||
if (nHostLen >= sizeof(szHost))
|
|
||||||
{
|
|
||||||
nHostLen = sizeof(szHost) - 1;
|
|
||||||
}
|
|
||||||
memcpy(szHost, *ppSrc, nHostLen);
|
|
||||||
szHost[nHostLen] = '\0';
|
|
||||||
|
|
||||||
if (getIpaddrByName(szHost, destServer.ip_addr, \
|
|
||||||
sizeof(destServer.ip_addr)) == INADDR_NONE)
|
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"conf file \"%s\", " \
|
|
||||||
"host \"%s\" is invalid, error info: %s", \
|
|
||||||
__LINE__, filename, szHost, hstrerror(h_errno));
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
destServer.port = atoi(pSeperator+1);
|
|
||||||
if (destServer.port <= 0)
|
|
||||||
{
|
|
||||||
destServer.port = FDFS_TRACKER_SERVER_DEF_PORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bsearch(&destServer, pTrackerGroup->servers, \
|
if (bsearch(&destServer, pTrackerGroup->servers, \
|
||||||
pTrackerGroup->server_count, \
|
pTrackerGroup->server_count, \
|
||||||
sizeof(ConnectionInfo), \
|
sizeof(TrackerServerInfo), \
|
||||||
storage_cmp_by_ip_and_port) == NULL)
|
storage_cmp_by_ip_and_port) == NULL)
|
||||||
{
|
{
|
||||||
insert_into_sorted_servers(pTrackerGroup, &destServer);
|
insert_into_sorted_servers(pTrackerGroup, &destServer);
|
||||||
|
|
@ -131,7 +101,7 @@ static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+ \
|
for (pServer=pTrackerGroup->servers; pServer<pTrackerGroup->servers+ \
|
||||||
pTrackerGroup->server_count; pServer++)
|
pTrackerGroup->server_count; pServer++)
|
||||||
{
|
{
|
||||||
|
|
@ -161,8 +131,8 @@ int fdfs_load_tracker_group_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = sizeof(MultiConnectionInfo) * pTrackerGroup->server_count);
|
bytes = sizeof(TrackerServerInfo) * pTrackerGroup->server_count;
|
||||||
pTrackerGroup->servers = (MultiConnectionInfo *)malloc(bytes);
|
pTrackerGroup->servers = (TrackerServerInfo *)malloc(bytes);
|
||||||
if (pTrackerGroup->servers == NULL)
|
if (pTrackerGroup->servers == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
|
@ -412,39 +382,40 @@ int fdfs_copy_tracker_group(TrackerServerGroup *pDestTrackerGroup, \
|
||||||
TrackerServerGroup *pSrcTrackerGroup)
|
TrackerServerGroup *pSrcTrackerGroup)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
ConnectionInfo *pDestServer;
|
TrackerServerInfo *pDestServer;
|
||||||
ConnectionInfo *pDestServerEnd;
|
TrackerServerInfo *pDestServerEnd;
|
||||||
|
|
||||||
bytes = sizeof(ConnectionInfo) * pSrcTrackerGroup->server_count;
|
bytes = sizeof(TrackerServerInfo) * pSrcTrackerGroup->server_count;
|
||||||
pDestTrackerGroup->servers = (ConnectionInfo *)malloc(bytes);
|
pDestTrackerGroup->servers = (TrackerServerInfo *)malloc(bytes);
|
||||||
if (pDestTrackerGroup->servers == NULL)
|
if (pDestTrackerGroup->servers == NULL)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"malloc %d bytes fail", __LINE__, bytes);
|
"malloc %d bytes fail", __LINE__, bytes);
|
||||||
return errno != 0 ? errno : ENOMEM;
|
return errno != 0 ? errno : ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDestTrackerGroup->server_index = 0;
|
pDestTrackerGroup->server_index = 0;
|
||||||
|
pDestTrackerGroup->leader_index = 0;
|
||||||
pDestTrackerGroup->server_count = pSrcTrackerGroup->server_count;
|
pDestTrackerGroup->server_count = pSrcTrackerGroup->server_count;
|
||||||
memcpy(pDestTrackerGroup->servers, pSrcTrackerGroup->servers, bytes);
|
memcpy(pDestTrackerGroup->servers, pSrcTrackerGroup->servers, bytes);
|
||||||
|
|
||||||
pDestServerEnd = pDestTrackerGroup->servers + \
|
pDestServerEnd = pDestTrackerGroup->servers +
|
||||||
pDestTrackerGroup->server_count;
|
pDestTrackerGroup->server_count;
|
||||||
for (pDestServer=pDestTrackerGroup->servers; \
|
for (pDestServer=pDestTrackerGroup->servers;
|
||||||
pDestServer<pDestServerEnd; pDestServer++)
|
pDestServer<pDestServerEnd; pDestServer++)
|
||||||
{
|
{
|
||||||
pDestServer->sock = -1;
|
fdfs_server_sock_reset(pDestServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fdfs_tracker_group_equals(TrackerServerGroup *pGroup1, \
|
bool fdfs_tracker_group_equals(TrackerServerGroup *pGroup1,
|
||||||
TrackerServerGroup *pGroup2)
|
TrackerServerGroup *pGroup2)
|
||||||
{
|
{
|
||||||
ConnectionInfo *pServer1;
|
TrackerServerInfo *pServer1;
|
||||||
ConnectionInfo *pServer2;
|
TrackerServerInfo *pServer2;
|
||||||
ConnectionInfo *pEnd1;
|
TrackerServerInfo *pEnd1;
|
||||||
|
|
||||||
if (pGroup1->server_count != pGroup2->server_count)
|
if (pGroup1->server_count != pGroup2->server_count)
|
||||||
{
|
{
|
||||||
|
|
@ -456,8 +427,7 @@ bool fdfs_tracker_group_equals(TrackerServerGroup *pGroup1, \
|
||||||
pServer2 = pGroup2->servers;
|
pServer2 = pGroup2->servers;
|
||||||
while (pServer1 < pEnd1)
|
while (pServer1 < pEnd1)
|
||||||
{
|
{
|
||||||
if (!(strcmp(pServer1->ip_addr, pServer2->ip_addr) == 0 &&
|
if (!fdfs_server_equal(pServer1, pServer2))
|
||||||
pServer1->port == pServer2->port))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
||||||
group_name, storageServer.ip_addr, \
|
group_name, storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -233,7 +233,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -273,12 +273,12 @@ int main(int argc, char *argv[])
|
||||||
//sleep(90);
|
//sleep(90);
|
||||||
strcpy(appender_filename, remote_filename);
|
strcpy(appender_filename, remote_filename);
|
||||||
if (storage_truncate_file(pTrackerServer, pStorageServer, \
|
if (storage_truncate_file(pTrackerServer, pStorageServer, \
|
||||||
group_name, appender_filename, file_size / 2) != 0)
|
group_name, appender_filename, file_size * 2) != 0)
|
||||||
{
|
{
|
||||||
printf("truncate file fail, " \
|
printf("truncate file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ int main(int argc, char *argv[])
|
||||||
printf("append file fail, " \
|
printf("append file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
|
||||||
printf("modify file fail, " \
|
printf("modify file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -429,8 +429,8 @@ int main(int argc, char *argv[])
|
||||||
2 * file_size + file_size /2);
|
2 * file_size + file_size /2);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ int main(int argc, char *argv[])
|
||||||
group_name, storageServer.ip_addr, \
|
group_name, storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -274,7 +274,7 @@ int main(int argc, char *argv[])
|
||||||
printf("truncate file fail, " \
|
printf("truncate file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +340,7 @@ int main(int argc, char *argv[])
|
||||||
printf("append file fail, " \
|
printf("append file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +407,7 @@ int main(int argc, char *argv[])
|
||||||
printf("modify file fail, " \
|
printf("modify file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -425,8 +425,8 @@ int main(int argc, char *argv[])
|
||||||
2 * file_size);
|
2 * file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,11 @@ static int list_all_groups(const char *group_name);
|
||||||
|
|
||||||
static void usage(char *argv[])
|
static void usage(char *argv[])
|
||||||
{
|
{
|
||||||
printf("Usage: %s <config_file> [-h <tracker_server>] [list|delete|set_trunk_server <group_name> " \
|
printf("Usage: %s <config_file> [-h <tracker_server>] "
|
||||||
"[storage_id]]\n", argv[0]);
|
"[list|delete|set_trunk_server <group_name> [storage_id]]\n"
|
||||||
|
"\tthe tracker server format: host[:port], "
|
||||||
|
"the tracker default port is %d\n\n",
|
||||||
|
argv[0], FDFS_TRACKER_SERVER_DEF_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
@ -116,21 +119,20 @@ int main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char ip_addr[IP_ADDRESS_SIZE];
|
ConnectionInfo conn;
|
||||||
|
|
||||||
*ip_addr = '\0';
|
if ((result=conn_pool_parse_server_info(tracker_server, &conn,
|
||||||
if (getIpaddrByName(tracker_server, ip_addr, sizeof(ip_addr)) \
|
FDFS_TRACKER_SERVER_DEF_PORT)) != 0)
|
||||||
== INADDR_NONE)
|
|
||||||
{
|
{
|
||||||
printf("resolve ip address of tracker server: %s " \
|
printf("resolve ip address of tracker server: %s "
|
||||||
"fail!, error info: %s\n", tracker_server, hstrerror(h_errno));
|
"fail!, error info: %s\n", tracker_server, hstrerror(h_errno));
|
||||||
return 2;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<g_tracker_group.server_count; i++)
|
for (i=0; i<g_tracker_group.server_count; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(g_tracker_group.servers[i].ip_addr, \
|
if (fdfs_server_contain1(g_tracker_group.servers + i,
|
||||||
ip_addr) == 0)
|
&conn) == 0)
|
||||||
{
|
{
|
||||||
g_tracker_group.server_index = i;
|
g_tracker_group.server_index = i;
|
||||||
break;
|
break;
|
||||||
|
|
@ -144,7 +146,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("server_count=%d, server_index=%d\n", g_tracker_group.server_count, g_tracker_group.server_index);
|
printf("server_count=%d, server_index=%d\n",
|
||||||
|
g_tracker_group.server_count, g_tracker_group.server_index);
|
||||||
|
|
||||||
pTrackerServer = tracker_get_connection();
|
pTrackerServer = tracker_get_connection();
|
||||||
if (pTrackerServer == NULL)
|
if (pTrackerServer == NULL)
|
||||||
|
|
@ -251,7 +254,7 @@ int main(int argc, char *argv[])
|
||||||
usage(argv);
|
usage(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
|
||||||
group_name, storageServer.ip_addr, \
|
group_name, storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -269,7 +269,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +361,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload slave file fail, " \
|
printf("upload slave file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -467,7 +467,7 @@ int main(int argc, char *argv[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, result != 0);
|
tracker_close_connection_ex(pTrackerServer, result != 0);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -491,7 +491,7 @@ int main(int argc, char *argv[])
|
||||||
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -681,8 +681,8 @@ int main(int argc, char *argv[])
|
||||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
||||||
group_name, storageServer.ip_addr, \
|
group_name, storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -263,7 +263,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +349,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload slave file fail, " \
|
printf("upload slave file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -439,7 +439,7 @@ int main(int argc, char *argv[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -458,7 +458,7 @@ int main(int argc, char *argv[])
|
||||||
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
printf("storage=%s:%d\n", storageServer.ip_addr, \
|
||||||
storageServer.port);
|
storageServer.port);
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, \
|
if ((pStorageServer=tracker_make_connection(&storageServer, \
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
@ -648,8 +648,8 @@ int main(int argc, char *argv[])
|
||||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,14 @@ int main(int argc, char *argv[])
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\n", file_id);
|
printf("%s\n", file_id);
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ int main(int argc, char *argv[])
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_tracker_connection)
|
if (new_tracker_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pNewTracker, result != 0);
|
tracker_close_connection_ex(pNewTracker, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -98,7 +98,7 @@ static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ppStorageServer=tracker_connect_server(pNewStorage, \
|
if ((*ppStorageServer=tracker_make_connection(pNewStorage,
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -114,7 +114,7 @@ static int storage_get_connection(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((*ppStorageServer=tracker_connect_server( \
|
if ((*ppStorageServer=tracker_make_connection(
|
||||||
*ppStorageServer, &result)) == NULL)
|
*ppStorageServer, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -155,7 +155,7 @@ static int storage_get_upload_connection(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_tracker_connection)
|
if (new_tracker_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pNewTracker, result != 0);
|
tracker_close_connection_ex(pNewTracker, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -163,7 +163,7 @@ static int storage_get_upload_connection(ConnectionInfo *pTrackerServer, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ppStorageServer=tracker_connect_server(pNewStorage, \
|
if ((*ppStorageServer=tracker_make_connection(pNewStorage,
|
||||||
&result)) == NULL)
|
&result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -179,7 +179,7 @@ static int storage_get_upload_connection(ConnectionInfo *pTrackerServer, \
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((*ppStorageServer=tracker_connect_server( \
|
if ((*ppStorageServer=tracker_make_connection(
|
||||||
*ppStorageServer, &result)) == NULL)
|
*ppStorageServer, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -289,7 +289,7 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -411,7 +411,7 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -506,7 +506,7 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -684,7 +684,7 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1035,7 +1035,7 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1265,7 +1265,7 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1480,7 +1480,7 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1801,7 +1801,7 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1932,7 +1932,7 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2210,7 +2210,7 @@ int fdfs_get_file_info_ex(const char *group_name, const char *remote_filename, \
|
||||||
if (get_from_server)
|
if (get_from_server)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
|
|
||||||
conn = tracker_get_connection_r(&trackerServer, &result);
|
conn = tracker_get_connection_r(&trackerServer, &result);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -2220,7 +2220,7 @@ int fdfs_get_file_info_ex(const char *group_name, const char *remote_filename, \
|
||||||
|
|
||||||
result = storage_query_file_info(conn, \
|
result = storage_query_file_info(conn, \
|
||||||
NULL, group_name, remote_filename, pFileInfo);
|
NULL, group_name, remote_filename, pFileInfo);
|
||||||
tracker_disconnect_server_ex(conn, result != 0 && \
|
tracker_close_connection_ex(conn, result != 0 && \
|
||||||
result != ENOENT);
|
result != ENOENT);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2346,7 +2346,7 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ int main(int argc, char *argv[])
|
||||||
usage(argv);
|
usage(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +361,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload slave file fail, " \
|
printf("upload slave file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -467,7 +467,7 @@ int main(int argc, char *argv[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, result != 0);
|
tracker_close_connection_ex(pTrackerServer, result != 0);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -681,8 +681,8 @@ int main(int argc, char *argv[])
|
||||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload file fail, " \
|
printf("upload file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +349,7 @@ int main(int argc, char *argv[])
|
||||||
printf("upload slave file fail, " \
|
printf("upload slave file fail, " \
|
||||||
"error no: %d, error info: %s\n", \
|
"error no: %d, error info: %s\n", \
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -439,7 +439,7 @@ int main(int argc, char *argv[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -648,8 +648,8 @@ int main(int argc, char *argv[])
|
||||||
pStorageServer->ip_addr, pStorageServer->port, result);
|
pStorageServer->ip_addr, pStorageServer->port, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageServer, true);
|
tracker_close_connection_ex(pStorageServer, true);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
|
|
||||||
fdfs_client_destroy();
|
fdfs_client_destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,22 +28,19 @@
|
||||||
|
|
||||||
int tracker_get_all_connections_ex(TrackerServerGroup *pTrackerGroup)
|
int tracker_get_all_connections_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
|
ConnectionInfo *conn;
|
||||||
|
int result;
|
||||||
int success_count;
|
int success_count;
|
||||||
|
|
||||||
success_count = 0;
|
success_count = 0;
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
if (pServer->sock >= 0)
|
if ((conn=tracker_connect_server(pServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
success_count++;
|
fdfs_active_test(conn);
|
||||||
}
|
|
||||||
else if (conn_pool_connect_server(pServer, \
|
|
||||||
g_fdfs_connect_timeout) == 0)
|
|
||||||
{
|
|
||||||
fdfs_active_test(pServer);
|
|
||||||
success_count++;
|
success_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,22 +50,22 @@ int tracker_get_all_connections_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
|
|
||||||
void tracker_close_all_connections_ex(TrackerServerGroup *pTrackerGroup)
|
void tracker_close_all_connections_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
|
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
conn_pool_disconnect_server(pServer);
|
tracker_disconnect_server(pServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup)
|
ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo *pCurrentServer;
|
TrackerServerInfo *pCurrentServer;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
int server_index;
|
int server_index;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
|
@ -91,7 +88,7 @@ ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
if ((conn=tracker_connect_server(pServer, &result)) != NULL)
|
if ((conn=tracker_connect_server(pServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
pTrackerGroup->server_index = pServer - \
|
pTrackerGroup->server_index = pServer -
|
||||||
pTrackerGroup->servers;
|
pTrackerGroup->servers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +103,7 @@ ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
if ((conn=tracker_connect_server(pServer, &result)) != NULL)
|
if ((conn=tracker_connect_server(pServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
pTrackerGroup->server_index = pServer - \
|
pTrackerGroup->server_index = pServer -
|
||||||
pTrackerGroup->servers;
|
pTrackerGroup->servers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -124,9 +121,9 @@ ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup)
|
||||||
|
|
||||||
ConnectionInfo *tracker_get_connection_no_pool(TrackerServerGroup *pTrackerGroup)
|
ConnectionInfo *tracker_get_connection_no_pool(TrackerServerGroup *pTrackerGroup)
|
||||||
{
|
{
|
||||||
ConnectionInfo *pCurrentServer;
|
TrackerServerInfo *pCurrentServer;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
int server_index;
|
int server_index;
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -141,20 +138,17 @@ ConnectionInfo *tracker_get_connection_no_pool(TrackerServerGroup *pTrackerGroup
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
pCurrentServer = pTrackerGroup->servers + server_index;
|
pCurrentServer = pTrackerGroup->servers + server_index;
|
||||||
if ((result=tracker_connect_server_no_pool(pCurrentServer)) == 0)
|
if ((conn=tracker_connect_server_no_pool(pCurrentServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
conn = pCurrentServer;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pCurrentServer+1; pServer<pEnd; pServer++)
|
for (pServer=pCurrentServer+1; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
if ((result=tracker_connect_server_no_pool(pServer)) == 0)
|
if ((conn=tracker_connect_server_no_pool(pServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
conn = pServer;
|
pTrackerGroup->server_index = pServer - pTrackerGroup->servers;
|
||||||
pTrackerGroup->server_index = pServer - \
|
|
||||||
pTrackerGroup->servers;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,11 +160,9 @@ ConnectionInfo *tracker_get_connection_no_pool(TrackerServerGroup *pTrackerGroup
|
||||||
|
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pCurrentServer; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pCurrentServer; pServer++)
|
||||||
{
|
{
|
||||||
if ((result=tracker_connect_server_no_pool(pServer)) == 0)
|
if ((conn=tracker_connect_server_no_pool(pServer, &result)) != NULL)
|
||||||
{
|
{
|
||||||
conn = pServer;
|
pTrackerGroup->server_index = pServer - pTrackerGroup->servers;
|
||||||
pTrackerGroup->server_index = pServer - \
|
|
||||||
pTrackerGroup->servers;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,13 +177,13 @@ ConnectionInfo *tracker_get_connection_no_pool(TrackerServerGroup *pTrackerGroup
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup,
|
||||||
ConnectionInfo *pTrackerServer, int *err_no)
|
TrackerServerInfo *pTrackerServer, int *err_no)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo *pCurrentServer;
|
TrackerServerInfo *pCurrentServer;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
int server_index;
|
int server_index;
|
||||||
|
|
||||||
server_index = pTrackerGroup->server_index;
|
server_index = pTrackerGroup->server_index;
|
||||||
|
|
@ -203,8 +195,8 @@ ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
pCurrentServer = pTrackerGroup->servers + server_index;
|
pCurrentServer = pTrackerGroup->servers + server_index;
|
||||||
memcpy(pTrackerServer, pCurrentServer, sizeof(ConnectionInfo));
|
memcpy(pTrackerServer, pCurrentServer, sizeof(TrackerServerInfo));
|
||||||
pTrackerServer->sock = -1;
|
fdfs_server_sock_reset(pTrackerServer);
|
||||||
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -213,11 +205,11 @@ ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pCurrentServer+1; pServer<pEnd; pServer++)
|
for (pServer=pCurrentServer+1; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(pTrackerServer, pServer, sizeof(ConnectionInfo));
|
memcpy(pTrackerServer, pServer, sizeof(TrackerServerInfo));
|
||||||
pTrackerServer->sock = -1;
|
fdfs_server_sock_reset(pTrackerServer);
|
||||||
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
||||||
{
|
{
|
||||||
pTrackerGroup->server_index = pServer - \
|
pTrackerGroup->server_index = pServer -
|
||||||
pTrackerGroup->servers;
|
pTrackerGroup->servers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -230,11 +222,11 @@ ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
|
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pCurrentServer; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pCurrentServer; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(pTrackerServer, pServer, sizeof(ConnectionInfo));
|
memcpy(pTrackerServer, pServer, sizeof(TrackerServerInfo));
|
||||||
pTrackerServer->sock = -1;
|
fdfs_server_sock_reset(pTrackerServer);
|
||||||
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
if ((conn=tracker_connect_server(pTrackerServer, err_no)) != NULL)
|
||||||
{
|
{
|
||||||
pTrackerGroup->server_index = pServer - \
|
pTrackerGroup->server_index = pServer -
|
||||||
pTrackerGroup->servers;
|
pTrackerGroup->servers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -327,7 +319,7 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -530,7 +522,7 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -610,7 +602,7 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -727,7 +719,7 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -811,7 +803,7 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -910,7 +902,7 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -993,7 +985,7 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -1088,7 +1080,7 @@ int tracker_query_storage_store_list_with_group( \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -1159,9 +1151,9 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
ConnectionInfo tracker_server;
|
TrackerServerInfo tracker_server;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
FDFSStorageInfo storage_infos[1];
|
FDFSStorageInfo storage_infos[1];
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE];
|
FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
|
|
@ -1177,8 +1169,8 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(&tracker_server, pServer, sizeof(ConnectionInfo));
|
memcpy(&tracker_server, pServer, sizeof(TrackerServerInfo));
|
||||||
tracker_server.sock = -1;
|
fdfs_server_sock_reset(&tracker_server);
|
||||||
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1186,7 +1178,7 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
|
|
||||||
result = tracker_list_servers(conn, group_name, storage_id, \
|
result = tracker_list_servers(conn, group_name, storage_id, \
|
||||||
storage_infos, 1, &storage_count);
|
storage_infos, 1, &storage_count);
|
||||||
tracker_disconnect_server_ex(conn, result != 0 && result != ENOENT);
|
tracker_close_connection_ex(conn, result != 0 && result != ENOENT);
|
||||||
if (result != 0 && result != ENOENT)
|
if (result != 0 && result != ENOENT)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1225,8 +1217,8 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
result = 0;
|
result = 0;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(&tracker_server, pServer, sizeof(ConnectionInfo));
|
memcpy(&tracker_server, pServer, sizeof(TrackerServerInfo));
|
||||||
tracker_server.sock = -1;
|
fdfs_server_sock_reset(&tracker_server);
|
||||||
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1236,10 +1228,10 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
storage_id_len, g_fdfs_network_timeout)) != 0)
|
storage_id_len, g_fdfs_network_timeout)) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%d fail, " \
|
"send data to tracker server %s:%d fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, \
|
"errno: %d, error info: %s", __LINE__,
|
||||||
tracker_server.ip_addr, tracker_server.port, \
|
conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1254,7 +1246,7 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(conn, result != 0 && result != ENOENT);
|
tracker_close_connection_ex(conn, result != 0 && result != ENOENT);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
if (result == ENOENT)
|
if (result == ENOENT)
|
||||||
|
|
@ -1284,9 +1276,9 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
ConnectionInfo tracker_server;
|
TrackerServerInfo tracker_server;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN];
|
||||||
char in_buff[1];
|
char in_buff[1];
|
||||||
char *pInBuff;
|
char *pInBuff;
|
||||||
|
|
@ -1305,28 +1297,28 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(&tracker_server, pServer, sizeof(ConnectionInfo));
|
memcpy(&tracker_server, pServer, sizeof(TrackerServerInfo));
|
||||||
tracker_server.sock = -1;
|
fdfs_server_sock_reset(&tracker_server);
|
||||||
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tcpsenddata_nb(conn->sock, out_buff, \
|
if ((result=tcpsenddata_nb(conn->sock, out_buff,
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN,
|
||||||
g_fdfs_network_timeout)) != 0)
|
g_fdfs_network_timeout)) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%d fail, " \
|
"send data to tracker server %s:%d fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, \
|
"errno: %d, error info: %s", __LINE__,
|
||||||
tracker_server.ip_addr, tracker_server.port, \
|
conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInBuff = in_buff;
|
pInBuff = in_buff;
|
||||||
result = fdfs_recv_response(conn, &pInBuff, 0, &in_bytes);
|
result = fdfs_recv_response(conn, &pInBuff, 0, &in_bytes);
|
||||||
tracker_disconnect_server_ex(conn, result != 0 && result != ENOENT);
|
tracker_close_connection_ex(conn, result != 0 && result != ENOENT);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, "
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
|
@ -1345,9 +1337,9 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
||||||
{
|
{
|
||||||
TrackerHeader *pHeader;
|
TrackerHeader *pHeader;
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
ConnectionInfo tracker_server;
|
TrackerServerInfo tracker_server;
|
||||||
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
char out_buff[sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN + \
|
||||||
FDFS_STORAGE_ID_MAX_SIZE];
|
FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
char in_buff[FDFS_STORAGE_ID_MAX_SIZE];
|
char in_buff[FDFS_STORAGE_ID_MAX_SIZE];
|
||||||
|
|
@ -1381,8 +1373,8 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(&tracker_server, pServer, sizeof(ConnectionInfo));
|
memcpy(&tracker_server, pServer, sizeof(TrackerServerInfo));
|
||||||
tracker_server.sock = -1;
|
fdfs_server_sock_reset(&tracker_server);
|
||||||
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1392,21 +1384,21 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
|
||||||
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
sizeof(TrackerHeader) + FDFS_GROUP_NAME_MAX_LEN +
|
||||||
storage_id_len, g_fdfs_network_timeout)) != 0)
|
storage_id_len, g_fdfs_network_timeout)) != 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"send data to tracker server %s:%d fail, " \
|
"send data to tracker server %s:%d fail, "
|
||||||
"errno: %d, error info: %s", __LINE__, \
|
"errno: %d, error info: %s", __LINE__,
|
||||||
tracker_server.ip_addr, tracker_server.port, \
|
conn->ip_addr, conn->port,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
|
|
||||||
tracker_disconnect_server_ex(conn, true);
|
tracker_close_connection_ex(conn, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInBuff = in_buff;
|
pInBuff = in_buff;
|
||||||
result = fdfs_recv_response(conn, &pInBuff, \
|
result = fdfs_recv_response(conn, &pInBuff,
|
||||||
sizeof(in_buff) - 1, &in_bytes);
|
sizeof(in_buff) - 1, &in_bytes);
|
||||||
|
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
strcpy(new_trunk_server_id, in_buff);
|
strcpy(new_trunk_server_id, in_buff);
|
||||||
|
|
@ -1500,7 +1492,7 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -1587,7 +1579,7 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
|
||||||
|
|
||||||
if (new_connection)
|
if (new_connection)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
|
@ -1614,9 +1606,9 @@ int tracker_get_storage_max_status(TrackerServerGroup *pTrackerGroup, \
|
||||||
char *storage_id, int *status)
|
char *storage_id, int *status)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
ConnectionInfo tracker_server;
|
TrackerServerInfo tracker_server;
|
||||||
ConnectionInfo *pServer;
|
TrackerServerInfo *pServer;
|
||||||
ConnectionInfo *pEnd;
|
TrackerServerInfo *pEnd;
|
||||||
FDFSStorageBrief storage_brief;
|
FDFSStorageBrief storage_brief;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
|
@ -1628,8 +1620,8 @@ int tracker_get_storage_max_status(TrackerServerGroup *pTrackerGroup, \
|
||||||
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
pEnd = pTrackerGroup->servers + pTrackerGroup->server_count;
|
||||||
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
for (pServer=pTrackerGroup->servers; pServer<pEnd; pServer++)
|
||||||
{
|
{
|
||||||
memcpy(&tracker_server, pServer, sizeof(ConnectionInfo));
|
memcpy(&tracker_server, pServer, sizeof(TrackerServerInfo));
|
||||||
tracker_server.sock = -1;
|
fdfs_server_sock_reset(&tracker_server);
|
||||||
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
if ((conn=tracker_connect_server(&tracker_server, &result)) == NULL)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1637,7 +1629,7 @@ int tracker_get_storage_max_status(TrackerServerGroup *pTrackerGroup, \
|
||||||
|
|
||||||
result = tracker_get_storage_status(conn, group_name, \
|
result = tracker_get_storage_status(conn, group_name, \
|
||||||
ip_addr, &storage_brief);
|
ip_addr, &storage_brief);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ typedef struct
|
||||||
do { \
|
do { \
|
||||||
if (pTrackerServer->sock < 0) \
|
if (pTrackerServer->sock < 0) \
|
||||||
{ \
|
{ \
|
||||||
if ((conn=tracker_connect_server( \
|
if ((conn=tracker_make_connection( \
|
||||||
pTrackerServer, &result)) != NULL) \
|
pTrackerServer, &result)) != NULL) \
|
||||||
{ \
|
{ \
|
||||||
return result; \
|
return result; \
|
||||||
|
|
@ -82,7 +82,7 @@ ConnectionInfo *tracker_get_connection_ex(TrackerServerGroup *pTrackerGroup);
|
||||||
* return: 0 success, !=0 fail
|
* return: 0 success, !=0 fail
|
||||||
**/
|
**/
|
||||||
ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
ConnectionInfo *tracker_get_connection_r_ex(TrackerServerGroup *pTrackerGroup, \
|
||||||
ConnectionInfo *pTrackerServer, int *err_no);
|
TrackerServerInfo *pTrackerServer, int *err_no);
|
||||||
|
|
||||||
#define tracker_get_all_connections() \
|
#define tracker_get_all_connections() \
|
||||||
tracker_get_all_connections_ex((&g_tracker_group))
|
tracker_get_all_connections_ex((&g_tracker_group))
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int storage_count;
|
int storage_count;
|
||||||
ConnectionInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
ConnectionInfo *pTrackerConn;
|
ConnectionInfo *pTrackerConn;
|
||||||
FDFSGroupStat groupStat;
|
FDFSGroupStat groupStat;
|
||||||
FDFSStorageInfo storageStats[FDFS_MAX_SERVERS_EACH_GROUP];
|
FDFSStorageInfo storageStats[FDFS_MAX_SERVERS_EACH_GROUP];
|
||||||
|
|
@ -187,7 +187,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
g_group_name, &groupStat);
|
g_group_name, &groupStat);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pTrackerConn, true);
|
tracker_close_connection_ex(pTrackerConn, true);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
"storage server count: %d in the group <= 0!",\
|
"storage server count: %d in the group <= 0!",\
|
||||||
__LINE__, groupStat.count);
|
__LINE__, groupStat.count);
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerConn);
|
tracker_close_connection(pTrackerConn);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +209,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
"storage server count in the group = 1, " \
|
"storage server count in the group = 1, " \
|
||||||
"does not need recovery", __LINE__);
|
"does not need recovery", __LINE__);
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerConn);
|
tracker_close_connection(pTrackerConn);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,13 +221,13 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
"does not need recovery", __LINE__, \
|
"does not need recovery", __LINE__, \
|
||||||
g_fdfs_store_paths.count, groupStat.store_path_count);
|
g_fdfs_store_paths.count, groupStat.store_path_count);
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerConn);
|
tracker_close_connection(pTrackerConn);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupStat.active_count <= 0)
|
if (groupStat.active_count <= 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTrackerConn);
|
tracker_close_connection(pTrackerConn);
|
||||||
sleep(5);
|
sleep(5);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -235,7 +235,7 @@ static int recovery_get_src_storage_server(ConnectionInfo *pSrcStorage)
|
||||||
result = tracker_list_servers(pTrackerConn, \
|
result = tracker_list_servers(pTrackerConn, \
|
||||||
g_group_name, NULL, storageStats, \
|
g_group_name, NULL, storageStats, \
|
||||||
FDFS_MAX_SERVERS_EACH_GROUP, &storage_count);
|
FDFS_MAX_SERVERS_EACH_GROUP, &storage_count);
|
||||||
tracker_disconnect_server_ex(pTrackerConn, result != 0);
|
tracker_close_connection_ex(pTrackerConn, result != 0);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|
@ -729,7 +729,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pStorageConn, result != 0);
|
tracker_close_connection_ex(pStorageConn, result != 0);
|
||||||
recovery_write_to_mark_file(pBasePath, pReader);
|
recovery_write_to_mark_file(pBasePath, pReader);
|
||||||
if (bContinueFlag)
|
if (bContinueFlag)
|
||||||
{
|
{
|
||||||
|
|
@ -1120,7 +1120,7 @@ int storage_disk_recovery_start(const int store_path_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
result = storage_do_fetch_binlog(pStorageConn, store_path_index);
|
||||||
tracker_disconnect_server_ex(pStorageConn, true);
|
tracker_close_connection_ex(pStorageConn, true);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -257,8 +257,8 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
|
||||||
static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
||||||
{
|
{
|
||||||
int total_len;
|
int total_len;
|
||||||
ConnectionInfo *pTrackerServer;
|
TrackerServerInfo *pTrackerServer;
|
||||||
ConnectionInfo *pTrackerEnd;
|
TrackerServerInfo *pTrackerEnd;
|
||||||
|
|
||||||
total_len = snprintf(buff, buffSize, \
|
total_len = snprintf(buff, buffSize, \
|
||||||
"\ng_tracker_group.server_count=%d, " \
|
"\ng_tracker_group.server_count=%d, " \
|
||||||
|
|
@ -275,9 +275,10 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
|
||||||
pTrackerServer<pTrackerEnd; pTrackerServer++)
|
pTrackerServer<pTrackerEnd; pTrackerServer++)
|
||||||
{
|
{
|
||||||
total_len += snprintf(buff + total_len, buffSize - total_len,
|
total_len += snprintf(buff + total_len, buffSize - total_len,
|
||||||
"\t%d. tracker server=%s:%d\n", \
|
"\t%d. tracker server=%s:%d\n",
|
||||||
(int)(pTrackerServer - g_tracker_group.servers) + 1, \
|
(int)(pTrackerServer - g_tracker_group.servers) + 1,
|
||||||
pTrackerServer->ip_addr, pTrackerServer->port);
|
pTrackerServer->connections[0].ip_addr,
|
||||||
|
pTrackerServer->connections[0].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_len;
|
return total_len;
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ static int storage_get_group_name_from_tracker()
|
||||||
}
|
}
|
||||||
|
|
||||||
result = storage_do_get_group_name(pTrackerConn);
|
result = storage_do_get_group_name(pTrackerConn);
|
||||||
tracker_disconnect_server_ex(pTrackerConn,
|
tracker_close_connection_ex(pTrackerConn,
|
||||||
result != 0 && result != ENOENT);
|
result != 0 && result != ENOENT);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -234,7 +234,7 @@ static int tracker_get_my_server_id()
|
||||||
|
|
||||||
result = tracker_get_storage_id(pTrackerServer, \
|
result = tracker_get_storage_id(pTrackerServer, \
|
||||||
g_group_name, g_tracker_client_ip, g_my_server_id_str);
|
g_group_name, g_tracker_client_ip, g_my_server_id_str);
|
||||||
tracker_disconnect_server_ex(pTrackerServer, result != 0);
|
tracker_close_connection_ex(pTrackerServer, result != 0);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ static int storage_convert_src_server_id()
|
||||||
|
|
||||||
result = tracker_get_storage_id(pTrackerConn,
|
result = tracker_get_storage_id(pTrackerConn,
|
||||||
g_group_name, g_sync_src_id, g_sync_src_id);
|
g_group_name, g_sync_src_id, g_sync_src_id);
|
||||||
tracker_disconnect_server_ex(pTrackerConn,
|
tracker_close_connection_ex(pTrackerConn,
|
||||||
result != 0 && result != ENOENT);
|
result != 0 && result != ENOENT);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2258,7 +2258,7 @@ static int storage_client_create_link_wrapper(struct fast_task_info *pTask, \
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int src_store_path_index;
|
int src_store_path_index;
|
||||||
ConnectionInfo trackerServer;
|
TrackerServerInfo trackerServer;
|
||||||
ConnectionInfo *pTracker;
|
ConnectionInfo *pTracker;
|
||||||
ConnectionInfo storageServer;
|
ConnectionInfo storageServer;
|
||||||
ConnectionInfo *pStorageServer;
|
ConnectionInfo *pStorageServer;
|
||||||
|
|
@ -2286,7 +2286,7 @@ static int storage_client_create_link_wrapper(struct fast_task_info *pTask, \
|
||||||
&storageServer, group_name, src_filename);
|
&storageServer, group_name, src_filename);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pTracker, true);
|
tracker_close_connection_ex(pTracker, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2304,7 +2304,7 @@ static int storage_client_create_link_wrapper(struct fast_task_info *pTask, \
|
||||||
if ((pStorageServer=tracker_make_connection(
|
if ((pStorageServer=tracker_make_connection(
|
||||||
&storageServer, &result)) == NULL)
|
&storageServer, &result)) == NULL)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTracker);
|
tracker_close_connection(pTracker);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2326,7 +2326,7 @@ static int storage_client_create_link_wrapper(struct fast_task_info *pTask, \
|
||||||
filename_len, sourceFileInfo.src_true_filename, \
|
filename_len, sourceFileInfo.src_true_filename, \
|
||||||
&src_store_path_index)) != 0)
|
&src_store_path_index)) != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTracker);
|
tracker_close_connection(pTracker);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2352,11 +2352,11 @@ static int storage_client_create_link_wrapper(struct fast_task_info *pTask, \
|
||||||
file_ext_name, remote_filename, filename_len);
|
file_ext_name, remote_filename, filename_len);
|
||||||
if (pStorageServer != NULL)
|
if (pStorageServer != NULL)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pStorageServer, result != 0);
|
tracker_close_connection_ex(pStorageServer, result != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server(pTracker);
|
tracker_close_connection(pTracker);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1036,7 +1036,7 @@ static int notify_reselect_tracker_leader(TrackerServerInfo *pTrackerServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = _notify_reselect_tleader(conn);
|
result = _notify_reselect_tleader(conn);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ int trunk_client_trunk_alloc_space(const int file_size, \
|
||||||
result = trunk_client_trunk_do_alloc_space(pTrunkServer, \
|
result = trunk_client_trunk_do_alloc_space(pTrunkServer, \
|
||||||
file_size, pTrunkInfo);
|
file_size, pTrunkInfo);
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrunkServer, result != 0);
|
tracker_close_connection_ex(pTrunkServer, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,7 +228,7 @@ int trunk_client_trunk_alloc_confirm(const FDFSTrunkFullInfo *pTrunkInfo, \
|
||||||
result = trunk_client_trunk_do_alloc_confirm(pTrunkServer, \
|
result = trunk_client_trunk_do_alloc_confirm(pTrunkServer, \
|
||||||
pTrunkInfo, status);
|
pTrunkInfo, status);
|
||||||
|
|
||||||
tracker_disconnect_server_ex(pTrunkServer, result != 0);
|
tracker_close_connection_ex(pTrunkServer, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,7 +259,7 @@ int trunk_client_trunk_free_space(const FDFSTrunkFullInfo *pTrunkInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = trunk_client_trunk_do_free_space(pTrunkServer, pTrunkInfo);
|
result = trunk_client_trunk_do_free_space(pTrunkServer, pTrunkInfo);
|
||||||
tracker_disconnect_server_ex(pTrunkServer, result != 0);
|
tracker_close_connection_ex(pTrunkServer, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,14 @@ int upload_file(const char *file_buff, const int file_size, char *file_id, char
|
||||||
if ((result=tracker_query_storage_store(pTrackerServer, &storageServer,
|
if ((result=tracker_query_storage_store(pTrackerServer, &storageServer,
|
||||||
group_name, &store_path_index)) != 0)
|
group_name, &store_path_index)) != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
||||||
== NULL)
|
== NULL)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,8 +60,8 @@ int upload_file(const char *file_buff, const int file_size, char *file_id, char
|
||||||
result = storage_upload_by_filebuff1(pTrackerServer, pStorageServer,
|
result = storage_upload_by_filebuff1(pTrackerServer, pStorageServer,
|
||||||
store_path_index, file_buff, file_size, NULL, NULL, 0, "", file_id);
|
store_path_index, file_buff, file_size, NULL, NULL, 0, "", file_id);
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
tracker_disconnect_server(pStorageServer);
|
tracker_close_connection(pStorageServer);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -83,14 +83,14 @@ int download_file(const char *file_id, int *file_size, char *storage_ip)
|
||||||
if ((result=tracker_query_storage_fetch1(pTrackerServer, \
|
if ((result=tracker_query_storage_fetch1(pTrackerServer, \
|
||||||
&storageServer, file_id)) != 0)
|
&storageServer, file_id)) != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
||||||
== NULL)
|
== NULL)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,8 +99,8 @@ int download_file(const char *file_id, int *file_size, char *storage_ip)
|
||||||
file_id, 0, 0, downloadFileCallback, NULL, &file_bytes);
|
file_id, 0, 0, downloadFileCallback, NULL, &file_bytes);
|
||||||
*file_size = file_bytes;
|
*file_size = file_bytes;
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
tracker_disconnect_server(pStorageServer);
|
tracker_close_connection(pStorageServer);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -121,22 +121,22 @@ int delete_file(const char *file_id, char *storage_ip)
|
||||||
if ((result=tracker_query_storage_update1(pTrackerServer, \
|
if ((result=tracker_query_storage_update1(pTrackerServer, \
|
||||||
&storageServer, file_id)) != 0)
|
&storageServer, file_id)) != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(pTrackerServer, true);
|
tracker_close_connection_ex(pTrackerServer, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
if ((pStorageServer=tracker_connect_server(&storageServer, &result)) \
|
||||||
== NULL)
|
== NULL)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(storage_ip, storageServer.ip_addr);
|
strcpy(storage_ip, storageServer.ip_addr);
|
||||||
result = storage_delete_file1(pTrackerServer, pStorageServer, file_id);
|
result = storage_delete_file1(pTrackerServer, pStorageServer, file_id);
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
tracker_disconnect_server(pStorageServer);
|
tracker_close_connection(pStorageServer);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ void dfs_destroy()
|
||||||
ConnectionInfo *pEnd;
|
ConnectionInfo *pEnd;
|
||||||
ConnectionInfo *pServer;
|
ConnectionInfo *pServer;
|
||||||
|
|
||||||
tracker_disconnect_server(pTrackerServer);
|
tracker_close_connection(pTrackerServer);
|
||||||
|
|
||||||
pEnd = storage_servers + storage_server_count;
|
pEnd = storage_servers + storage_server_count;
|
||||||
for (pServer=storage_servers; pServer<pEnd; pServer++)
|
for (pServer=storage_servers; pServer<pEnd; pServer++)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,35 @@ bool fdfs_server_contain_ex(TrackerServerInfo *pServer1,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fdfs_server_equal(TrackerServerInfo *pServer1,
|
||||||
|
TrackerServerInfo *pServer2)
|
||||||
|
{
|
||||||
|
ConnectionInfo *conn;
|
||||||
|
ConnectionInfo *end;
|
||||||
|
|
||||||
|
if (pServer1->count != pServer2->count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pServer1->count == 1)
|
||||||
|
{
|
||||||
|
return (pServer1->connections->port == pServer2->connections->port &&
|
||||||
|
strcmp(pServer1->connections->ip_addr, pServer2->connections->ip_addr) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
end = pServer1->connections + pServer1->count;
|
||||||
|
for (conn=pServer1->connections; conn<end; conn++)
|
||||||
|
{
|
||||||
|
if (!fdfs_server_contain1(pServer2, conn))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo)
|
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo)
|
||||||
{
|
{
|
||||||
ConnectionInfo *conn;
|
ConnectionInfo *conn;
|
||||||
|
|
@ -903,7 +932,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,9 @@ static inline bool fdfs_server_contain1(TrackerServerInfo *pServerInfo,
|
||||||
bool fdfs_server_contain_ex(TrackerServerInfo *pServer1,
|
bool fdfs_server_contain_ex(TrackerServerInfo *pServer1,
|
||||||
TrackerServerInfo *pServer2);
|
TrackerServerInfo *pServer2);
|
||||||
|
|
||||||
|
bool fdfs_server_equal(TrackerServerInfo *pServer1,
|
||||||
|
TrackerServerInfo *pServer2);
|
||||||
|
|
||||||
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo);
|
void fdfs_server_sock_reset(TrackerServerInfo *pServerInfo);
|
||||||
|
|
||||||
int fdfs_parse_server_info(char *server_str, const int default_port,
|
int fdfs_parse_server_info(char *server_str, const int default_port,
|
||||||
|
|
|
||||||
|
|
@ -3915,7 +3915,7 @@ static int tracker_mem_get_sys_files(TrackerServerInfo *pTrackerServer)
|
||||||
|
|
||||||
if ((result=tracker_get_sys_files_start(conn)) != 0)
|
if ((result=tracker_get_sys_files_start(conn)) != 0)
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, true);
|
tracker_close_connection_ex(conn, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3929,7 +3929,7 @@ static int tracker_mem_get_sys_files(TrackerServerInfo *pTrackerServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = tracker_get_sys_files_end(conn);
|
result = tracker_get_sys_files_end(conn);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -4905,7 +4905,7 @@ static int tracker_mem_get_trunk_binlog_size(
|
||||||
}
|
}
|
||||||
|
|
||||||
result = _storage_get_trunk_binlog_size(conn, file_size);
|
result = _storage_get_trunk_binlog_size(conn, file_size);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
|
|
||||||
logDebug("file: "__FILE__", line: %d, " \
|
logDebug("file: "__FILE__", line: %d, " \
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ int fdfs_deal_no_body_cmd_ex(const char *ip_addr, const int port, const int cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = fdfs_deal_no_body_cmd(conn, cmd);
|
result = fdfs_deal_no_body_cmd(conn, cmd);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +421,7 @@ char *fdfs_pack_metadata(const FDFSMetaData *meta_list, const int meta_count, \
|
||||||
return meta_buff;
|
return meta_buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tracker_disconnect_server_ex(ConnectionInfo *conn, \
|
void tracker_close_connection_ex(ConnectionInfo *conn, \
|
||||||
const bool bForceClose)
|
const bool bForceClose)
|
||||||
{
|
{
|
||||||
if (g_use_connection_pool)
|
if (g_use_connection_pool)
|
||||||
|
|
@ -537,6 +537,24 @@ ConnectionInfo *tracker_make_connection_ex(ConnectionInfo *conn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tracker_disconnect_server(TrackerServerInfo *pServerInfo)
|
||||||
|
{
|
||||||
|
ConnectionInfo *conn;
|
||||||
|
ConnectionInfo *end;
|
||||||
|
|
||||||
|
if (pServerInfo->count == 1)
|
||||||
|
{
|
||||||
|
conn_pool_disconnect_server(pServerInfo->connections);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = pServerInfo->connections + pServerInfo->count;
|
||||||
|
for (conn=pServerInfo->connections; conn<end; conn++)
|
||||||
|
{
|
||||||
|
conn_pool_disconnect_server(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \
|
static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \
|
||||||
char *buff, const int buff_size)
|
char *buff, const int buff_size)
|
||||||
{
|
{
|
||||||
|
|
@ -728,7 +746,7 @@ int fdfs_get_tracker_status(TrackerServerInfo *pTrackerServer,
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,8 +254,8 @@ static inline ConnectionInfo *tracker_connect_server_no_pool(
|
||||||
bind_addr, err_no, true);
|
bind_addr, err_no, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tracker_disconnect_server(pTrackerServer) \
|
#define tracker_close_connection(pTrackerServer) \
|
||||||
tracker_disconnect_server_ex(pTrackerServer, false)
|
tracker_close_connection_ex(pTrackerServer, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* close all connections to tracker servers
|
* close all connections to tracker servers
|
||||||
|
|
@ -264,10 +264,12 @@ static inline ConnectionInfo *tracker_connect_server_no_pool(
|
||||||
* bForceClose: if force close the connection when use connection pool
|
* bForceClose: if force close the connection when use connection pool
|
||||||
* return:
|
* return:
|
||||||
**/
|
**/
|
||||||
void tracker_disconnect_server_ex(ConnectionInfo *conn, \
|
void tracker_close_connection_ex(ConnectionInfo *conn, \
|
||||||
const bool bForceClose);
|
const bool bForceClose);
|
||||||
|
|
||||||
|
|
||||||
|
void tracker_disconnect_server(TrackerServerInfo *pServerInfo);
|
||||||
|
|
||||||
ConnectionInfo *tracker_make_connection_ex(ConnectionInfo *conn,
|
ConnectionInfo *tracker_make_connection_ex(ConnectionInfo *conn,
|
||||||
const int connect_timeout, int *err_no);
|
const int connect_timeout, int *err_no);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,11 +310,11 @@ static int do_notify_leader_changed(TrackerServerInfo *pTrackerServer, \
|
||||||
if (conn->port == g_server_port &&
|
if (conn->port == g_server_port &&
|
||||||
is_local_host_ip(conn->ip_addr))
|
is_local_host_ip(conn->ip_addr))
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, true);
|
tracker_close_connection_ex(conn, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -470,7 +470,7 @@ static int relationship_ping_leader()
|
||||||
}
|
}
|
||||||
|
|
||||||
result = fdfs_ping_leader(conn);
|
result = fdfs_ping_leader(conn);
|
||||||
tracker_disconnect_server_ex(conn, result != 0);
|
tracker_close_connection_ex(conn, result != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue