chiark / gitweb /
sd-rtnl: recv_message - drop message when peeking fails
authorTom Gundersen <teg@jklm.no>
Sun, 28 Dec 2014 23:24:00 +0000 (00:24 +0100)
committerTom Gundersen <teg@jklm.no>
Mon, 29 Dec 2014 00:59:49 +0000 (01:59 +0100)
Read the message form the socket or we will loop trying to read the
same message repeatedly.

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;