diff options
author | Tushar Gohad <tushar.gohad@intel.com> | 2014-07-22 18:25:30 -0700 |
---|---|---|
committer | Tushar Gohad <tushar.gohad@intel.com> | 2014-07-22 18:25:30 -0700 |
commit | 5b393fab81a3326553827ab7b1cda0ca008468a0 (patch) | |
tree | 5a86a722f8964ca9f5c1da11d851f51b2c76fc1a /src/utils | |
parent | e96f00ee117b936bd54ed04494122eca575ca066 (diff) | |
download | liberasurecode-5b393fab81a3326553827ab7b1cda0ca008468a0.tar.gz |
algsig: Move jerasure backend dlopen up a level
.. also check for errors
Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/chksum/alg_sig.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/utils/chksum/alg_sig.c b/src/utils/chksum/alg_sig.c index f8329b8..bfaa4a1 100644 --- a/src/utils/chksum/alg_sig.c +++ b/src/utils/chksum/alg_sig.c @@ -24,6 +24,7 @@ #include <dlfcn.h> #include <alg_sig.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -45,7 +46,7 @@ int load_gf_functions(void *sohandle, struct jerasure_mult_routines *routines) } static -alg_sig_t *init_alg_sig_w8(int sig_len) +alg_sig_t *init_alg_sig_w8(void *jerasure_sohandle, int sig_len) { alg_sig_t *alg_sig_handle; int num_gf_lr_table_syms; @@ -55,12 +56,6 @@ alg_sig_t *init_alg_sig_w8(int sig_len) int num_components = sig_len / w; struct jerasure_mult_routines g_jerasure_mult_routines; - void *jerasure_sohandle = get_jerasure_sohandle(); - - if (NULL == jerasure_sohandle) { - return NULL; - } - alg_sig_handle = (alg_sig_t *)malloc(sizeof(alg_sig_t)); if (NULL == alg_sig_handle) { return NULL; @@ -109,7 +104,7 @@ alg_sig_t *init_alg_sig_w8(int sig_len) } static -alg_sig_t *init_alg_sig_w16(int sig_len) +alg_sig_t *init_alg_sig_w16(void *jerasure_sohandle, int sig_len) { alg_sig_t *alg_sig_handle; int num_gf_lr_table_syms; @@ -117,14 +112,13 @@ alg_sig_t *init_alg_sig_w16(int sig_len) int w = 16; int alpha = 2, beta = 4, gamma = 8; int num_components = sig_len / w; - - void *jerasure_sohandle = get_jerasure_sohandle(); - if (jerasure_sohandle == NULL) { - return NULL; + + if (NULL == jerasure_sohandle) { + return NULL; } alg_sig_handle = (alg_sig_t *)malloc(sizeof(alg_sig_t)); - if (alg_sig_handle == NULL) { + if (NULL == alg_sig_handle) { return NULL; } @@ -176,6 +170,13 @@ alg_sig_t *init_alg_sig_w16(int sig_len) alg_sig_t *init_alg_sig(int sig_len, int gf_w) { int i=0; + void *jerasure_sohandle = get_jerasure_sohandle(); + + if (NULL == jerasure_sohandle) { + fprintf (stderr, "Could not open Jerasure backend. Install Jerasure or fix LD_LIBRARY_PATH. Passing.\n"); + return NULL; + } + while (valid_pairs[i][0] > -1) { if (gf_w == valid_pairs[i][0] && sig_len == valid_pairs[i][1]) { @@ -189,9 +190,9 @@ alg_sig_t *init_alg_sig(int sig_len, int gf_w) } if (gf_w == 8) { - return init_alg_sig_w8(sig_len); + return init_alg_sig_w8(jerasure_sohandle, sig_len); } else if (gf_w == 16) { - return init_alg_sig_w16(sig_len); + return init_alg_sig_w16(jerasure_sohandle, sig_len); } return NULL; } |