Some bugfixes and clean up for UADK.
Yang Shen (7): uadk/zlibwrapper - some misc clean up uadk/zlibwrapper - fix the return value for deflate/inflate uadk/zlibwrapper - add parameters check for APIs uadk/zlibwrapper - remove duplication for deflate and inflate uadk/zlibwrapper - fix wrong windowsize uadk/zlibwrapper - rename zlibwrapper APIs uadk/wd - fix error shmid for multiprocess
wd_zlibwrapper.h => include/wd_zlibwrapper.h | 30 +-- wd_util.c | 84 +++---- wd_zlibwrapper.c | 217 +++++++++---------- 3 files changed, 133 insertions(+), 198 deletions(-) rename wd_zlibwrapper.h => include/wd_zlibwrapper.h (68%)
-- 2.24.0
Some misc clean up.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_zlibwrapper.h => include/wd_zlibwrapper.h | 0 wd_zlibwrapper.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) rename wd_zlibwrapper.h => include/wd_zlibwrapper.h (100%)
diff --git a/wd_zlibwrapper.h b/include/wd_zlibwrapper.h similarity index 100% rename from wd_zlibwrapper.h rename to include/wd_zlibwrapper.h diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 6a0dfba..5dd1c2a 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -6,18 +6,16 @@ /* === Dependencies === */ #define _GNU_SOURCE
-#include <errno.h> -#include <math.h> -#include <numa.h> #include <stdlib.h> #include <stdio.h> +#include <numa.h>
#include "wd.h" #include "wd_comp.h" #include "wd_sched.h" #include "wd_util.h" -#include "wd_zlibwrapper.h" #include "drv/wd_comp_drv.h" +#include "wd_zlibwrapper.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -52,7 +50,7 @@ static int wd_zlib_init(void) ctx_set_num = calloc(WD_DIR_MAX, sizeof(*ctx_set_num)); if (!ctx_set_num) { WD_ERR("failed to alloc ctx_set_size!\n"); - return -WD_ENOMEM; + return Z_MEM_ERROR; }
cparams.op_type_num = WD_DIR_MAX; @@ -60,18 +58,20 @@ static int wd_zlib_init(void) cparams.bmp = numa_allocate_nodemask(); if (!cparams.bmp) { WD_ERR("failed to create nodemask!\n"); - ret = -WD_ENOMEM; + ret = Z_MEM_ERROR; goto out_freectx; }
numa_bitmask_setall(cparams.bmp);
for (i = 0; i < WD_DIR_MAX; i++) - ctx_set_num[i].sync_ctx_num = 2; + ctx_set_num[i].sync_ctx_num = WD_DIR_MAX;
ret = wd_comp_init2_("zlib", 0, 0, &cparams); - if (ret) + if (ret) { + ret = Z_STREAM_ERROR; goto out_freebmp; + }
zlib_config.status = WD_ZLIB_INIT;
The next_in/next_out in zstream should add the changed number for every request. And the return value should be Z_STREAM_END for stream end.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_zlibwrapper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 5dd1c2a..8d2308f 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -186,8 +186,12 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty strm->avail_out = dst_len - req.dst_len; strm->total_in += req.src_len; strm->total_out += req.dst_len; + strm->next_in += req.src_len; + strm->next_out += req.dst_len;
- if (flush == Z_FINISH && req.src_len == src_len) + if (type == WD_DIR_COMPRESS && flush == Z_FINISH && req.src_len == src_len) + ret = Z_STREAM_END; + else if (type == WD_DIR_DECOMPRESS && req.status == WD_STREAM_END) ret = Z_STREAM_END;
return ret;
Add parameters check for APIs.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_zlibwrapper.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 8d2308f..ed919dc 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -163,6 +163,9 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty int dst_len = strm->avail_out; int ret;
+ if (unlikely(!strm)) + return Z_STREAM_ERROR; + if (unlikely(flush != Z_SYNC_FLUSH && flush != Z_FINISH)) { WD_ERR("invalid: flush is %d!\n", flush); return Z_STREAM_ERROR; @@ -210,6 +213,9 @@ int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, { int ret;
+ if (!strm) + return Z_STREAM_ERROR; + pthread_atfork(NULL, NULL, wd_zlib_unlock);
pthread_mutex_lock(&wd_zlib_mutex); @@ -227,7 +233,7 @@ int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, __atomic_add_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); pthread_mutex_unlock(&wd_zlib_mutex);
- return 0; + return Z_OK;
out_uninit: wd_zlib_uninit(); @@ -245,6 +251,9 @@ int wd_deflate(z_streamp strm, int flush)
int wd_deflateReset(z_streamp strm) { + if (!strm) + return Z_STREAM_ERROR; + wd_comp_reset_sess((handle_t)strm->reserved);
strm->total_in = 0; @@ -257,6 +266,9 @@ int wd_deflateEnd(z_streamp strm) { int ret;
+ if (!strm) + return Z_STREAM_ERROR; + wd_zlib_free_sess(strm);
pthread_mutex_lock(&wd_zlib_mutex); @@ -283,6 +295,9 @@ int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int s { int ret;
+ if (!strm) + return Z_STREAM_ERROR; + pthread_atfork(NULL, NULL, wd_zlib_unlock);
pthread_mutex_lock(&wd_zlib_mutex); @@ -300,7 +315,7 @@ int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int s __atomic_add_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); pthread_mutex_unlock(&wd_zlib_mutex);
- return 0; + return Z_OK;
out_uninit: wd_zlib_uninit(); @@ -318,6 +333,9 @@ int wd_inflate(z_streamp strm, int flush)
int wd_inflateReset(z_streamp strm) { + if (!strm) + return Z_STREAM_ERROR; + wd_comp_reset_sess((handle_t)strm->reserved);
strm->total_in = 0; @@ -330,6 +348,9 @@ int wd_inflateEnd(z_streamp strm) { int ret;
+ if (!strm) + return Z_STREAM_ERROR; + wd_zlib_free_sess(strm);
pthread_mutex_lock(&wd_zlib_mutex);
The two groups of functions have the same codes. One is wd_deflateInit and wd_inflateInit. Another is wd_deflateEnd and wd_inflateEnd. So remove the code duplication.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_zlibwrapper.c | 160 ++++++++++++++++++----------------------------- 1 file changed, 62 insertions(+), 98 deletions(-)
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index ed919dc..58dbd9b 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -38,7 +38,7 @@ static void wd_zlib_unlock(void) zlib_config.status = WD_ZLIB_UNINIT; }
-static int wd_zlib_init(void) +static int wd_zlib_uadk_init(void) { struct wd_ctx_nums *ctx_set_num; struct wd_ctx_params cparams; @@ -84,7 +84,7 @@ out_freectx: return ret; }
-static void wd_zlib_uninit(void) +static void wd_zlib_uadk_uninit(void) { wd_comp_uninit2(); zlib_config.status = WD_ZLIB_UNINIT; @@ -155,6 +155,62 @@ static void wd_zlib_free_sess(z_streamp strm) wd_comp_free_sess((handle_t)strm->reserved); }
+static int wd_zlib_init(z_streamp strm, int level, int windowbits, enum wd_comp_op_type type) +{ + int ret; + + if (unlikely(!strm)) + return Z_STREAM_ERROR; + + pthread_mutex_lock(&wd_zlib_mutex); + ret = wd_zlib_uadk_init(); + if (unlikely(ret < 0)) + goto out_unlock; + + strm->total_in = 0; + strm->total_out = 0; + + ret = wd_zlib_alloc_sess(strm, level, windowbits, type); + if (unlikely(ret < 0)) + goto out_uninit; + + __atomic_add_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); + pthread_mutex_unlock(&wd_zlib_mutex); + + return Z_OK; + +out_uninit: + wd_zlib_uadk_uninit(); + +out_unlock: + pthread_mutex_unlock(&wd_zlib_mutex); + + return ret; +} + +static int wd_zlib_uninit(z_streamp strm) +{ + int ret; + + if (unlikely(!strm)) + return Z_STREAM_ERROR; + + wd_zlib_free_sess(strm); + + pthread_mutex_lock(&wd_zlib_mutex); + + ret = __atomic_sub_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); + if (ret != 0) + goto out_unlock; + + wd_zlib_uadk_uninit(); + +out_unlock: + pthread_mutex_unlock(&wd_zlib_mutex); + + return Z_OK; +} + static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type type) { handle_t h_sess = strm->reserved; @@ -211,37 +267,9 @@ int wd_deflateInit_(z_streamp strm, int level, const char *version, int stream_s int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size) { - int ret; - - if (!strm) - return Z_STREAM_ERROR; - pthread_atfork(NULL, NULL, wd_zlib_unlock);
- pthread_mutex_lock(&wd_zlib_mutex); - ret = wd_zlib_init(); - if (unlikely(ret < 0)) - goto out_unlock; - - strm->total_in = 0; - strm->total_out = 0; - - ret = wd_zlib_alloc_sess(strm, level, windowBits, WD_DIR_COMPRESS); - if (unlikely(ret < 0)) - goto out_uninit; - - __atomic_add_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); - pthread_mutex_unlock(&wd_zlib_mutex); - - return Z_OK; - -out_uninit: - wd_zlib_uninit(); - -out_unlock: - pthread_mutex_unlock(&wd_zlib_mutex); - - return ret; + return wd_zlib_init(strm, level, windowBits, WD_DIR_COMPRESS); }
int wd_deflate(z_streamp strm, int flush) @@ -264,25 +292,7 @@ int wd_deflateReset(z_streamp strm)
int wd_deflateEnd(z_streamp strm) { - int ret; - - if (!strm) - return Z_STREAM_ERROR; - - wd_zlib_free_sess(strm); - - pthread_mutex_lock(&wd_zlib_mutex); - - ret = __atomic_sub_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); - if (ret != 0) - goto out_unlock; - - wd_zlib_uninit(); - -out_unlock: - pthread_mutex_unlock(&wd_zlib_mutex); - - return Z_OK; + return wd_zlib_uninit(strm); }
/* === Decompression === */ @@ -293,37 +303,9 @@ int wd_inflateInit_(z_streamp strm, const char *version, int stream_size)
int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) { - int ret; - - if (!strm) - return Z_STREAM_ERROR; - pthread_atfork(NULL, NULL, wd_zlib_unlock);
- pthread_mutex_lock(&wd_zlib_mutex); - ret = wd_zlib_init(); - if (unlikely(ret < 0)) - goto out_unlock; - - strm->total_in = 0; - strm->total_out = 0; - - ret = wd_zlib_alloc_sess(strm, 0, windowBits, WD_DIR_DECOMPRESS); - if (unlikely(ret < 0)) - goto out_uninit; - - __atomic_add_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); - pthread_mutex_unlock(&wd_zlib_mutex); - - return Z_OK; - -out_uninit: - wd_zlib_uninit(); - -out_unlock: - pthread_mutex_unlock(&wd_zlib_mutex); - - return ret; + return wd_zlib_init(strm, 0, windowBits, WD_DIR_DECOMPRESS); }
int wd_inflate(z_streamp strm, int flush) @@ -346,23 +328,5 @@ int wd_inflateReset(z_streamp strm)
int wd_inflateEnd(z_streamp strm) { - int ret; - - if (!strm) - return Z_STREAM_ERROR; - - wd_zlib_free_sess(strm); - - pthread_mutex_lock(&wd_zlib_mutex); - - ret = __atomic_sub_fetch(&zlib_config.count, 1, __ATOMIC_RELAXED); - if (ret != 0) - goto out_unlock; - - wd_zlib_uninit(); - -out_unlock: - pthread_mutex_unlock(&wd_zlib_mutex); - - return Z_OK; + return wd_zlib_uninit(strm); }
Since the UADK has a WD_COMP_WS_24K which is not support in zlib. Need to skip this value to get the right windowsize.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_zlibwrapper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 58dbd9b..46a5c75 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -101,23 +101,23 @@ static int wd_zlib_analy_alg(int windowbits, int *alg, int *windowsize) static const int WBINS_ZLIB_4K = 12; static const int WBINS_GZIP_4K = 27; static const int WBINS_DEFLATE_4K = -12; - int ret = Z_STREAM_ERROR;
if ((windowbits >= ZLIB_MIN_WBITS) && (windowbits <= ZLIB_MAX_WBITS)) { *alg = WD_ZLIB; *windowsize = max(windowbits - WBINS_ZLIB_4K, WD_COMP_WS_4K); - ret = Z_OK; } else if ((windowbits >= GZIP_MIN_WBITS) && (windowbits <= GZIP_MAX_WBITS)) { *alg = WD_GZIP; *windowsize = max(windowbits - WBINS_GZIP_4K, WD_COMP_WS_4K); - ret = Z_OK; } else if ((windowbits >= DEFLATE_MIN_WBITS) && (windowbits <= DEFLATE_MAX_WBITS)) { *alg = WD_DEFLATE; *windowsize = max(windowbits - WBINS_DEFLATE_4K, WD_COMP_WS_4K); - ret = Z_OK; + } else { + return Z_STREAM_ERROR; }
- return ret; + *windowsize = *windowsize == WD_COMP_WS_24K ? WD_COMP_WS_32K : *windowsize; + + return Z_OK; }
static int wd_zlib_alloc_sess(z_streamp strm, int level, int windowbits, enum wd_comp_op_type type)
Rename zlibwrappre APIs to fellow UADK rules. And remove the useles input parameters.
Signed-off-by: Yang Shen shenyang39@huawei.com --- include/wd_zlibwrapper.h | 30 ++++++------------------------ wd_zlibwrapper.c | 32 +++++++++++--------------------- 2 files changed, 17 insertions(+), 45 deletions(-)
diff --git a/include/wd_zlibwrapper.h b/include/wd_zlibwrapper.h index a409f36..847a315 100644 --- a/include/wd_zlibwrapper.h +++ b/include/wd_zlibwrapper.h @@ -16,8 +16,6 @@ extern "C" { #endif
-#define ZLIB_VERSION "1.2.11" - /* Allowed flush values; the same as zlib library */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 @@ -89,33 +87,17 @@ typedef struct z_stream_s {
typedef z_stream * z_streamp;
-int wd_deflateInit_(z_streamp strm, int level, const char *version, int stream_size); -int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, - int memLevel, int strategy, const char *version, int stream_size); +int wd_deflate_init(z_streamp strm, int level, int windowbits); /* * The flush support Z_SYNC_FLUSH and Z_FINISH only. */ int wd_deflate(z_streamp strm, int flush); -int wd_deflateReset(z_streamp strm); -int wd_deflateEnd(z_streamp strm); +int wd_deflate_reset(z_streamp strm); +int wd_deflate_end(z_streamp strm);
-int wd_inflateInit_(z_streamp strm, const char *version, int stream_size); -int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size); +int wd_inflate_init(z_streamp strm, int windowbits); int wd_inflate(z_streamp strm, int flush); -int wd_inflateReset(z_streamp strm); -int wd_inflateEnd(z_streamp strm); - -#define wd_deflateInit(strm, level) \ - wd_deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - wd_deflateInit2_((strm), (level), (method), (windowBits), (memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_inflateInit(strm) \ - wd_inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) - -#define wd_inflateInit2(strm, windowBits) \ - wd_inflateInit2_((strm), (windowBits), ZLIB_VERSION, (int)sizeof(z_stream)) +int wd_inflate_reset(z_streamp strm); +int wd_inflate_end(z_streamp strm);
#endif /* UADK_ZLIBWRAPPER_H */ diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c index 46a5c75..86e92f7 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -257,19 +257,11 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty }
/* === Compression === */ -int wd_deflateInit_(z_streamp strm, int level, const char *version, int stream_size) - -{ - return wd_deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); -} - -int wd_deflateInit2_(z_streamp strm, int level, int method, int windowBits, - int memLevel, int strategy, const char *version, int stream_size) +int wd_deflate_init(z_streamp strm, int level, int windowbits) { pthread_atfork(NULL, NULL, wd_zlib_unlock);
- return wd_zlib_init(strm, level, windowBits, WD_DIR_COMPRESS); + return wd_zlib_init(strm, level, windowbits, WD_DIR_COMPRESS); }
int wd_deflate(z_streamp strm, int flush) @@ -277,7 +269,7 @@ int wd_deflate(z_streamp strm, int flush) return wd_zlib_do_request(strm, flush, WD_DIR_COMPRESS); }
-int wd_deflateReset(z_streamp strm) +int wd_deflate_reset(z_streamp strm) { if (!strm) return Z_STREAM_ERROR; @@ -290,30 +282,28 @@ int wd_deflateReset(z_streamp strm) return Z_OK; }
-int wd_deflateEnd(z_streamp strm) +int wd_deflate_end(z_streamp strm) { return wd_zlib_uninit(strm); }
/* === Decompression === */ -int wd_inflateInit_(z_streamp strm, const char *version, int stream_size) -{ - return wd_inflateInit2_(strm, MAX_WBITS, version, stream_size); -} - -int wd_inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) +int wd_inflate_init(z_streamp strm, int windowbits) { pthread_atfork(NULL, NULL, wd_zlib_unlock);
- return wd_zlib_init(strm, 0, windowBits, WD_DIR_DECOMPRESS); + return wd_zlib_init(strm, 0, windowbits, WD_DIR_DECOMPRESS); }
int wd_inflate(z_streamp strm, int flush) { + if (unlikely(!strm)) + return Z_STREAM_ERROR; + return wd_zlib_do_request(strm, flush, WD_DIR_DECOMPRESS); }
-int wd_inflateReset(z_streamp strm) +int wd_inflate_reset(z_streamp strm) { if (!strm) return Z_STREAM_ERROR; @@ -326,7 +316,7 @@ int wd_inflateReset(z_streamp strm) return Z_OK; }
-int wd_inflateEnd(z_streamp strm) +int wd_inflate_end(z_streamp strm) { return wd_zlib_uninit(strm); }
'shmid' is identifier for share memory. And it will be updated after process call shmget(). So here the process need to remember the 'shmid' to close the right share memory.
Signed-off-by: Yang Shen shenyang39@huawei.com --- wd_util.c | 84 +++++++++++++++++++------------------------------------ 1 file changed, 29 insertions(+), 55 deletions(-)
diff --git a/wd_util.c b/wd_util.c index dab4fc8..b7e6e0e 100644 --- a/wd_util.c +++ b/wd_util.c @@ -142,74 +142,50 @@ static void clone_ctx_to_internal(struct wd_ctx *ctx, ctx_in->ctx_mode = ctx->ctx_mode; }
-static int get_shared_memory_id(__u32 numsize) +static int wd_shm_create(struct wd_ctx_config_internal *in) { - int shm; - - shm = shmget(WD_IPC_KEY, sizeof(unsigned long) * numsize, - IPC_CREAT | PRIVILEGE_FLAG); - if (shm < 0) { - WD_ERR("failed to get shared memory id.\n"); - return -WD_EINVAL; - } - - return shm; -} - -static unsigned long *wd_shared_create(__u32 numsize) -{ - bool need_info = wd_need_info(); + int shm_size = sizeof(unsigned long) * WD_CTX_CNT_NUM; void *ptr; - int shm; + int shmid;
- if (!need_info) - return NULL; + if (!wd_need_info()) + return 0;
- if (numsize > WD_CTX_CNT_NUM) { - WD_ERR("invalid: input parameter is err!\n"); - return NULL; + shmid = shmget(WD_IPC_KEY, shm_size, IPC_CREAT | PRIVILEGE_FLAG); + if (shmid < 0) { + WD_ERR("failed to get shared memory id(%d).\n", errno); + return -WD_EINVAL; }
- shm = get_shared_memory_id(numsize); - if (shm < 0) - return NULL; - - ptr = shmat(shm, NULL, 0); + ptr = shmat(shmid, NULL, 0); if (ptr == (void *)-1) { - WD_ERR("failed to get shared memory addr.\n"); - return NULL; + WD_ERR("failed to get shared memory addr(%d).\n", errno); + return -WD_EINVAL; }
- memset(ptr, 0, sizeof(unsigned long) * numsize); + memset(ptr, 0, shm_size); + + in->shmid = shmid; + in->msg_cnt = ptr;
- return ptr; + return 0; }
-static void wd_shared_delete(__u32 numsize) +static void wd_shm_delete(struct wd_ctx_config_internal *in) { - bool need_info = wd_need_info(); - int shm; - - if (!need_info) - return; - - if (numsize > WD_CTX_CNT_NUM) { - WD_ERR("invalid: input parameter is err!\n"); - return; - } - - shm = get_shared_memory_id(numsize); - if (shm < 0) + if (!wd_need_info()) return;
/* deleted shared memory */ - shmctl(shm, IPC_RMID, NULL); + shmctl(in->shmid, IPC_RMID, NULL); + + in->shmid = 0; + in->msg_cnt = NULL; }
int wd_init_ctx_config(struct wd_ctx_config_internal *in, struct wd_ctx_config *cfg) { - bool need_info = wd_need_info(); struct wd_ctx_internal *ctxs; int i, j, ret;
@@ -224,9 +200,9 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, return -WD_EEXIST; }
- in->msg_cnt = wd_shared_create(WD_CTX_CNT_NUM); - if (!in->msg_cnt && need_info) - return -WD_EINVAL; + ret = wd_shm_create(in); + if (ret) + return ret;
ctxs = calloc(1, cfg->ctx_num * sizeof(struct wd_ctx_internal)); if (!ctxs) { @@ -260,9 +236,9 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, err_out: for (j = 0; j < i; j++) pthread_spin_destroy(&ctxs[j].lock); - - wd_shared_delete(WD_CTX_CNT_NUM); free(ctxs); +err_shm_del: + wd_shm_delete(in); return ret; }
@@ -311,8 +287,7 @@ void wd_clear_ctx_config(struct wd_ctx_config_internal *in) in->ctxs = NULL; }
- wd_shared_delete(WD_CTX_CNT_NUM); - in->msg_cnt = NULL; + wd_shm_delete(in); }
void wd_memset_zero(void *data, __u32 size) @@ -2580,4 +2555,3 @@ void wd_alg_attrs_uninit(struct wd_init_attrs *attrs) } wd_sched_rr_release(alg_sched); } -