On Wed, Apr 18, 2012 at 09:56:06AM +0200, Vitezslav Samel wrote:
If the recvfrom() call is interrupted (returns -1 and errno is
EINTR)
try one more time.
Thinking of it more and more, there's no point in looping, simply
leave this to another round of select() and recvfrom().
Please discard this one patch.
Cheers,
Vita
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/packet.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/packet.c b/src/packet.c
index ed5cd8b..293b8fb 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -164,10 +164,12 @@ void getpacket(int fd, char *buf, struct sockaddr_ll *fromaddr, int
*ch,
if (FD_ISSET(fd, &set)) {
ssize_t len;
- fromlen = sizeof(struct sockaddr_ll);
- len = recvfrom(fd, buf, MAX_PACKET_SIZE,
- MSG_TRUNC | MSG_DONTWAIT,
- (struct sockaddr *) fromaddr, &fromlen);
+ do {
+ fromlen = sizeof(struct sockaddr_ll);
+ len = recvfrom(fd, buf, MAX_PACKET_SIZE,
+ MSG_TRUNC | MSG_DONTWAIT,
+ (struct sockaddr *) fromaddr, &fromlen);
+ } while (len == -1 && errno == EINTR);
if (len > 0)
*br = len;
}
--
1.7.8.4