From: Lennart Poettering Date: Sun, 31 Dec 2006 17:33:57 +0000 (+0000) Subject: Ignore EAGAIN errors on recvmsg() (Closes #60) X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=c3ed8d543014877ec1a5cd2ab0fbef79c03c0467;p=catta Ignore EAGAIN errors on recvmsg() (Closes #60) git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1361 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/socket.c b/avahi-core/socket.c index 9291f08..9ca1437 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -635,6 +635,9 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(int fd, AvahiIPv4Address *ret_src_add goto fail; } + if (ms <= 0) + goto fail; + p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE); io.iov_base = AVAHI_DNS_PACKET_DATA(p); @@ -650,7 +653,14 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4(int fd, AvahiIPv4Address *ret_src_add msg.msg_flags = 0; if ((l = recvmsg(fd, &msg, 0)) < 0) { - avahi_log_warn("recvmsg(): %s", strerror(errno)); + /* Linux returns EAGAIN when an invalid IP packet has been + recieved. We suppress warnings in this case because this might + create quite a bit of log traffic on machines with unstable + links. (See #60) */ + + if (errno != EAGAIN) + avahi_log_warn("recvmsg(): %s", strerror(errno)); + goto fail; } @@ -768,6 +778,9 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(int fd, AvahiIPv6Address *ret_src_add avahi_log_warn("ioctl(): %s", strerror(errno)); goto fail; } + + if (ms <= 0) + goto fail; p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE); @@ -785,7 +798,14 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6(int fd, AvahiIPv6Address *ret_src_add msg.msg_flags = 0; if ((l = recvmsg(fd, &msg, 0)) < 0) { - avahi_log_warn("recvmsg(): %s", strerror(errno)); + /* Linux returns EAGAIN when an invalid IP packet has been + recieved. We suppress warnings in this case because this might + create quite a bit of log traffic on machines with unstable + links. (See #60) */ + + if (errno != EAGAIN) + avahi_log_warn("recvmsg(): %s", strerror(errno)); + goto fail; }