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 92f3182..640c0ea 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;