f20720
---
f20720
 libmultipath/configure.c |    8 +++--
f20720
 multipathd/main.c        |   68 +++++++++++++++++++++++++++++++++++++----------
f20720
 2 files changed, 59 insertions(+), 17 deletions(-)
f20720
f20720
Index: multipath-tools-130222/libmultipath/configure.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/configure.c
f20720
+++ multipath-tools-130222/libmultipath/configure.c
f20720
@@ -829,8 +829,10 @@ coalesce_paths (struct vectors * vecs, v
f20720
 		 * at this point, we know we really got a new mp
f20720
 		 */
f20720
 		mpp = add_map_with_path(vecs, pp1, 0);
f20720
-		if (!mpp)
f20720
-			return 1;
f20720
+		if (!mpp) {
f20720
+			orphan_path(pp1);
f20720
+			continue;
f20720
+		}
f20720
 
f20720
 		if (pp1->priority == PRIO_UNDEF)
f20720
 			mpp->action = ACT_REJECT;
f20720
@@ -879,7 +881,7 @@ coalesce_paths (struct vectors * vecs, v
f20720
 			condlog(3, "%s: domap (%u) failure "
f20720
 				   "for create/reload map",
f20720
 				mpp->alias, r);
f20720
-			if (r == DOMAP_FAIL) {
f20720
+			if (r == DOMAP_FAIL || conf->daemon) {
f20720
 				condlog(2, "%s: %s map",
f20720
 					mpp->alias, (mpp->action == ACT_CREATE)?
f20720
 					"ignoring" : "removing");
f20720
Index: multipath-tools-130222/multipathd/main.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipathd/main.c
f20720
+++ multipath-tools-130222/multipathd/main.c
f20720
@@ -821,7 +821,7 @@ map_discovery (struct vectors * vecs)
f20720
 
f20720
 	vector_foreach_slot (vecs->mpvec, mpp, i)
f20720
 		if (setup_multipath(vecs, mpp))
f20720
-			return 1;
f20720
+			i--;
f20720
 
f20720
 	return 0;
f20720
 }
f20720
@@ -1523,21 +1523,29 @@ configure (struct vectors * vecs, int st
f20720
 	vector mpvec;
f20720
 	int i, ret;
f20720
 
f20720
-	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc()))
f20720
+	if (!vecs->pathvec && !(vecs->pathvec = vector_alloc())) {
f20720
+		condlog(0, "couldn't allocate path vec in configure");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
-	if (!vecs->mpvec && !(vecs->mpvec = vector_alloc()))
f20720
+	if (!vecs->mpvec && !(vecs->mpvec = vector_alloc())) {
f20720
+		condlog(0, "couldn't allocate multipath vec in configure");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
-	if (!(mpvec = vector_alloc()))
f20720
+	if (!(mpvec = vector_alloc())) {
f20720
+		condlog(0, "couldn't allocate new maps vec in configure");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
 	/*
f20720
 	 * probe for current path (from sysfs) and map (from dm) sets
f20720
 	 */
f20720
 	ret = path_discovery(vecs->pathvec, conf, DI_ALL);
f20720
-	if (ret < 0)
f20720
+	if (ret < 0) {
f20720
+		condlog(0, "configure failed at path discovery");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
 	vector_foreach_slot (vecs->pathvec, pp, i){
f20720
 		if (filter_path(conf, pp) > 0){
f20720
@@ -1548,21 +1556,27 @@ configure (struct vectors * vecs, int st
f20720
 		else
f20720
 			pp->checkint = conf->checkint;
f20720
 	}
f20720
-	if (map_discovery(vecs))
f20720
+	if (map_discovery(vecs)) {
f20720
+		condlog(0, "configure failed at map discovery");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
 	/*
f20720
 	 * create new set of maps & push changed ones into dm
f20720
 	 */
f20720
-	if (coalesce_paths(vecs, mpvec, NULL, 1))
f20720
+	if (coalesce_paths(vecs, mpvec, NULL, 1)) {
f20720
+		condlog(0, "configure failed while coalescing paths");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
 	/*
f20720
 	 * may need to remove some maps which are no longer relevant
f20720
 	 * e.g., due to blacklist changes in conf file
f20720
 	 */
f20720
-	if (coalesce_maps(vecs, mpvec))
f20720
+	if (coalesce_maps(vecs, mpvec)) {
f20720
+		condlog(0, "configure failed while coalescing maps");
f20720
 		return 1;
f20720
+	}
f20720
 
f20720
 	dm_lib_release();
f20720
 
f20720
@@ -1588,11 +1602,15 @@ configure (struct vectors * vecs, int st
f20720
 	 * start dm event waiter threads for these new maps
f20720
 	 */
f20720
 	vector_foreach_slot(vecs->mpvec, mpp, i) {
f20720
-		if (setup_multipath(vecs, mpp))
f20720
-			return 1;
f20720
+		if (setup_multipath(vecs, mpp)) {
f20720
+			i--;
f20720
+			continue;
f20720
+		}
f20720
 		if (start_waiters)
f20720
-			if (start_waiter_thread(mpp, vecs))
f20720
-				return 1;
f20720
+			if (start_waiter_thread(mpp, vecs)) {
f20720
+				remove_map(mpp, vecs, 1);
f20720
+				i--;
f20720
+			}
f20720
 	}
f20720
 	return 0;
f20720
 }
f20720
@@ -1857,15 +1875,23 @@ child (void * param)
f20720
 	condlog(2, "--------start up--------");
f20720
 	condlog(2, "read " DEFAULT_CONFIGFILE);
f20720
 
f20720
-	if (load_config(DEFAULT_CONFIGFILE, udev))
f20720
+	if (load_config(DEFAULT_CONFIGFILE, udev)) {
f20720
+		condlog(0, "failed to load config");
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
+	}
f20720
 
f20720
 	if (init_checkers()) {
f20720
 		condlog(0, "failed to initialize checkers");
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	if (init_prio()) {
f20720
 		condlog(0, "failed to initialize prioritizers");
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 
f20720
@@ -1898,8 +1924,12 @@ child (void * param)
f20720
 	}
f20720
 
f20720
 	vecs = gvecs = init_vecs();
f20720
-	if (!vecs)
f20720
+	if (!vecs) {
f20720
+		condlog(0, "failed to create vecs");
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
+	}
f20720
 
f20720
 	setscheduler();
f20720
 	set_oom_adj();
f20720
@@ -1911,11 +1941,15 @@ child (void * param)
f20720
 	 */
f20720
 	if ((rc = pthread_create(&uevent_thr, &uevent_attr, ueventloop, udev))) {
f20720
 		condlog(0, "failed to create uevent thread: %d", rc);
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	pthread_attr_destroy(&uevent_attr);
f20720
 	if ((rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs))) {
f20720
 		condlog(0, "failed to create cli listener: %d", rc);
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	/*
f20720
@@ -1927,6 +1961,8 @@ child (void * param)
f20720
 	if (configure(vecs, 1)) {
f20720
 		unlock(vecs->lock);
f20720
 		condlog(0, "failure during configuration");
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	unlock(vecs->lock);
f20720
@@ -1936,10 +1972,14 @@ child (void * param)
f20720
 	 */
f20720
 	if ((rc = pthread_create(&check_thr, &misc_attr, checkerloop, vecs))) {
f20720
 		condlog(0,"failed to create checker loop thread: %d", rc);
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	if ((rc = pthread_create(&uevq_thr, &misc_attr, uevqloop, vecs))) {
f20720
 		condlog(0, "failed to create uevent dispatcher: %d", rc);
f20720
+		if (logsink)
f20720
+			log_thread_stop();
f20720
 		exit(1);
f20720
 	}
f20720
 	pthread_attr_destroy(&misc_attr);