From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, Hannes Reinecke <hare@suse.com>
Subject: libmultipath: add pthread_cleanup hook for udev monitor
Date: Fri, 15 Sep 2017 08:14:30 +0200 [thread overview]
Message-ID: <1505456070-116960-1-git-send-email-hare@suse.de> (raw)
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
next reply other threads:[~2017-09-15 6:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 6:14 Hannes Reinecke [this message]
2017-09-20 11:33 ` libmultipath: add pthread_cleanup hook for udev monitor Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505456070-116960-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox