@dl12345
Ok.. So. Changes for dnsmasq
. I'm currently testing to see if it dies, but it'll take a few days now that I'm stablized, but these are the changes that'll need to go into the PR you put up.
Patch to fix the dnsmasq init service
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -937,6 +937,8 @@
append_parm "$cfg" "maxport" "--max-port"
append_parm "$cfg" "domain" "--domain"
append_parm "$cfg" "local" "--local"
+ append_parm "$cfg" "maxprocs" "--max-procs"
+
config_list_foreach "$cfg" "listen_address" append_listenaddress
config_list_foreach "$cfg" "server" append_server
config_list_foreach "$cfg" "rev_server" append_rev_server
--- a/package/network/services/dnsmasq/files/dhcp.conf
+++ b/package/network/services/dnsmasq/files/dhcp.conf
@@ -21,6 +21,7 @@
#list bogusnxdomain '64.94.110.11'
option localservice 1 # disable to allow DNS requests from non-local subnets
option ednspacket_max 1232
+ option maxprocs 1 # Max Forked Processes
config dhcp lan
option interface lan
package/network/services/dnsmasq/patches/200-fix_max_procs.patch
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -1036,7 +1036,7 @@ int main (int argc, char **argv)
pid = getpid();
daemon->pipe_to_parent = -1;
- for (i = 0; i < MAX_PROCS; i++)
+ for (i = 0; i < daemon->max_procs; i++)
daemon->tcp_pipes[i] = -1;
#ifdef HAVE_INOTIFY
@@ -1497,7 +1497,7 @@ static void async_event(int pipe, time_t
break;
}
else
- for (i = 0 ; i < MAX_PROCS; i++)
+ for (i = 0 ; i < daemon->max_procs; i++)
if (daemon->tcp_pids[i] == p)
daemon->tcp_pids[i] = 0;
break;
@@ -1561,7 +1561,7 @@ static void async_event(int pipe, time_t
case EVENT_TERM:
/* Knock all our children on the head. */
- for (i = 0; i < MAX_PROCS; i++)
+ for (i = 0; i < daemon->max_procs; i++)
if (daemon->tcp_pids[i] != 0)
kill(daemon->tcp_pids[i], SIGALRM);
@@ -1732,7 +1732,7 @@ static void set_dns_listeners(void)
poll_listen(rfl->rfd->fd, POLLIN);
/* check to see if we have free tcp process slots. */
- for (i = MAX_PROCS - 1; i >= 0; i--)
+ for (i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
break;
@@ -1756,7 +1756,7 @@ static void set_dns_listeners(void)
}
if (!option_bool(OPT_DEBUG))
- for (i = 0; i < MAX_PROCS; i++)
+ for (i = 0; i < daemon->max_procs; i++)
if (daemon->tcp_pipes[i] != -1)
poll_listen(daemon->tcp_pipes[i], POLLIN);
}
@@ -1791,7 +1791,7 @@ static void check_dns_listeners(time_t n
to free the process slot. Once the child process has gone, poll()
returns POLLHUP, not POLLIN, so have to check for both here. */
if (!option_bool(OPT_DEBUG))
- for (i = 0; i < MAX_PROCS; i++)
+ for (i = 0; i < daemon->max_procs; i++)
if (daemon->tcp_pipes[i] != -1 &&
poll_check(daemon->tcp_pipes[i], POLLIN | POLLHUP) &&
!cache_recv_insert(now, daemon->tcp_pipes[i]))
@@ -1815,7 +1815,7 @@ static void check_dns_listeners(time_t n
at least one a poll() time, that we still do.
There may be more waiting connections after
poll() returns then free process slots. */
- for (i = MAX_PROCS - 1; i >= 0; i--)
+ for (i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
break;
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -1240,6 +1240,9 @@ extern struct daemon {
/* file for packet dumps. */
int dumpfd;
#endif
+
+ /* maximum number of child processes to fork */
+ unsigned int max_procs;
} *daemon;
/* cache.c */
--- a/src/option.c
+++ b/src/option.c
@@ -174,7 +174,8 @@ struct myoption {
#define LOPT_CMARK_ALST_EN 365
#define LOPT_CMARK_ALST 366
#define LOPT_QUIET_TFTP 367
-
+#define LOPT_MAX_PROCS 368
+
#ifdef HAVE_GETOPT_LONG
static const struct option opts[] =
#else
@@ -351,8 +352,9 @@ static const struct myoption opts[] =
{ "dhcp-ignore-clid", 0, 0, LOPT_IGNORE_CLID },
{ "dynamic-host", 1, 0, LOPT_DYNHOST },
{ "log-debug", 0, 0, LOPT_LOG_DEBUG },
- { "umbrella", 2, 0, LOPT_UMBRELLA },
+ { "umbrella", 2, 0, LOPT_UMBRELLA },
{ "quiet-tftp", 0, 0, LOPT_QUIET_TFTP },
+ { "max-procs", 1, 0, LOPT_MAX_PROCS },
{ NULL, 0, 0, 0 }
};
@@ -539,8 +541,9 @@ static struct {
{ LOPT_SCRIPT_TIME, OPT_LEASE_RENEW, NULL, gettext_noop("Call dhcp-script when lease expiry changes."), NULL },
{ LOPT_UMBRELLA, ARG_ONE, "[=<optspec>]", gettext_noop("Send Cisco Umbrella identifiers including remote IP."), NULL },
{ LOPT_QUIET_TFTP, OPT_QUIET_TFTP, NULL, gettext_noop("Do not log routine TFTP."), NULL },
+ { LOPT_MAX_PROCS, ARG_ONE, "<number>", gettext_noop("Specify maximum number of child process to fork."), NULL },
{ 0, 0, NULL, NULL, NULL }
-};
+};
/* We hide metacharacters in quoted strings by mapping them into the ASCII control
character space. Note that the \0, \t \b \r \033 and \n characters are carefully placed in the
@@ -4800,7 +4803,12 @@ err:
break;
}
#endif
-
+ case LOPT_MAX_PROCS: /* --max-procs */
+ if (!atoi_check16(arg, &daemon->max_procs))
+ ret_err(gen_err);
+ if (daemon->max_procs > MAX_PROCS) daemon->max_procs = MAX_PROCS;
+ break;
+
default:
ret_err(_("unsupported option (check that dnsmasq was compiled with DHCP/TFTP/DNSSEC/DBus support)"));
@@ -5282,7 +5290,7 @@ void read_opts(int argc, char **argv, ch
daemon->soa_refresh = SOA_REFRESH;
daemon->soa_retry = SOA_RETRY;
daemon->soa_expiry = SOA_EXPIRY;
-
+ daemon->max_procs = MAX_PROCS;
#ifndef NO_ID
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
add_txt("authors.bind", "Simon Kelley", 0);