chiark / gitweb /
sd-rtnl: recv_message - drop message when peeking fails
[elogind.git] / src / libsystemd / sd-rtnl / rtnl-message.c
index 92f318267e009e7d351727ec04a8e589af8481e9..640c0ea93eadf34f451ef9ce3a492923ccef122f 100644 (file)
@@ -1377,9 +1377,17 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
                 }
         }
 
-        if (!auth)
+        if (!auth) {
                 /* not from the kernel, ignore */
+                if (peek) {
+                        /* drop the message */
+                        r = recvmsg(fd, &msg, 0);
+                        if (r < 0)
+                                return (errno == EAGAIN || errno == EINTR) ? 0 : -errno;
+                }
+
                 return 0;
+        }
 
         if (group)
                 *_group = group;