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

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