]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[compress] split init and config functions
authorFabio M. Di Nitto <fdinitto@redhat.com>
Wed, 16 Aug 2017 03:54:11 +0000 (05:54 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 17 Aug 2017 09:54:12 +0000 (11:54 +0200)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libknet/compress.c
libknet/compress.h
libknet/handle.c
libknet/internals.h

index af09ce059ab70ddd624dc15d71c2418f8d982e41..95354ed92de602861e7e46945489a21291ba2dc3 100644 (file)
@@ -121,31 +121,37 @@ static int val_level(
 }
 
 int compress_init(
-       knet_handle_t knet_h,
-       struct knet_handle_compress_cfg *knet_handle_compress_cfg)
+       knet_handle_t knet_h)
 {
-       int cmp_model, idx = 0;
+       int idx = 0;
 
        if (get_max_model() > KNET_MAX_COMPRESS_METHODS) {
-               log_err(knet_h, KNET_SUB_COMPRESS, "Too many compress methods supported by compress.c. Please complain to knet developers to fix internals.h KNET_MAX_COMPRESS_METHODS define!");
+               log_err(knet_h, KNET_SUB_COMPRESS, "Too many compress methods defined in compress.c.");
                errno = EINVAL;
                return -1;
        }
-       if (!knet_handle_compress_cfg) {
-               while ((compress_modules_cmds[idx].model_name != NULL) &&
-                      (compress_modules_cmds[idx].built_in == 1)) {
-                       if (compress_modules_cmds[idx].init != NULL) {
-                               if (compress_modules_cmds[idx].init(knet_h, idx) < 0) {
-                                       log_err(knet_h, KNET_SUB_COMPRESS, "Failed to initialize %s library", compress_modules_cmds[idx].model_name);
-                                       errno = EINVAL;
-                                       return -1;
-                               }
+
+       while ((compress_modules_cmds[idx].model_name != NULL) &&
+              (compress_modules_cmds[idx].built_in == 1)) {
+               if (compress_modules_cmds[idx].init != NULL) {
+                       if (compress_modules_cmds[idx].init(knet_h, idx) < 0) {
+                               log_err(knet_h, KNET_SUB_COMPRESS, "Failed to initialize %s library", compress_modules_cmds[idx].model_name);
+                               errno = EINVAL;
+                               return -1;
                        }
-                       idx++;
                }
-               return 0;
+               idx++;
        }
 
+       return 0;
+}
+
+int compress_cfg(
+       knet_handle_t knet_h,
+       struct knet_handle_compress_cfg *knet_handle_compress_cfg)
+{
+       int cmp_model;
+
        log_debug(knet_h, KNET_SUB_COMPRESS,
                  "Initizializing compress module [%s/%d/%u]",
                  knet_handle_compress_cfg->compress_model, knet_handle_compress_cfg->compress_level, knet_handle_compress_cfg->compress_threshold);
index ffc6d8d8a3e33128f705dd465dbb3f69e7429361..905e92900fbb392a351eb42dd0db4a6eb47081b6 100644 (file)
@@ -31,10 +31,13 @@ typedef struct {
                         ssize_t *buf_out_len);
 } compress_model_t;
 
-int compress_init(
+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);
+
 void compress_fini(
        knet_handle_t knet_h);
 
index b9ac56832f7d09bb12312e6061a9a5f50004e383..f10d3bf2224e22ecfa6821977eac378728484a23 100644 (file)
@@ -627,7 +627,7 @@ knet_handle_t knet_handle_new(knet_node_id_t host_id,
                goto exit_fail;
        }
 
-       if (compress_init(knet_h, NULL)) {
+       if (compress_init(knet_h)) {
                savederrno = errno;
                goto exit_fail;
        }
@@ -1349,7 +1349,7 @@ int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *
                return -1;
        }
 
-       err = compress_init(knet_h, knet_handle_compress_cfg);
+       err = compress_cfg(knet_h, knet_handle_compress_cfg);
        savederrno = errno;
 
        pthread_rwlock_unlock(&knet_h->global_rwlock);
index 0cae38effc876c5bc20503124c6b256a25856a49..2465de3ae91172b2f172e420a6e568acecd048d1 100644 (file)
@@ -134,7 +134,7 @@ struct knet_fd_trackers {
 
 #define KNET_MAX_FDS KNET_MAX_HOST * KNET_MAX_LINK * 4
 
-#define KNET_MAX_COMPRESS_METHODS 32
+#define KNET_MAX_COMPRESS_METHODS UINT8_MAX
 
 struct knet_handle {
        knet_node_id_t host_id;