Skip to content

Commit

Permalink
[compress] move tracking update into a write lock context
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 115b403 commit 9654cc7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions libknet/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ int compress_cfg(
return -1;
}

if (!compress_check_lib_is_init(knet_h, cmp_model)) {
if ((!compress_check_lib_is_init(knet_h, cmp_model)) ||
(!knet_h->compress_activated[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 All @@ -312,9 +313,6 @@ int compress_cfg(
err = -1;
goto out_unlock;
}
} else {
compress_modules_cmds[cmp_model].libref++;
knet_h->compress_activated[cmp_model] = 1;
}

if (val_level(knet_h, cmp_model, knet_handle_compress_cfg->compress_level) < 0) {
Expand Down Expand Up @@ -428,7 +426,8 @@ int decompress(
return -1;
}

if (!compress_check_lib_is_init(knet_h, compress_model)) {
if ((!compress_check_lib_is_init(knet_h, compress_model)) ||
(!knet_h->compress_activated[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 All @@ -449,11 +448,6 @@ int decompress(
strerror(savederrno));
goto out_unlock;
}
} else {
if (!knet_h->compress_activated[compress_model]) {
compress_modules_cmds[compress_model].libref++;
knet_h->compress_activated[compress_model] = 1;
}
}

err = compress_modules_cmds[compress_model].decompress(knet_h, buf_in, buf_in_len, buf_out, buf_out_len);
Expand Down

0 comments on commit 9654cc7

Please sign in to comment.