summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-06-02 17:50:40 +0200
committerLennart Poettering <lennart@poettering.net>2016-06-06 19:59:08 +0200
commitf3315c5860548b5560ef114a1e2af4eaafb32c6b (patch)
treefdba5afc80cc3da3fd36283ba84fa1c813a7d853
parent35ad2cd7ce3c85a9ff8f251ac9c325bdd6e852ef (diff)
lldp: deal properly with recv() returning EAGAIN/EINTR
It might very well return EAGAIN in case of packet checksum problems and suchlike, hence let's better handle this nicely, the same way as we do it in the other sd-network libraries for incoming datagrams.
-rw-r--r--src/libsystemd-network/sd-lldp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
index c74deccd0c..66d5dbf203 100644
--- a/src/libsystemd-network/sd-lldp.c
+++ b/src/libsystemd-network/sd-lldp.c
@@ -216,8 +216,12 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
return -ENOMEM;
length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT);
- if (length < 0)
+ if (length < 0) {
+ if (errno == EAGAIN || errno == EINTR)
+ return 0;
+
return log_lldp_errno(errno, "Failed to read LLDP datagram: %m");
+ }
if ((size_t) length != n->raw_size) {
log_lldp("Packet size mismatch.");