daandemeyer / rpms / systemd

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