Skip to content

Commit

Permalink
[cleanup] move knet_handle_compress to compress.c
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 Jul 22, 2020
1 parent dfa3f44 commit 6d282d5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
34 changes: 33 additions & 1 deletion libknet/compress.c
Expand Up @@ -273,7 +273,7 @@ int compress_init(
return 0;
}

int compress_cfg(
static int compress_cfg(
knet_handle_t knet_h,
struct knet_handle_compress_cfg *knet_handle_compress_cfg)
{
Expand Down Expand Up @@ -485,6 +485,38 @@ int decompress(
return err;
}

int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *knet_handle_compress_cfg)
{
int savederrno = 0;
int err = 0;

if (!knet_h) {
errno = EINVAL;
return -1;
}

if (!knet_handle_compress_cfg) {
errno = EINVAL;
return -1;
}

savederrno = get_global_wrlock(knet_h);
if (savederrno) {
log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s",
strerror(savederrno));
errno = savederrno;
return -1;
}

compress_fini(knet_h, 0);
err = compress_cfg(knet_h, knet_handle_compress_cfg);
savederrno = errno;

pthread_rwlock_unlock(&knet_h->global_rwlock);
errno = err ? savederrno : 0;
return err;
}

int knet_get_compress_list(struct knet_compress_info *compress_list, size_t *compress_list_entries)
{
int err = 0;
Expand Down
4 changes: 0 additions & 4 deletions libknet/compress.h
Expand Up @@ -11,10 +11,6 @@

#include "internals.h"

int compress_cfg(
knet_handle_t knet_h,
struct knet_handle_compress_cfg *knet_handle_compress_cfg);

int compress_init(
knet_handle_t knet_h);

Expand Down
32 changes: 0 additions & 32 deletions libknet/handle.c
Expand Up @@ -1599,38 +1599,6 @@ int knet_handle_crypto_use_config(knet_handle_t knet_h,
return err;
}

int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *knet_handle_compress_cfg)
{
int savederrno = 0;
int err = 0;

if (!knet_h) {
errno = EINVAL;
return -1;
}

if (!knet_handle_compress_cfg) {
errno = EINVAL;
return -1;
}

savederrno = get_global_wrlock(knet_h);
if (savederrno) {
log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s",
strerror(savederrno));
errno = savederrno;
return -1;
}

compress_fini(knet_h, 0);
err = compress_cfg(knet_h, knet_handle_compress_cfg);
savederrno = errno;

pthread_rwlock_unlock(&knet_h->global_rwlock);
errno = err ? savederrno : 0;
return err;
}

ssize_t knet_recv(knet_handle_t knet_h, char *buff, const size_t buff_len, const int8_t channel)
{
int savederrno = 0;
Expand Down

0 comments on commit 6d282d5

Please sign in to comment.