Explain "-c" option more exactly and state the default in the man

page.

Add ability to run "inetd -R 0" to disable the default connection
per minute limit of 256 connections. Document this in man page.

Don't use maxchild as a boolean - instead check if it is greater
than zero.

Reviewed by:	sheldonh
Based on a patch by:	Alexander Langer <alex@big.endian.de>
This commit is contained in:
David Malone 2000-08-03 15:45:38 +00:00
parent 2968046ea1
commit 1b65d153ee
2 changed files with 13 additions and 8 deletions

View File

@ -89,7 +89,9 @@ section for more information on TCP Wrappers support.
Turn on TCP Wrapping for internal services which are built in to
.Nm inetd .
.It Fl c Ar maximum
Specify the default maximum number of services that can be invoked.
Specify the default maximum number of
simultaneous invocations of each service;
the default is unlimited.
May be overridden on a per-service basis with the "max-child"
parameter.
.It Fl C Ar rate
@ -100,6 +102,7 @@ May be overridden on a per-service basis with the
.It Fl R Ar rate
Specify the maximum number of times a service can be invoked
in one minute; the default is 256.
A rate of 0 allows an unlimited number of invocations.
.It Fl a
Specify a specific IP address to bind to.
Alternatively, a hostname can be specified,

View File

@ -191,7 +191,9 @@ static const char rcsid[] =
< 0 = no limit */
#endif
#ifndef TOOMANY
#define TOOMANY 256 /* don't start more than TOOMANY */
#endif
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
#define RETRYTIME (60*10) /* retry after bind or server fail */
#define MAX_MAXCHLD 32767 /* max allowable max children */
@ -247,7 +249,7 @@ getvalue(arg, value, whine)
char *p;
tmp = strtol(arg, &p, 0);
if (tmp < 1 || *p) {
if (tmp < 0 || *p) {
syslog(LOG_ERR, whine, arg);
return 1; /* failure */
}
@ -590,7 +592,7 @@ main(argc, argv, envp)
if (dofork) {
if (sep->se_count++ == 0)
(void)gettimeofday(&sep->se_time, (struct timezone *)NULL);
else if (sep->se_count >= toomany) {
else if (toomany > 0 && sep->se_count >= toomany) {
struct timeval now;
(void)gettimeofday(&now, (struct timezone *)NULL);
@ -795,6 +797,8 @@ void flag_signal(c)
void
addchild(struct servtab *sep, pid_t pid)
{
if (sep->se_maxchild <= 0)
return;
#ifdef SANITY_CHECK
if (sep->se_numchild >= sep->se_maxchild) {
syslog(LOG_ERR, "%s: %d >= %d",
@ -802,8 +806,6 @@ addchild(struct servtab *sep, pid_t pid)
exit(EX_SOFTWARE);
}
#endif
if (sep->se_maxchild == 0)
return;
sep->se_pids[sep->se_numchild++] = pid;
if (sep->se_numchild == sep->se_maxchild)
disable(sep);
@ -906,7 +908,7 @@ void config()
sep->se_reset = 1;
}
/* copy over outstanding child pids */
if (sep->se_maxchild && new->se_maxchild) {
if (sep->se_maxchild > 0 && new->se_maxchild > 0) {
new->se_numchild = sep->se_numchild;
if (new->se_numchild > new->se_maxchild)
new->se_numchild = new->se_maxchild;
@ -919,7 +921,7 @@ void config()
sep->se_maxcpm = new->se_maxcpm;
/* might need to turn on or off service now */
if (sep->se_fd >= 0) {
if (sep->se_maxchild
if (sep->se_maxchild > 0
&& sep->se_numchild == sep->se_maxchild) {
if (FD_ISSET(sep->se_fd, &allsock))
disable(sep);
@ -1718,7 +1720,7 @@ getconfigent()
else
sep->se_maxchild = 1;
}
if (sep->se_maxchild) {
if (sep->se_maxchild > 0) {
sep->se_pids = malloc(sep->se_maxchild * sizeof(*sep->se_pids));
if (sep->se_pids == NULL) {
syslog(LOG_ERR, "malloc: %m");