[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] Only return the requested path checker



checker_lookup() silently returns the default checker if the requested
one can't be loaded. Even worse, it the default checker can't be loaded,
it gets stuck in an infinite loop.

It seems to me that if the requested checker can't be loaded, we should
just throw an error. That's what this patch does.

-Ben
Index: multipath-tools-temp/libmultipath/checkers.c
===================================================================
--- multipath-tools-temp.orig/libmultipath/checkers.c
+++ multipath-tools-temp/libmultipath/checkers.c
@@ -47,10 +47,7 @@ struct checker * checker_lookup (char * 
 		if (!strncmp(name, c->name, CHECKER_NAME_LEN))
 			return c;
 	}
-	c = add_checker(name);
-	if (c)
-		return c;
-	return checker_default();
+	return add_checker(name);
 }
 
 struct checker * add_checker (char * name)
@@ -179,6 +176,8 @@ struct checker * checker_default (void)
 
 void checker_get (struct checker * dst, struct checker * src)
 {
+	if (!src)
+		dst->check == NULL;
 	dst->fd = src->fd;
 	dst->sync = src->sync;
 	strncpy(dst->name, src->name, CHECKER_NAME_LEN);
Index: multipath-tools-temp/libmultipath/config.c
===================================================================
--- multipath-tools-temp.orig/libmultipath/config.c
+++ multipath-tools-temp/libmultipath/config.c
@@ -457,6 +457,8 @@ load_config (char * file)
 
 	if (!conf->checker)
 		conf->checker = checker_lookup(DEFAULT_CHECKER);
+	if (!conf->checker)
+		goto out;
 
 	return 0;
 out:
Index: multipath-tools-temp/libmultipath/dict.c
===================================================================
--- multipath-tools-temp.orig/libmultipath/dict.c
+++ multipath-tools-temp/libmultipath/dict.c
@@ -129,6 +129,8 @@ def_path_checker_handler(vector strvec)
 	
 	conf->checker = checker_lookup(buff);
 	FREE(buff);
+	if (!conf->checker)
+		return 1;
 
 	return 0;
 }
@@ -562,6 +564,8 @@ hw_path_checker_handler(vector strvec)
 	
 	hwe->checker = checker_lookup(buff);
 	FREE(buff);
+	if (!hwe->checker)
+		return 1;
 
 	return 0;
 }
Index: multipath-tools-temp/libmultipath/hwtable.c
===================================================================
--- multipath-tools-temp.orig/libmultipath/hwtable.c
+++ multipath-tools-temp/libmultipath/hwtable.c
@@ -733,6 +733,8 @@ setup_default_hwtable (vector hw)
 
 	while (hwe->vendor) {
 		hwe->checker = checker_lookup(hwe->checker_name);
+		if (!hwe->checker)
+			r++;
 		hwe->prio = prio_lookup(hwe->prio_name);
 		r += store_hwe(hw, hwe);
 		hwe++;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]