parent
7816a28c53
commit
02f4659a32
|
|
@ -221,11 +221,12 @@ int conn_pool_connect_server_ex1(ConnectionInfo *conn,
|
|||
{
|
||||
if (log_connect_error)
|
||||
{
|
||||
FC_FORMAT_IP_ADDRESS(conn->ip_addr, new_ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to %s%sserver %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, service_name != NULL ?
|
||||
service_name : "", service_name != NULL ? " " : "",
|
||||
conn->ip_addr, conn->port, result, STRERROR(result));
|
||||
new_ip_addr, conn->port, result, STRERROR(result));
|
||||
}
|
||||
|
||||
close(conn->sock);
|
||||
|
|
@ -255,9 +256,10 @@ int conn_pool_async_connect_server_ex(ConnectionInfo *conn,
|
|||
result = asyncconnectserverbyip(conn->sock, conn->ip_addr, conn->port);
|
||||
if (!(result == 0 || result == EINPROGRESS))
|
||||
{
|
||||
FC_FORMAT_IP_ADDRESS(conn->ip_addr, new_ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to server %s:%u fail, errno: %d, "
|
||||
"error info: %s", __LINE__, conn->ip_addr,
|
||||
"error info: %s", __LINE__, new_ip_addr,
|
||||
conn->port, result, STRERROR(result));
|
||||
close(conn->sock);
|
||||
conn->sock = -1;
|
||||
|
|
@ -319,12 +321,13 @@ static ConnectionInfo *get_connection(ConnectionPool *cp,
|
|||
if ((cp->max_count_per_entry > 0) &&
|
||||
(cm->total_count >= cp->max_count_per_entry))
|
||||
{
|
||||
FC_FORMAT_IP_ADDRESS(conn->ip_addr, new_ip_addr);
|
||||
*err_no = ENOSPC;
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connections: %d of %s%sserver %s:%u exceed limit: %d",
|
||||
__LINE__, cm->total_count, service_name != NULL ?
|
||||
service_name : "", service_name != NULL ? " " : "",
|
||||
conn->ip_addr, conn->port, cp->max_count_per_entry);
|
||||
new_ip_addr, conn->port, cp->max_count_per_entry);
|
||||
pthread_mutex_unlock(&cm->lock);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -529,18 +532,20 @@ static int close_connection(ConnectionPool *cp, ConnectionInfo *conn,
|
|||
pthread_mutex_unlock(&cp->lock);
|
||||
if (cm == NULL)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"hash entry of server %s:%u not exist", __LINE__, \
|
||||
conn->ip_addr, conn->port);
|
||||
FC_FORMAT_IP_ADDRESS(conn->ip_addr, new_ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"hash entry of server %s:%u not exist",
|
||||
__LINE__, new_ip_addr, conn->port);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
node = (ConnectionNode *)((char *)conn - sizeof(ConnectionNode));
|
||||
if (node->manager != cm)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"manager of server entry %s:%u is invalid!", \
|
||||
__LINE__, conn->ip_addr, conn->port);
|
||||
FC_FORMAT_IP_ADDRESS(conn->ip_addr, new_ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"manager of server entry %s:%u is invalid!",
|
||||
__LINE__, new_ip_addr, conn->port);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -812,7 +812,7 @@ int setsockaddrbyip(const char *ip, const uint16_t port,
|
|||
if (is_ipv6_addr(ip))
|
||||
{
|
||||
convert->len = sizeof(convert->sa.addr6);
|
||||
if (strchr(ip, '#') != NULL)
|
||||
if (strchr(ip, '%') != NULL)
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
|
||||
|
|
@ -873,8 +873,8 @@ int connectserverbyip(int sock, const char *server_ip, const uint16_t server_por
|
|||
return 0;
|
||||
}
|
||||
|
||||
int connectserverbyip_nb_ex(int sock, const char *server_ip, \
|
||||
const uint16_t server_port, const int timeout, \
|
||||
int connectserverbyip_nb_ex(int sock, const char *server_ip,
|
||||
const uint16_t server_port, const int timeout,
|
||||
const bool auto_detect)
|
||||
{
|
||||
int result;
|
||||
|
|
@ -1069,10 +1069,11 @@ int socketClientEx2(int af, const char *server_ip,
|
|||
server_port, timeout, auto_detect);
|
||||
if (*err_no != 0)
|
||||
{
|
||||
FC_FORMAT_IP_ADDRESS(server_ip, new_ip_addr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"connect to %s:%u fail, "
|
||||
"errno: %d, error info: %s",
|
||||
__LINE__, server_ip, server_port,
|
||||
__LINE__, new_ip_addr, server_port,
|
||||
*err_no, STRERROR(*err_no));
|
||||
close(sock);
|
||||
return -4;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,16 @@
|
|||
|
||||
#define FAST_WRITE_BUFF_SIZE (256 * 1024)
|
||||
|
||||
#define FC_FORMAT_IP_ADDRESS(old_ip_addr, new_ip_addr) \
|
||||
char new_ip_addr[IP_ADDRESS_SIZE + 2]; \
|
||||
do { \
|
||||
if (is_ipv6_addr(old_ip_addr)) { \
|
||||
sprintf(new_ip_addr, "[%s]", old_ip_addr); \
|
||||
} else { \
|
||||
strcpy(new_ip_addr, old_ip_addr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct fast_if_config {
|
||||
char name[IF_NAMESIZE]; //if name
|
||||
char mac[64];
|
||||
|
|
|
|||
Loading…
Reference in New Issue