Fix bug which caused dnsmasq to become unresponsive when an interface goes.

This commit is contained in:
Simon Kelley
2014-09-18 22:08:58 +01:00
parent 288df49c96
commit 5782649ad9
2 changed files with 17 additions and 3 deletions

View File

@@ -570,18 +570,28 @@ void bump_maxfd(int fd, int *max)
int retry_send(void)
{
struct timespec waiter;
/* Linux kernels can return EAGAIN in perpetuity when calling
sendmsg() and the relevant interface has gone. Here we loop
retrying in EAGAIN for 1 second max, to avoid this hanging
dnsmasq. */
static int retries = 0;
struct timespec waiter;
if (errno == EAGAIN || errno == EWOULDBLOCK)
{
waiter.tv_sec = 0;
waiter.tv_nsec = 10000;
nanosleep(&waiter, NULL);
return 1;
if (retries++ < 1000)
return 1;
}
retries = 0;
if (errno == EINTR)
return 1;
return 0;
}