valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0107-libudev-monitor-fix-error-path-in-send_device.patch

803fb7
From dfd0017561730f675d65cc826815ce7c932892aa Mon Sep 17 00:00:00 2001
803fb7
From: Tom Gundersen <teg@jklm.no>
803fb7
Date: Wed, 11 Mar 2015 22:23:38 +0100
803fb7
Subject: [PATCH] libudev: monitor - fix error path in send_device
803fb7
803fb7
Return -errno rather than -1 in case sendmsg() fails.
803fb7
803fb7
(cherry picked from commit a4445e88cece0444c66d70876b03065158dd4685)
803fb7
---
803fb7
 src/libudev/libudev-monitor.c | 10 +++++++++-
803fb7
 1 file changed, 9 insertions(+), 1 deletion(-)
803fb7
803fb7
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
803fb7
index 3f1fee7f7..d0486e3d1 100644
803fb7
--- a/src/libudev/libudev-monitor.c
803fb7
+++ b/src/libudev/libudev-monitor.c
803fb7
@@ -749,12 +749,20 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
803fb7
          * If we send to a multicast group, we will get
803fb7
          * ECONNREFUSED, which is expected.
803fb7
          */
803fb7
-        if (destination != NULL)
803fb7
+        if (destination)
803fb7
                 smsg.msg_name = &destination->snl;
803fb7
         else
803fb7
                 smsg.msg_name = &udev_monitor->snl_destination;
803fb7
         smsg.msg_namelen = sizeof(struct sockaddr_nl);
803fb7
         count = sendmsg(udev_monitor->sock, &smsg, 0);
803fb7
+        if (count < 0) {
803fb7
+                if (!destination && errno == ECONNREFUSED) {
803fb7
+                        log_debug("passed unknown number of bytes to netlink monitor %p", udev_monitor);
803fb7
+                        return 0;
803fb7
+                } else
803fb7
+                        return -errno;
803fb7
+        }
803fb7
+
803fb7
         log_debug("passed %zi bytes to netlink monitor %p", count, udev_monitor);
803fb7
         return count;
803fb7
 }