From 130d7fe1102d5e86c0403cf7c8d4afc14257fe3b Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 8 Sep 2020 09:06:26 +0800 Subject: [PATCH] add func conn_pool_compare_ip_and_port --- HISTORY | 2 +- src/connection_pool.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index f208f0f..890799f 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -Version 1.44 2020-09-06 +Version 1.44 2020-09-08 * add test file src/tests/test_pthread_lock.c * add uniq_skiplist.[hc] * add function split_string_ex diff --git a/src/connection_pool.h b/src/connection_pool.h index 251dfce..f62810e 100644 --- a/src/connection_pool.h +++ b/src/connection_pool.h @@ -305,6 +305,16 @@ static inline void conn_pool_set_server_info(ConnectionInfo *pServerInfo, pServerInfo->sock = -1; } +static inline int conn_pool_compare_ip_and_port(const char *ip1, + const short port1, const char *ip2, const short port2) +{ + int result; + if ((result=strcmp(ip1, ip2)) != 0) { + return result; + } + return port1 - port2; +} + #ifdef __cplusplus } #endif