From: Hannes Reinecke Date: Tue, 13 Jan 2009 14:28:23 +0000 (+0100) Subject: Checker name is not displayed on failure X-Git-Tag: upstream/0.5.0~106^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=224a6f156408405d42dbc12bcc62e052fbc9bc4b;p=platform%2Fupstream%2Fmultipath-tools.git Checker name is not displayed on failure If add_checker() isn't able to locate the checker it won't display the name in free_checker(). Signed-off-by: Hannes Reinecke --- diff --git a/libmultipath/prio.c b/libmultipath/prio.c index 13e6823..61c19b7 100644 --- a/libmultipath/prio.c +++ b/libmultipath/prio.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "debug.h" #include "prio.h" @@ -18,14 +19,24 @@ int init_prio (void) static struct prio * alloc_prio (void) { - return MALLOC(sizeof(struct prio)); + struct prio *p; + + p = MALLOC(sizeof(struct prio)); + if (p) + INIT_LIST_HEAD(&p->node); + return p; } void free_prio (struct prio * p) { + condlog(3, "unloading %s prioritizer", p->name); list_del(&p->node); - if (p->handle) - dlclose(p->handle); + if (p->handle) { + if (dlclose(p->handle) != 0) { + condlog(0, "Cannot unload prioritizer %s: %s", + p->name, dlerror()); + } + } FREE(p); } @@ -58,6 +69,7 @@ int prio_set_args (struct prio * p, char * args) struct prio * add_prio (char * name) { char libname[LIB_PRIO_NAMELEN]; + struct stat stbuf; struct prio * p; char *errstr; @@ -66,13 +78,19 @@ struct prio * add_prio (char * name) return NULL; snprintf(libname, LIB_PRIO_NAMELEN, "%s/libprio%s.so", conf->multipath_dir, name); + if (stat(libname,&stbuf) < 0) { + condlog(0,"Prioritizer '%s' not found in %s", + name, conf->multipath_dir); + goto out; + } condlog(3, "loading %s prioritizer", libname); p->handle = dlopen(libname, RTLD_NOW); - errstr = dlerror(); - if (errstr != NULL) - condlog(0, "A dynamic linking error occurred: (%s)", errstr); - if (!p->handle) + if (!p->handle) { + if ((errstr = dlerror()) != NULL) + condlog(0, "A dynamic linking error occurred: (%s)", + errstr); goto out; + } p->getprio = (int (*)(struct path *, char *)) dlsym(p->handle, "getprio"); errstr = dlerror(); if (errstr != NULL)