From d1cecfb5899419d9f1d2c9faed01d19814e6130c Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 10 Feb 2017 13:26:48 +0900 Subject: [PATCH] pkbuf leak is fixed --- configure.ac | 7 ------- lib/core/include/core.h.in | 4 +--- lib/core/src/unix/pkbuf.c | 38 +++++++++++++++++++------------------- test/s1ap_test.c | 2 ++ 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 8571982c2..3fd441b5c 100644 --- a/configure.ac +++ b/configure.ac @@ -71,12 +71,6 @@ dnl Checks for compile flag dnl Checks for pointer size AC_CHECK_SIZEOF(void*, 4) -if test "x$ac_cv_sizeof_voidp" != "x"; then - voidp_size=$ac_cv_sizeof_voidp -else - AC_ERROR([Cannot determine size of void*]) -fi - dnl Checks for integer size AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(int, 4) @@ -138,7 +132,6 @@ else AC_ERROR([could not detect a 64-bit integer type]) fi -AC_SUBST(voidp_size) AC_SUBST(short_value) AC_SUBST(int_value) AC_SUBST(long_value) diff --git a/lib/core/include/core.h.in b/lib/core/include/core.h.in index e458c164a..ec9a26e3c 100644 --- a/lib/core/include/core.h.in +++ b/lib/core/include/core.h.in @@ -173,12 +173,10 @@ typedef unsigned @short_value@ c_uint16_t; typedef @int_value@ c_int32_t; typedef unsigned @int_value@ c_uint32_t; -#define C_SIZEOF_VOIDP @voidp_size@ - typedef @long_value@ c_int64_t; typedef unsigned @long_value@ c_uint64_t; -#if C_SIZEOF_VOIDP == 8 +#if SIZEOF_VOIDP == 8 typedef c_uint64_t c_uintptr_t; typedef c_int64_t c_intptr_t; #else diff --git a/lib/core/src/unix/pkbuf.c b/lib/core/src/unix/pkbuf.c index 28be862bd..f56c50ac0 100644 --- a/lib/core/src/unix/pkbuf.c +++ b/lib/core/src/unix/pkbuf.c @@ -13,7 +13,7 @@ pool_declare(clbuf_pool, clbuf_t, MAX_NUM_OF_CLBUF); pool_declare(pkbuf_pool, pkbuf_t, MAX_NUM_OF_PKBUF); #undef BOUNDARY -#define BOUNDARY 4 +#define BOUNDARY SIZEOF_VOIDP #define SIZEOF_CLUSTER_128 CORE_ALIGN(128+MAX_SIZEOF_HEADROOM, BOUNDARY) #define SIZEOF_CLUSTER_256 CORE_ALIGN(256+MAX_SIZEOF_HEADROOM, BOUNDARY) @@ -63,6 +63,8 @@ status_t pkbuf_init(void) } status_t pkbuf_final(void) { + pkbuf_show(); + pool_final(&clbuf_pool); pool_final(&pkbuf_pool); @@ -80,24 +82,22 @@ status_t pkbuf_final(void) void pkbuf_show(void) { - d_print("Pkbuf : Size = %d, Avail = %d\n",pool_size(&pkbuf_pool), - pool_avail(&pkbuf_pool)); - d_print("clfbuf : Size = %d, Avail = %d\n\n",pool_size(&clbuf_pool), - pool_avail(&clbuf_pool)); - - d_print("cluster128 : Size = %d, Avail = %d\n",pool_size(&cluster_128_pool), - pool_avail(&cluster_128_pool)); - d_print("cluster256 : Size = %d, Avail = %d\n",pool_size(&cluster_256_pool), - pool_avail(&cluster_256_pool)); - d_print("cluster512 : Size = %d, Avail = %d\n",pool_size(&cluster_512_pool), - pool_avail(&cluster_512_pool)); - d_print("cluster1024 : Size = %d, Avail = %d\n", - pool_size(&cluster_1024_pool), - pool_avail(&cluster_128_pool)); - d_print("cluster2048 : Size = %d, Avail = %d\n", - pool_size(&cluster_2048_pool), - pool_avail(&cluster_2048_pool)); - + d_print("%d not freed in pkbuf_t pool\n", + pool_size(&pkbuf_pool) - pool_avail(&pkbuf_pool)); + d_print("%d not freed in clbuf_t pool\n", + pool_size(&clbuf_pool) - pool_avail(&clbuf_pool)); + d_print("%d not freed in cluster128_t pool\n", + pool_size(&cluster_128_pool) - pool_avail(&cluster_128_pool)); + d_print("%d not freed in cluster256_t pool\n", + pool_size(&cluster_256_pool) - pool_avail(&cluster_256_pool)); + d_print("%d not freed in cluster512_t pool\n", + pool_size(&cluster_512_pool) - pool_avail(&cluster_512_pool)); + d_print("%d not freed in cluster1024_t pool\n", + pool_size(&cluster_1024_pool) - pool_avail(&cluster_128_pool)); + d_print("%d not freed in cluster2048_t pool\n", + pool_size(&cluster_2048_pool) - pool_avail(&cluster_2048_pool)); + d_print("%d not freed in cluster8192_t pool\n", + pool_size(&cluster_8192_pool) - pool_avail(&cluster_8192_pool)); } static clbuf_t* clbuf_alloc(c_uint16_t length); diff --git a/test/s1ap_test.c b/test/s1ap_test.c index 7b9a4eef0..5b83bd01c 100644 --- a/test/s1ap_test.c +++ b/test/s1ap_test.c @@ -137,6 +137,8 @@ static void s1ap_test5(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, 280, erval); s1ap_free_pdu(&message); + + pkbuf_free(pkbuf); } abts_suite *test_s1ap(abts_suite *suite)