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

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