"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dnsmasq.c" between
dnsmasq-2.84.tar.xz and dnsmasq-2.85.tar.xz

About: Dnsmasq is a lightweight caching DNS forwarder and DHCP server.

dnsmasq.c  (dnsmasq-2.84.tar.xz):dnsmasq.c  (dnsmasq-2.85.tar.xz)
skipping to change at line 240 skipping to change at line 240
#ifndef HAVE_LOOP #ifndef HAVE_LOOP
if (option_bool(OPT_LOOP_DETECT)) if (option_bool(OPT_LOOP_DETECT))
die(_("loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF); die(_("loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF);
#endif #endif
#ifndef HAVE_UBUS #ifndef HAVE_UBUS
if (option_bool(OPT_UBUS)) if (option_bool(OPT_UBUS))
die(_("Ubus not available: set HAVE_UBUS in src/config.h"), NULL, EC_BADCONF ); die(_("Ubus not available: set HAVE_UBUS in src/config.h"), NULL, EC_BADCONF );
#endif #endif
/* Handle only one of min_port/max_port being set. */
if (daemon->min_port != 0 && daemon->max_port == 0)
daemon->max_port = MAX_PORT;
if (daemon->max_port != 0 && daemon->min_port == 0)
daemon->min_port = MIN_PORT;
if (daemon->max_port < daemon->min_port) if (daemon->max_port < daemon->min_port)
die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF); die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF);
now = dnsmasq_time(); now = dnsmasq_time();
if (daemon->auth_zones) if (daemon->auth_zones)
{ {
if (!daemon->authserver) if (!daemon->authserver)
die(_("--auth-server required when an auth zone is defined."), NULL, EC_B ADCONF); die(_("--auth-server required when an auth zone is defined."), NULL, EC_B ADCONF);
skipping to change at line 395 skipping to change at line 402
/* After netlink_init() and before create_helper() */ /* After netlink_init() and before create_helper() */
lease_make_duid(now); lease_make_duid(now);
#endif #endif
if (daemon->port != 0) if (daemon->port != 0)
{ {
cache_init(); cache_init();
blockdata_init(); blockdata_init();
hash_questions_init(); hash_questions_init();
/* Scale random socket pool by ftabsize, but
limit it based on available fds. */
daemon->numrrand = daemon->ftabsize/2;
if (daemon->numrrand > max_fd/3)
daemon->numrrand = max_fd/3;
/* safe_malloc returns zero'd memory */
daemon->randomsocks = safe_malloc(daemon->numrrand * sizeof(struct randfd)
);
} }
#ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY
if ((daemon->port != 0 || daemon->dhcp || daemon->doing_dhcp6) if ((daemon->port != 0 || daemon->dhcp || daemon->doing_dhcp6)
&& (!option_bool(OPT_NO_RESOLV) || daemon->dynamic_dirs)) && (!option_bool(OPT_NO_RESOLV) || daemon->dynamic_dirs))
inotify_dnsmasq_init(); inotify_dnsmasq_init();
else else
daemon->inotifyfd = -1; daemon->inotifyfd = -1;
#endif #endif
skipping to change at line 982 skipping to change at line 997
for (p = daemon->if_prefix; p; p = p->next) for (p = daemon->if_prefix; p; p = p->next)
if (p->missing) if (p->missing)
my_syslog(MS_TFTP | LOG_WARNING, _("warning: TFTP directory %s inacces sible"), p->prefix); my_syslog(MS_TFTP | LOG_WARNING, _("warning: TFTP directory %s inacces sible"), p->prefix);
/* This is a guess, it assumes that for small limits, /* This is a guess, it assumes that for small limits,
disjoint files might be served, but for large limits, disjoint files might be served, but for large limits,
a single file will be sent to may clients (the file only needs a single file will be sent to may clients (the file only needs
one fd). */ one fd). */
max_fd -= 30; /* use other than TFTP */ max_fd -= 30 + daemon->numrrand; /* use other than TFTP */
if (max_fd < 0) if (max_fd < 0)
max_fd = 5; max_fd = 5;
else if (max_fd < 100 && !option_bool(OPT_SINGLE_PORT)) else if (max_fd < 100 && !option_bool(OPT_SINGLE_PORT))
max_fd = max_fd/2; max_fd = max_fd/2;
else else
max_fd = max_fd - 20; max_fd = max_fd - 20;
/* if we have to use a limited range of ports, /* if we have to use a limited range of ports,
that will limit the number of transfers */ that will limit the number of transfers */
skipping to change at line 1673 skipping to change at line 1688
alarms for ra only */ alarms for ra only */
send_alarm(periodic_ra(now), now); send_alarm(periodic_ra(now), now);
#endif #endif
#endif #endif
} }
static int set_dns_listeners(time_t now) static int set_dns_listeners(time_t now)
{ {
struct serverfd *serverfdp; struct serverfd *serverfdp;
struct listener *listener; struct listener *listener;
struct randfd_list *rfl;
int wait = 0, i; int wait = 0, i;
#ifdef HAVE_TFTP #ifdef HAVE_TFTP
int tftp = 0; int tftp = 0;
struct tftp_transfer *transfer; struct tftp_transfer *transfer;
if (!option_bool(OPT_SINGLE_PORT)) if (!option_bool(OPT_SINGLE_PORT))
for (transfer = daemon->tftp_trans; transfer; transfer = transfer->next) for (transfer = daemon->tftp_trans; transfer; transfer = transfer->next)
{ {
tftp++; tftp++;
poll_listen(transfer->sockfd, POLLIN); poll_listen(transfer->sockfd, POLLIN);
} }
#endif #endif
/* will we be able to get memory? */ /* will we be able to get memory? */
if (daemon->port != 0) if (daemon->port != 0)
get_new_frec(now, &wait, NULL); get_new_frec(now, &wait, NULL);
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next) for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
poll_listen(serverfdp->fd, POLLIN); poll_listen(serverfdp->fd, POLLIN);
if (daemon->port != 0 && !daemon->osport) for (i = 0; i < daemon->numrrand; i++)
for (i = 0; i < RANDOM_SOCKS; i++) if (daemon->randomsocks[i].refcount != 0)
if (daemon->randomsocks[i].refcount != 0) poll_listen(daemon->randomsocks[i].fd, POLLIN);
poll_listen(daemon->randomsocks[i].fd, POLLIN);
/* Check overflow random sockets too. */
for (rfl = daemon->rfl_poll; rfl; rfl = rfl->next)
poll_listen(rfl->rfd->fd, POLLIN);
for (listener = daemon->listeners; listener; listener = listener->next) for (listener = daemon->listeners; listener; listener = listener->next)
{ {
/* only listen for queries if we have resources */ /* only listen for queries if we have resources */
if (listener->fd != -1 && wait == 0) if (listener->fd != -1 && wait == 0)
poll_listen(listener->fd, POLLIN); poll_listen(listener->fd, POLLIN);
/* death of a child goes through the select loop, so /* death of a child goes through the select loop, so
we don't need to explicitly arrange to wake up here */ we don't need to explicitly arrange to wake up here */
if (listener->tcpfd != -1) if (listener->tcpfd != -1)
skipping to change at line 1734 skipping to change at line 1753
if (daemon->tcp_pipes[i] != -1) if (daemon->tcp_pipes[i] != -1)
poll_listen(daemon->tcp_pipes[i], POLLIN); poll_listen(daemon->tcp_pipes[i], POLLIN);
return wait; return wait;
} }
static void check_dns_listeners(time_t now) static void check_dns_listeners(time_t now)
{ {
struct serverfd *serverfdp; struct serverfd *serverfdp;
struct listener *listener; struct listener *listener;
struct randfd_list *rfl;
int i; int i;
int pipefd[2]; int pipefd[2];
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next) for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
if (poll_check(serverfdp->fd, POLLIN)) if (poll_check(serverfdp->fd, POLLIN))
reply_query(serverfdp->fd, serverfdp->source_addr.sa.sa_family, now); reply_query(serverfdp->fd, now);
if (daemon->port != 0 && !daemon->osport) for (i = 0; i < daemon->numrrand; i++)
for (i = 0; i < RANDOM_SOCKS; i++) if (daemon->randomsocks[i].refcount != 0 &&
if (daemon->randomsocks[i].refcount != 0 && poll_check(daemon->randomsocks[i].fd, POLLIN))
poll_check(daemon->randomsocks[i].fd, POLLIN)) reply_query(daemon->randomsocks[i].fd, now);
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now
); /* Check overflow random sockets too. */
for (rfl = daemon->rfl_poll; rfl; rfl = rfl->next)
if (poll_check(rfl->rfd->fd, POLLIN))
reply_query(rfl->rfd->fd, now);
/* Races. The child process can die before we read all of the data from the /* Races. The child process can die before we read all of the data from the
pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
process, and tcp_pipes to -1 and close the FD when we read the last process, and tcp_pipes to -1 and close the FD when we read the last
of the data - indicated by cache_recv_insert returning zero. of the data - indicated by cache_recv_insert returning zero.
The order of these events is indeterminate, and both are needed The order of these events is indeterminate, and both are needed
to free the process slot. Once the child process has gone, poll() to free the process slot. Once the child process has gone, poll()
returns POLLHUP, not POLLIN, so have to check for both here. */ returns POLLHUP, not POLLIN, so have to check for both here. */
if (!option_bool(OPT_DEBUG)) if (!option_bool(OPT_DEBUG))
for (i = 0; i < MAX_PROCS; i++) for (i = 0; i < MAX_PROCS; i++)
 End of changes. 8 change blocks. 
12 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)