mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
import of dnsmasq-2.34.tar.gz
This commit is contained in:
45
src/util.c
45
src/util.c
@@ -410,3 +410,48 @@ char *print_mac(struct daemon *daemon, unsigned char *mac, int len)
|
||||
|
||||
return daemon->namebuff;
|
||||
}
|
||||
|
||||
void bump_maxfd(int fd, int *max)
|
||||
{
|
||||
if (fd > *max)
|
||||
*max = fd;
|
||||
}
|
||||
|
||||
void log_start(struct daemon *daemon)
|
||||
{
|
||||
if (daemon->options & OPT_DEBUG)
|
||||
{
|
||||
#ifdef LOG_PERROR
|
||||
openlog("dnsmasq", LOG_PERROR, daemon->log_fac);
|
||||
#else
|
||||
openlog("dnsmasq", 0, daemon->log_fac);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
openlog("dnsmasq", LOG_PID, daemon->log_fac);
|
||||
}
|
||||
|
||||
int read_write(int fd, unsigned char *packet, int size, int rw)
|
||||
{
|
||||
ssize_t n, done;
|
||||
|
||||
for (done = 0; done < size; done += n)
|
||||
{
|
||||
retry:
|
||||
if (rw)
|
||||
n = read(fd, &packet[done], (size_t)(size - done));
|
||||
else
|
||||
n = write(fd, &packet[done], (size_t)(size - done));
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
else if (n == -1)
|
||||
{
|
||||
if (errno == EINTR || errno == ENOMEM || errno == ENOBUFS)
|
||||
goto retry;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user