summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nfsd
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-02-14 01:25:14 +0000
committerdelphij <delphij@FreeBSD.org>2013-02-14 01:25:14 +0000
commit236389d4e1b113bad02d1341c69f20ff70b57350 (patch)
treed8bd0da5357ccfb33c62e1ef4fcaa5ff271046da /usr.sbin/nfsd
parent7c3bad234976947db9f526e1b3b2e174c3fad149 (diff)
downloadFreeBSD-src-236389d4e1b113bad02d1341c69f20ff70b57350.zip
FreeBSD-src-236389d4e1b113bad02d1341c69f20ff70b57350.tar.gz
Abstract out setting of nfsdcnt and consistently use MAXNFSDCNT when the
proposed value is too high and DEFNFSDCNT when proposed value is too low. MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/nfsd')
-rw-r--r--usr.sbin/nfsd/nfsd.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index 7f7a245..3fa267c 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -119,6 +119,7 @@ static void usage(void);
static void open_stable(int *, int *);
static void copy_stable(int, int);
static void backup_stable(int);
+static void set_nfsdcnt(int);
/*
* Nfs server daemon mostly just a user context for nfssvc()
@@ -178,8 +179,7 @@ main(int argc, char **argv)
bindanyflag = 1;
break;
case 'n':
- nfsdcnt_set = 1;
- nfsdcnt = atoi(optarg);
+ set_nfsdcnt(atoi(optarg));
break;
case 'h':
bindhostc++;
@@ -235,15 +235,8 @@ main(int argc, char **argv)
*/
if (argc > 1)
usage();
- if (argc == 1) {
- nfsdcnt_set = 1;
- nfsdcnt = atoi(argv[0]);
- if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
- warnx("nfsd count %d; reset to %d", nfsdcnt,
- DEFNFSDCNT);
- nfsdcnt = DEFNFSDCNT;
- }
- }
+ if (argc == 1)
+ set_nfsdcnt(atoi(argv[0]));
/*
* Unless the "-o" option was specified, try and run "nfsd".
@@ -429,16 +422,6 @@ main(int argc, char **argv)
}
if (!new_syscall) {
- if (nfsdcnt < 1) {
- warnx("nfsd count too low %d; reset to %d", nfsdcnt,
- DEFNFSDCNT);
- nfsdcnt = DEFNFSDCNT;
- }
- if (nfsdcnt > MAXNFSDCNT) {
- warnx("nfsd count too high %d; reset to %d", nfsdcnt,
- DEFNFSDCNT);
- nfsdcnt = MAXNFSDCNT;
- }
/* If we use UDP only, we start the last server below. */
srvcnt = tcpflag ? nfsdcnt : nfsdcnt - 1;
for (i = 0; i < srvcnt; i++) {
@@ -891,6 +874,23 @@ setbindhost(struct addrinfo **ai, const char *bindhost, struct addrinfo hints)
}
static void
+set_nfsdcnt(int proposed)
+{
+
+ if (proposed < 1) {
+ warnx("nfsd count too low %d; reset to %d", proposed,
+ DEFNFSDCNT);
+ nfsdcnt = DEFNFSDCNT;
+ } else if (proposed > MAXNFSDCNT) {
+ warnx("nfsd count too high %d; truncated to %d", proposed,
+ MAXNFSDCNT);
+ nfsdcnt = MAXNFSDCNT;
+ } else
+ nfsdcnt = proposed;
+ nfsdcnt_set = 1;
+}
+
+static void
usage(void)
{
(void)fprintf(stderr, "%s", getopt_usage);
OpenPOWER on IntegriCloud