Skip to content

Commit

Permalink
[dlopen] compress: drop unnecessary tracker and use init array instead
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Sep 14, 2017
1 parent 9654cc7 commit 181118e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
11 changes: 3 additions & 8 deletions libknet/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ static int compress_load_lib(knet_handle_t knet_h, int cmp_model, int rate_limit
}

compress_modules_cmds[cmp_model].libref++;
knet_h->compress_activated[cmp_model] = 1;

return 0;
}
Expand All @@ -238,7 +237,6 @@ int compress_init(
return -1;
}

memset(knet_h->compress_activated, 0, KNET_MAX_COMPRESS_METHODS);
memset(&last_load_failure, 0, sizeof(struct timespec));

return 0;
Expand Down Expand Up @@ -291,8 +289,7 @@ int compress_cfg(
return -1;
}

if ((!compress_check_lib_is_init(knet_h, cmp_model)) ||
(!knet_h->compress_activated[cmp_model])) {
if (!compress_check_lib_is_init(knet_h, cmp_model)) {
/*
* need to switch to write lock, load the lib, and return with a write lock
* this is not racy because compress_load_lib is written idempotent.
Expand Down Expand Up @@ -356,7 +353,7 @@ void compress_fini(
if ((compress_modules_cmds[idx].built_in == 1) &&
(compress_modules_cmds[idx].loaded == 1) &&
(compress_modules_cmds[idx].model_id > 0) &&
(knet_h->compress_activated[compress_modules_cmds[idx].model_id] == 1) &&
(knet_h->compress_int_data[idx] != NULL) &&
(idx < KNET_MAX_COMPRESS_METHODS)) {
if ((all) || (compress_modules_cmds[idx].model_id == knet_h->compress_model)) {
if (compress_modules_cmds[idx].fini != NULL) {
Expand All @@ -365,7 +362,6 @@ void compress_fini(
knet_h->compress_int_data[idx] = NULL;
}
compress_modules_cmds[idx].libref--;
knet_h->compress_activated[compress_modules_cmds[idx].model_id] = 0;

if ((compress_modules_cmds[idx].libref == 0) &&
(compress_modules_cmds[idx].loaded == 1)) {
Expand Down Expand Up @@ -426,8 +422,7 @@ int decompress(
return -1;
}

if ((!compress_check_lib_is_init(knet_h, compress_model)) ||
(!knet_h->compress_activated[compress_model])) {
if (!compress_check_lib_is_init(knet_h, compress_model)) {
/*
* need to switch to write lock, load the lib, and return with a write lock
* this is not racy because compress_load_lib is written idempotent.
Expand Down
1 change: 0 additions & 1 deletion libknet/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ struct knet_handle {
int compress_level;
uint32_t compress_threshold;
void *compress_int_data[KNET_MAX_COMPRESS_METHODS]; /* for compress method private data */
uint8_t compress_activated[KNET_MAX_COMPRESS_METHODS]; /* track active compression library used by this handle */
unsigned char *recv_from_links_buf_decompress;
unsigned char *send_to_links_buf_compress;
seq_num_t tx_seq_num;
Expand Down

0 comments on commit 181118e

Please sign in to comment.