diff --git a/src/connection_pool.c b/src/connection_pool.c index 9e6498d..9490dd5 100644 --- a/src/connection_pool.c +++ b/src/connection_pool.c @@ -52,7 +52,11 @@ static int node_init_for_rdma(ConnectionNode *node, static inline void conn_pool_get_key(const ConnectionInfo *conn, char *key, int *key_len) { - *key_len = sprintf(key, "%s-%u", conn->ip_addr, conn->port); + *key_len = strlen(conn->ip_addr); + memcpy(key, conn->ip_addr, *key_len); + *(key + (*key_len)++) = '-'; + *(key + (*key_len)++) = (conn->port >> 8) & 0xFF; + *(key + (*key_len)++) = conn->port & 0xFF; } static int close_conn(ConnectionPool *cp, ConnectionManager *cm, diff --git a/src/tests/Makefile b/src/tests/Makefile index 3a7bd09..7aa22a8 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -11,7 +11,7 @@ ALL_PRGS = test_allocator test_skiplist test_multi_skiplist test_mblock test_blo test_server_id_func test_pipe test_atomic test_file_write_hole test_file_lock \ test_pthread_wait test_thread_pool test_data_visible test_mutex_lock_perf \ test_queue_perf test_normalize_path test_sorted_array test_sorted_queue \ - test_thread_local test_memcpy mblock_benchmark + test_thread_local test_memcpy mblock_benchmark cpool_benchmark all: $(ALL_PRGS) diff --git a/src/tests/cpool_benchmark.c b/src/tests/cpool_benchmark.c index 2a5b6fd..b2c49d7 100644 --- a/src/tests/cpool_benchmark.c +++ b/src/tests/cpool_benchmark.c @@ -28,7 +28,7 @@ #include "fastcommon/connection_pool.h" static int thread_count = 2; -static int64_t loop_count = 1000000; +static int64_t loop_count = 10000000; static ConnectionPool cpool; static void *thread_run(void *args)