Blame SOURCES/0060-UP-uevent-loop-udev.patch

4728c8
---
4728c8
 libmultipath/uevent.c |   17 ++++++++++++-----
4728c8
 libmultipath/uevent.h |    4 +++-
4728c8
 multipathd/main.c     |    8 +++++---
4728c8
 3 files changed, 20 insertions(+), 9 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/uevent.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/uevent.c
4728c8
+++ multipath-tools-130222/libmultipath/uevent.c
4728c8
@@ -47,7 +47,6 @@
4728c8
 #include "list.h"
4728c8
 #include "uevent.h"
4728c8
 #include "vector.h"
4728c8
-#include "config.h"
4728c8
 
4728c8
 typedef int (uev_trigger)(struct uevent *, void * trigger_data);
4728c8
 
4728c8
@@ -127,11 +126,14 @@ service_uevq(struct list_head *tmpq)
4728c8
 
4728c8
 static void uevq_stop(void *arg)
4728c8
 {
4728c8
+	struct udev *udev = arg;
4728c8
+
4728c8
 	condlog(3, "Stopping uev queue");
4728c8
 	pthread_mutex_lock(uevq_lockp);
4728c8
 	my_uev_trigger = NULL;
4728c8
 	pthread_cond_signal(uev_condp);
4728c8
 	pthread_mutex_unlock(uevq_lockp);
4728c8
+	udev_unref(udev);
4728c8
 }
4728c8
 
4728c8
 void
4728c8
@@ -399,9 +401,9 @@ exit:
4728c8
 	return 1;
4728c8
 }
4728c8
 
4728c8
-int uevent_listen(void)
4728c8
+int uevent_listen(struct udev *udev)
4728c8
 {
4728c8
-	int err;
4728c8
+	int err = 2;
4728c8
 	struct udev_monitor *monitor = NULL;
4728c8
 	int fd, socket_flags;
4728c8
 	int need_failback = 1;
4728c8
@@ -411,9 +413,14 @@ int uevent_listen(void)
4728c8
 	 * thereby not getting to empty the socket's receive buffer queue
4728c8
 	 * often enough.
4728c8
 	 */
4728c8
-	pthread_cleanup_push(uevq_stop, NULL);
4728c8
+	if (!udev) {
4728c8
+		condlog(1, "no udev context");
4728c8
+		return 1;
4728c8
+	}
4728c8
+	udev_ref(udev);
4728c8
+	pthread_cleanup_push(uevq_stop, udev);
4728c8
 
4728c8
-	monitor = udev_monitor_new_from_netlink(conf->udev, "udev");
4728c8
+	monitor = udev_monitor_new_from_netlink(udev, "udev");
4728c8
 	if (!monitor) {
4728c8
 		condlog(2, "failed to create udev monitor");
4728c8
 		goto out;
4728c8
Index: multipath-tools-130222/libmultipath/uevent.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/uevent.h
4728c8
+++ multipath-tools-130222/libmultipath/uevent.h
4728c8
@@ -13,6 +13,8 @@
4728c8
 #define NETLINK_KOBJECT_UEVENT		15
4728c8
 #endif
4728c8
 
4728c8
+struct udev;
4728c8
+
4728c8
 struct uevent {
4728c8
 	struct list_head node;
4728c8
 	struct udev_device *udev;
4728c8
@@ -27,7 +29,7 @@ struct uevent {
4728c8
 int is_uevent_busy(void);
4728c8
 void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
4728c8
 
4728c8
-int uevent_listen(void);
4728c8
+int uevent_listen(struct udev *udev);
4728c8
 int uevent_dispatch(int (*store_uev)(struct uevent *, void * trigger_data),
4728c8
 		    void * trigger_data);
4728c8
 int uevent_get_major(struct uevent *uev);
4728c8
Index: multipath-tools-130222/multipathd/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipathd/main.c
4728c8
+++ multipath-tools-130222/multipathd/main.c
4728c8
@@ -840,7 +840,7 @@ out:
4728c8
 static void *
4728c8
 ueventloop (void * ap)
4728c8
 {
4728c8
-	if (uevent_listen())
4728c8
+	if (uevent_listen(udev))
4728c8
 		condlog(0, "error starting uevent listener");
4728c8
 
4728c8
 	return NULL;
4728c8
@@ -1593,7 +1593,7 @@ static int
4728c8
 child (void * param)
4728c8
 {
4728c8
 	pthread_t check_thr, uevent_thr, uxlsnr_thr, uevq_thr;
4728c8
-	pthread_attr_t log_attr, misc_attr;
4728c8
+	pthread_attr_t log_attr, misc_attr, uevent_attr;
4728c8
 	struct vectors * vecs;
4728c8
 	struct multipath * mpp;
4728c8
 	int i;
4728c8
@@ -1606,6 +1606,7 @@ child (void * param)
4728c8
 	udev = udev_new();
4728c8
 
4728c8
 	setup_thread_attr(&misc_attr, 64 * 1024, 1);
4728c8
+	setup_thread_attr(&uevent_attr, 128 * 1024, 1);
4728c8
 	setup_thread_attr(&waiter_attr, 32 * 1024, 1);
4728c8
 
4728c8
 	if (logsink) {
4728c8
@@ -1671,10 +1672,11 @@ child (void * param)
4728c8
 	/*
4728c8
 	 * Start uevent listener early to catch events
4728c8
 	 */
4728c8
-	if ((rc = pthread_create(&uevent_thr, &misc_attr, ueventloop, vecs))) {
4728c8
+	if ((rc = pthread_create(&uevent_thr, &uevent_attr, ueventloop, udev))) {
4728c8
 		condlog(0, "failed to create uevent thread: %d", rc);
4728c8
 		exit(1);
4728c8
 	}
4728c8
+	pthread_attr_destroy(&uevent_attr);
4728c8
 	if ((rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs))) {
4728c8
 		condlog(0, "failed to create cli listener: %d", rc);
4728c8
 		exit(1);