use socketCreateExAuto and socketClientExAuto
parent
14edb44071
commit
4af6511d3f
4
HISTORY
4
HISTORY
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
Version 5.13 2019-09-29
|
||||||
|
* use socketCreateExAuto and socketClientExAuto exported by libfastcommon,
|
||||||
|
you must upgrade libfastcommon to V1.41 or later
|
||||||
|
|
||||||
Version 5.12 2018-06-07
|
Version 5.12 2018-06-07
|
||||||
* code refine for rare case
|
* code refine for rare case
|
||||||
* replace print format OFF_PRINTF_FORMAT to PRId64
|
* replace print format OFF_PRINTF_FORMAT to PRId64
|
||||||
|
|
|
||||||
|
|
@ -141,40 +141,14 @@ int storage_get_my_tracker_client_ip()
|
||||||
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
{
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
result = errno != 0 ? errno : EPERM;
|
if (pTServer->sock >= 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(5);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,40 +232,14 @@ static int storage_report_storage_ip_addr()
|
||||||
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
{
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
result = errno != 0 ? errno : EPERM;
|
if (pTServer->sock >= 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,40 +299,14 @@ int storage_changelog_req()
|
||||||
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
{
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
result = errno != 0 ? errno : EPERM;
|
if (pTServer->sock >= 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1677,53 +1677,19 @@ int storage_report_storage_status(const char *storage_id, \
|
||||||
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
{
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
result = errno != 0 ? errno : EPERM;
|
if (pTServer->sock >= 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tcpsetserveropt(pTServer->sock, g_fdfs_network_timeout);
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(5);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTServer->sock < 0)
|
if (pTServer->sock < 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"connect to tracker server %s:%d fail, " \
|
|
||||||
"errno: %d, error info: %s", \
|
|
||||||
__LINE__, pTServer->ip_addr, pTServer->port, \
|
|
||||||
result, STRERROR(result));
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1753,7 +1719,6 @@ static int storage_reader_sync_init_req(StorageBinLogReader *pReader)
|
||||||
ConnectionInfo *pTServerEnd;
|
ConnectionInfo *pTServerEnd;
|
||||||
char tracker_client_ip[IP_ADDRESS_SIZE];
|
char tracker_client_ip[IP_ADDRESS_SIZE];
|
||||||
int result;
|
int result;
|
||||||
int conn_ret;
|
|
||||||
|
|
||||||
if (!g_sync_old_done)
|
if (!g_sync_old_done)
|
||||||
{
|
{
|
||||||
|
|
@ -1801,45 +1766,14 @@ static int storage_reader_sync_init_req(StorageBinLogReader *pReader)
|
||||||
{
|
{
|
||||||
while (g_continue_flag)
|
while (g_continue_flag)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
{
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
if (pTServer->sock >= 0)
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s. program exit!", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
g_continue_flag = false;
|
|
||||||
result = errno != 0 ? errno : EPERM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
sleep(g_heart_beat_interval);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((conn_ret=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"connect to tracker server %s:%d fail, " \
|
|
||||||
"errno: %d, error info: %s", \
|
|
||||||
__LINE__, pTServer->ip_addr, pTServer->port, \
|
|
||||||
conn_ret, STRERROR(conn_ret));
|
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
|
|
||||||
pTServer++;
|
pTServer++;
|
||||||
if (pTServer >= pTServerEnd)
|
if (pTServer >= pTServerEnd)
|
||||||
{
|
{
|
||||||
|
|
@ -2685,36 +2619,20 @@ static void* storage_sync_thread_entrance(void* arg)
|
||||||
pStorage->status != FDFS_STORAGE_STATUS_NONE)
|
pStorage->status != FDFS_STORAGE_STATUS_NONE)
|
||||||
{
|
{
|
||||||
strcpy(storage_server.ip_addr, pStorage->ip_addr);
|
strcpy(storage_server.ip_addr, pStorage->ip_addr);
|
||||||
storage_server.sock = \
|
|
||||||
socket(AF_INET, SOCK_STREAM, 0);
|
storage_server.sock = socketCreateExAuto(pStorage->ip_addr,
|
||||||
|
g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
if (storage_server.sock < 0)
|
if (storage_server.sock < 0)
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d," \
|
logCrit("file: "__FILE__", line: %d, "
|
||||||
" socket create fail, " \
|
"socket create fail, program exit!", __LINE__);
|
||||||
"errno: %d, error info: %s. " \
|
|
||||||
"program exit!", __LINE__, \
|
|
||||||
errno, STRERROR(errno));
|
|
||||||
g_continue_flag = false;
|
g_continue_flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
if ((conn_result=connectserverbyip_nb(storage_server.sock,
|
||||||
{
|
pStorage->ip_addr, g_server_port,
|
||||||
socketBind(storage_server.sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(storage_server.sock) != 0)
|
|
||||||
{
|
|
||||||
nContinuousFail++;
|
|
||||||
close(storage_server.sock);
|
|
||||||
storage_server.sock = -1;
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((conn_result=connectserverbyip_nb(storage_server.sock,\
|
|
||||||
pStorage->ip_addr, g_server_port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
g_fdfs_connect_timeout)) == 0)
|
||||||
{
|
{
|
||||||
char szFailPrompt[64];
|
char szFailPrompt[64];
|
||||||
|
|
|
||||||
|
|
@ -240,34 +240,22 @@ static void *tracker_report_thread_entrance(void *arg)
|
||||||
{
|
{
|
||||||
close(pTrackerServer->sock);
|
close(pTrackerServer->sock);
|
||||||
}
|
}
|
||||||
pTrackerServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
|
pTrackerServer->sock = socketCreateExAuto(pTrackerServer->ip_addr,
|
||||||
|
g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
if (pTrackerServer->sock < 0)
|
if (pTrackerServer->sock < 0)
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
logCrit("file: "__FILE__", line: %d, "
|
||||||
"socket create failed, errno: %d, " \
|
"socket create fail, program exit!", __LINE__);
|
||||||
"error info: %s. program exit!", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
g_continue_flag = false;
|
g_continue_flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
|
||||||
{
|
|
||||||
socketBind(pTrackerServer->sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tcpsetserveropt(pTrackerServer->sock, g_fdfs_network_timeout);
|
tcpsetserveropt(pTrackerServer->sock, g_fdfs_network_timeout);
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTrackerServer->sock) != 0)
|
if ((result=connectserverbyip_nb(pTrackerServer->sock,
|
||||||
{
|
pTrackerServer->ip_addr, pTrackerServer->port,
|
||||||
nContinuousFail++;
|
g_fdfs_connect_timeout)) != 0)
|
||||||
sleep(g_heart_beat_interval);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTrackerServer->sock, \
|
|
||||||
pTrackerServer->ip_addr, \
|
|
||||||
pTrackerServer->port, g_fdfs_connect_timeout)) != 0)
|
|
||||||
{
|
{
|
||||||
if (previousCode != result)
|
if (previousCode != result)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1444,36 +1444,19 @@ static void* trunk_sync_thread_entrance(void* arg)
|
||||||
pStorage->status != FDFS_STORAGE_STATUS_NONE)
|
pStorage->status != FDFS_STORAGE_STATUS_NONE)
|
||||||
{
|
{
|
||||||
strcpy(storage_server.ip_addr, pStorage->ip_addr);
|
strcpy(storage_server.ip_addr, pStorage->ip_addr);
|
||||||
storage_server.sock = \
|
storage_server.sock = socketCreateExAuto(pStorage->ip_addr,
|
||||||
socket(AF_INET, SOCK_STREAM, 0);
|
g_fdfs_connect_timeout, O_NONBLOCK,
|
||||||
|
g_client_bind_addr ? g_bind_addr : NULL, &result);
|
||||||
if (storage_server.sock < 0)
|
if (storage_server.sock < 0)
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d," \
|
logCrit("file: "__FILE__", line: %d, "
|
||||||
" socket create fail, " \
|
"socket create fail, program exit!", __LINE__);
|
||||||
"errno: %d, error info: %s. " \
|
|
||||||
"program exit!", __LINE__, \
|
|
||||||
errno, STRERROR(errno));
|
|
||||||
g_continue_flag = false;
|
g_continue_flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_client_bind_addr && *g_bind_addr != '\0')
|
if ((conn_result=connectserverbyip_nb(storage_server.sock,
|
||||||
{
|
pStorage->ip_addr, g_server_port,
|
||||||
socketBind(storage_server.sock, g_bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(storage_server.sock) != 0)
|
|
||||||
{
|
|
||||||
nContinuousFail++;
|
|
||||||
close(storage_server.sock);
|
|
||||||
storage_server.sock = -1;
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((conn_result=connectserverbyip_nb(storage_server.sock,\
|
|
||||||
pStorage->ip_addr, g_server_port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
g_fdfs_connect_timeout)) == 0)
|
||||||
{
|
{
|
||||||
char szFailPrompt[64];
|
char szFailPrompt[64];
|
||||||
|
|
|
||||||
|
|
@ -64,23 +64,13 @@ static void *http_check_entrance(void *arg)
|
||||||
{
|
{
|
||||||
if (g_http_check_type == FDFS_HTTP_CHECK_ALIVE_TYPE_TCP)
|
if (g_http_check_type == FDFS_HTTP_CHECK_ALIVE_TYPE_TCP)
|
||||||
{
|
{
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socketClientAuto((*ppServer)->ip_addr,
|
||||||
if(sock < 0)
|
(*ppGroup)->storage_http_port,
|
||||||
|
g_fdfs_connect_timeout, O_NONBLOCK, &result);
|
||||||
|
if (sock >= 0)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : EPERM;
|
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = connectserverbyip_nb_auto(sock, \
|
|
||||||
(*ppServer)->ip_addr, \
|
|
||||||
(*ppGroup)->storage_http_port, \
|
|
||||||
g_fdfs_connect_timeout);
|
|
||||||
close(sock);
|
close(sock);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_http_servers_dirty)
|
if (g_http_servers_dirty)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -539,6 +539,11 @@ int fdfs_get_ini_context_from_tracker(TrackerServerGroup *pTrackerGroup, \
|
||||||
pServerStart = pTrackerGroup->servers;
|
pServerStart = pTrackerGroup->servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!client_bind_addr)
|
||||||
|
{
|
||||||
|
bind_addr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
for (pGlobalServer=pServerStart; pGlobalServer<pServerEnd; \
|
for (pGlobalServer=pServerStart; pGlobalServer<pServerEnd; \
|
||||||
|
|
@ -547,52 +552,19 @@ int fdfs_get_ini_context_from_tracker(TrackerServerGroup *pTrackerGroup, \
|
||||||
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
memcpy(pTServer, pGlobalServer, sizeof(ConnectionInfo));
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pTServer->sock = socket(AF_INET, SOCK_STREAM, 0);
|
pTServer->sock = socketClientExAuto(pTServer->ip_addr,
|
||||||
if(pTServer->sock < 0)
|
pTServer->port, g_fdfs_connect_timeout,
|
||||||
{
|
O_NONBLOCK, bind_addr, &result);
|
||||||
result = errno != 0 ? errno : EPERM;
|
if (pTServer->sock >= 0)
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"socket create failed, errno: %d, " \
|
|
||||||
"error info: %s.", \
|
|
||||||
__LINE__, result, STRERROR(result));
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client_bind_addr && (bind_addr != NULL && \
|
|
||||||
*bind_addr != '\0'))
|
|
||||||
{
|
|
||||||
socketBind(pTServer->sock, bind_addr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tcpsetnonblockopt(pTServer->sock) != 0)
|
|
||||||
{
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((result=connectserverbyip_nb(pTServer->sock, \
|
|
||||||
pTServer->ip_addr, pTServer->port, \
|
|
||||||
g_fdfs_connect_timeout)) == 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pTServer->sock);
|
|
||||||
pTServer->sock = -1;
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTServer->sock < 0)
|
if (pTServer->sock < 0)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"connect to tracker server %s:%d fail, " \
|
|
||||||
"errno: %d, error info: %s", \
|
|
||||||
__LINE__, pTServer->ip_addr, pTServer->port, \
|
|
||||||
result, STRERROR(result));
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -606,6 +578,9 @@ int fdfs_get_ini_context_from_tracker(TrackerServerGroup *pTrackerGroup, \
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"get parameters from tracker server %s:%d fail",
|
||||||
|
__LINE__, pTServer->ip_addr, pTServer->port);
|
||||||
fdfs_quit(pTServer);
|
fdfs_quit(pTServer);
|
||||||
close(pTServer->sock);
|
close(pTServer->sock);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue