diff --git a/CMakeLists.txt b/CMakeLists.txt index 54abc074..3b42517b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,8 +50,8 @@ option(INCLUDE_OPENSSL_SERVER "link OpenSSlServer staticly to the core" TRUE) option(INCLUDE_OPENSSL_CLIENT "link OpenSSLClient staticly to the core" TRUE) option(INCLUDE_TROJAN_AUTH_SERVER "link TrojanAuthServer staticly to the core" TRUE) option(INCLUDE_TROJAN_SOCKS_SERVER "link TrojanSocksServer staticly to the core" TRUE) -option(INCLUDE_WOLFSSL_SERVER "link WolfSSLServer staticly to the core" FALSE) # temporarely disabled for compile speed -option(INCLUDE_WOLFSSL_CLIENT "link WolfSSLClient staticly to the core" FALSE) # temporarely disabled for compile speed +option(INCLUDE_WOLFSSL_SERVER "link WolfSSLServer staticly to the core" TRUE) # temporarely disabled for compile speed +option(INCLUDE_WOLFSSL_CLIENT "link WolfSSLClient staticly to the core" TRUE) # temporarely disabled for compile speed option(INCLUDE_BORINGSSL_SERVER "link BoringSSLServer staticly to the core" FALSE) #conflicts with openssl/noprefix ? option(INCLUDE_HTTP2_SERVER "link Http2Server staticly to the core" TRUE) option(INCLUDE_HTTP2_CLIENT "link Http2Client staticly to the core" TRUE) diff --git a/ww/generic_pool.c b/ww/generic_pool.c index a5f981ef..a1f20649 100644 --- a/ww/generic_pool.c +++ b/ww/generic_pool.c @@ -1,14 +1,46 @@ #include "generic_pool.h" #include "utils/mathutils.h" #include "ww.h" - +#ifdef POOL_DEBUG +#include "loggers/network_logger.h" +#endif #define GENERIC_POOL_DEFAULT_WIDTH ((unsigned long) ((ram_profile))) -extern void poolReCharge(generic_pool_t *pool); -extern void poolShrink(generic_pool_t *pool); extern pool_item_t *popPoolItem(generic_pool_t *pool); extern void reusePoolItem(generic_pool_t *pool, pool_item_t *b); +void poolReCharge(generic_pool_t *pool) +{ + const size_t increase = ((pool->cap - pool->len) < (pool->cap) / 2 ? (pool->cap - pool->len) : (pool->cap / 2)); + + for (size_t i = pool->len; i < (pool->len + increase); i++) + { + pool->available[i] = pool->create_item_handle(pool); + } + pool->len += increase; +#if defined(DEBUG) && defined(POOL_DEBUG) + hlogd("BufferPool: allocated %d new buffers, %zu are in use", increase, pool->in_use); +#endif +} + +void poolShrink(generic_pool_t *pool) +{ + const size_t decrease = (pool->len < (pool->cap / 2) ? pool->len : (pool->cap / 2)); + + for (size_t i = pool->len - decrease; i < pool->len; i++) + { + pool->destroy_item_handle(pool, pool->available[i]); + } + pool->len -= decrease; + +#if defined(DEBUG) && defined(POOL_DEBUG) + hlogd("BufferPool: freed %d buffers, %zu are in use", decrease, pool->in_use); +#endif +#ifdef OS_LINUX + // malloc_trim(0); +#endif +} + static void poolFirstCharge(generic_pool_t *pool) { pool->len = pool->cap / 2; diff --git a/ww/generic_pool.h b/ww/generic_pool.h index 4b8e5bae..3f1a2032 100644 --- a/ww/generic_pool.h +++ b/ww/generic_pool.h @@ -22,8 +22,9 @@ */ -#define POOL_DEBUG -#define BYPASS_POOL +// #define POOL_DEBUG +// #define BYPASS_POOL + struct generic_pool_s; @@ -59,37 +60,8 @@ struct generic_pool_s typedef struct generic_pool_s generic_pool_t; -inline void poolReCharge(generic_pool_t *pool) -{ - const size_t increase = ((pool->cap - pool->len) < (pool->cap) / 2 ? (pool->cap - pool->len) : (pool->cap / 2)); - - for (size_t i = pool->len; i < (pool->len + increase); i++) - { - pool->available[i] = pool->create_item_handle(pool); - } - pool->len += increase; -#if defined(DEBUG) && defined(POOL_DEBUG) - LOGD("BufferPool: allocated %d new buffers, %zu are in use", increase, pool->in_use); -#endif -} - -inline void poolShrink(generic_pool_t *pool) -{ - const size_t decrease = (pool->len < (pool->cap / 2) ? pool->len : (pool->cap / 2)); - - for (size_t i = pool->len - decrease; i < pool->len; i++) - { - pool->destroy_item_handle(pool, pool->available[i]); - } - pool->len -= decrease; - -#if defined(DEBUG) && defined(POOL_DEBUG) - LOGD("BufferPool: freed %d buffers, %zu are in use", decrease, pool->in_use); -#endif -#ifdef OS_LINUX - // malloc_trim(0); -#endif -} +void poolReCharge(generic_pool_t *pool); +void poolShrink(generic_pool_t *pool); inline pool_item_t *popPoolItem(generic_pool_t *pool) {