From 325946a3be2bfd8d2dc05e106016a2ee686636b9 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sat, 12 Oct 2019 10:59:08 +0800 Subject: [PATCH] add function conn_pool_set_server_info --- src/connection_pool.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/connection_pool.h b/src/connection_pool.h index 7169ff3..0d29f65 100644 --- a/src/connection_pool.h +++ b/src/connection_pool.h @@ -33,7 +33,7 @@ typedef struct int sock; int port; char ip_addr[INET6_ADDRSTRLEN]; - int socket_domain; //socket domain, AF_INET, AF_INET6 or PF_UNSPEC for auto dedect + int socket_domain; //socket domain, AF_INET, AF_INET6 or AF_UNSPEC for auto dedect } ConnectionInfo; struct tagConnectionManager; @@ -212,6 +212,24 @@ int conn_pool_load_server_info(IniContext *pIniContext, const char *filename, int conn_pool_parse_server_info(const char *pServerStr, ConnectionInfo *pServerInfo, const int default_port); +/** +* set server info with ip address and port +* parameters: +* pServerInfo: store server info +* ip_addr: the ip address +* port: the port +* return none +*/ +static inline void conn_pool_set_server_info(ConnectionInfo *pServerInfo, + const char *ip_addr, const int port) +{ + snprintf(pServerInfo->ip_addr, sizeof(pServerInfo->ip_addr), + "%s", ip_addr); + pServerInfo->port = port; + pServerInfo->socket_domain = AF_UNSPEC; + pServerInfo->sock = -1; +} + #ifdef __cplusplus } #endif