All of lore.kernel.org
 help / color / mirror / Atom feed
* libmultipath: add pthread_cleanup hook for udev monitor
@ 2017-09-15  6:14 Hannes Reinecke
  2017-09-20 11:33 ` Martin Wilck
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2017-09-15  6:14 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: dm-devel, Hannes Reinecke

The udev monitor from uevent_listen() needs to be cleaned up from
a pthread cleanup hook.
Valgrind complained here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/uevent.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index eb44da56..8b511eb2 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -361,6 +361,14 @@ static void uevent_cleanup(void *arg)
 	udev_unref(udev);
 }
 
+static void monitor_cleanup(void *arg)
+{
+	struct udev_monitor *monitor = arg;
+
+	condlog(3, "Releasing uevent_monitor() resources");
+	udev_monitor_unref(monitor);
+}
+
 /*
  * Service the uevent queue.
  */
@@ -749,6 +757,7 @@ int uevent_listen(struct udev *udev)
 		condlog(2, "failed to create udev monitor");
 		goto out;
 	}
+	pthread_cleanup_push(monitor_cleanup, monitor);
 #ifdef LIBUDEV_API_RECVBUF
 	if (udev_monitor_set_receive_buffer_size(monitor, 128 * 1024 * 1024))
 		condlog(2, "failed to increase buffer size");
@@ -834,7 +843,7 @@ int uevent_listen(struct udev *udev)
 	need_failback = 0;
 out:
 	if (monitor)
-		udev_monitor_unref(monitor);
+		pthread_cleanup_pop(1);
 	if (need_failback)
 		err = failback_listen();
 	pthread_cleanup_pop(1);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: libmultipath: add pthread_cleanup hook for udev monitor
  2017-09-15  6:14 libmultipath: add pthread_cleanup hook for udev monitor Hannes Reinecke
@ 2017-09-20 11:33 ` Martin Wilck
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Wilck @ 2017-09-20 11:33 UTC (permalink / raw)
  To: Hannes Reinecke, Christophe Varoqui; +Cc: dm-devel, Hannes Reinecke

On Fri, 2017-09-15 at 08:14 +0200, Hannes Reinecke wrote:
> The udev monitor from uevent_listen() needs to be cleaned up from
> a pthread cleanup hook.
> Valgrind complained here.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>

Reviewed-by: Martin Wilck <mwilck@suse.com>

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-20 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-15  6:14 libmultipath: add pthread_cleanup hook for udev monitor Hannes Reinecke
2017-09-20 11:33 ` Martin Wilck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.