Theoretical correctness fix:

Handle EAGAIN and EWOULDBLOCK more gracefully when dealing with safe_read().
All occurrences of safe_read() should only be invoked on fds that have signaled
ready-to-read state via the epoll() mechanism, so this change should not
result in any observable difference, but it is best to be safe.

Additionally, a constant stack variable is converted to an equivalent
macro define for cleanliness.

Finally, print the error type encountered if reading data from an ARP response
fails with a read error.
This commit is contained in:
Nicholas J. Kain
2011-05-30 10:54:05 -04:00
parent 03f0e8719e
commit d72b24a2fe
24 changed files with 26 additions and 13 deletions

10
ifchd/ifchd.c Executable file → Normal file
View File

@@ -1,5 +1,5 @@
/* ifchd.c - interface change daemon
* Time-stamp: <2011-05-01 19:03:48 njk>
* Time-stamp: <2011-05-30 10:30:20 njk>
*
* (C) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
*
@@ -664,10 +664,12 @@ static void process_client_fd(int fd)
memset(buf, '\0', sizeof buf);
r = safe_read(sks[sqidx], buf, sizeof buf / 2 - 1);
if (r <= 0) {
if (r != 0)
log_line("error reading from client fd: %s", strerror(errno));
if (r == 0)
goto fail;
else if (r < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
return;
log_line("error reading from client fd: %s", strerror(errno));
}
/* Discard everything and close connection if we risk overflow.