diff options
author | Tom Gundersen <teg@jklm.no> | 2015-11-24 18:25:52 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-11-25 18:30:31 +0100 |
commit | 0d43d2fcb7ac5264c739dc2f67f93ed0985a418a (patch) | |
tree | 399e2e94af1d94fec01aea7848b27db8bca27775 /src/libsystemd-network/sd-dhcp-server.c | |
parent | af143e3b692fbba2e68efd2c834711ba518f547a (diff) |
libsystemd-network: clean up recv functions
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-server.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-server.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 277c88e2b9..3e2ecdaddd 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -963,10 +963,10 @@ static int server_receive_message(sd_event_source *s, int fd, if (ioctl(fd, FIONREAD, &buflen) < 0) return -errno; - if (buflen < 0) + else if (buflen < 0) return -EIO; - message = malloc0(buflen); + message = malloc(buflen); if (!message) return -ENOMEM; @@ -974,9 +974,12 @@ static int server_receive_message(sd_event_source *s, int fd, iov.iov_len = buflen; len = recvmsg(fd, &msg, 0); - if (len < buflen) - return 0; - else if ((size_t)len < sizeof(DHCPMessage)) + if (len < 0) { + if (errno == EAGAIN || errno == EINTR) + return 0; + + return -errno; + } else if ((size_t)len < sizeof(DHCPMessage)) return 0; CMSG_FOREACH(cmsg, &msg) { |