From owner-freebsd-bugs@FreeBSD.ORG Sat May 29 00:10:52 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9046616A4CE for ; Sat, 29 May 2004 00:10:52 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 72EED43D1D for ; Sat, 29 May 2004 00:10:52 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i4T7A9ks016897 for ; Sat, 29 May 2004 00:10:09 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i4T7A9xW016896; Sat, 29 May 2004 00:10:09 -0700 (PDT) (envelope-from gnats) Date: Sat, 29 May 2004 00:10:09 -0700 (PDT) Message-Id: <200405290710.i4T7A9xW016896@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Michael Conlen Subject: Re: bin/67317: patch to nfsd.c to make it slightly more dynamic X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Michael Conlen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 May 2004 07:10:52 -0000 The following reply was made to PR bin/67317; it has been noted by GNATS. From: Michael Conlen To: freebsd-gnats-submit@FreeBSD.org, meconlen@obfuscated.net Cc: Subject: Re: bin/67317: patch to nfsd.c to make it slightly more dynamic Date: Sat, 29 May 2004 03:01:13 -0400 Proper diffs. Forgot that the variables in the functions should be static, not sure how to test that properly, but I'd suspect a system might act funny when you tried to kill nfsd with the previous patch, until it segfaulted. This is the first C code I've done in six months, so look over it, though it seems to work fine on a system doing lots of volume. Cheers. 7a8,9 > * Modified by Michael Conlen May 28, 2004 > * 75a78,80 > > #include > 84d88 < #define MAXNFSDCNT 20 86,87d89 < pid_t children[MAXNFSDCNT]; /* PIDs of children */ < int nfsdcnt; /* number of children */ 91c93 < void killchildren(void); --- > void killchildren(int, ...); 94c96 < void reapchild(int); --- > void reapchild(int, ...); 139a142,143 > pid_t *children; > int nfsdcnt; 159,163d162 < if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { < warnx("nfsd count %d; reset to %d", nfsdcnt, < DEFNFSDCNT); < nfsdcnt = DEFNFSDCNT; < } 203,207d201 < if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { < warnx("nfsd count %d; reset to %d", nfsdcnt, < DEFNFSDCNT); < nfsdcnt = DEFNFSDCNT; < } 335a330,339 > > /* allocate children */ > children = calloc(nfsdcnt, sizeof(pid_t)); > if(children == NULL ) { > syslog(LOG_ERR, "malloc: %m"); > nfsd_exit(1); > } > reapchild(0, children, nfsdcnt); > killchildren(0, children, nfsdcnt); > 770,771c774 < reapchild(signo) < int signo; --- > reapchild(int signo, ...) 775a779,791 > va_list argp; > pid_t *children; > int nfsdcnt; > > if(signo == 0) { > va_start(argp, signo); > children = va_arg(argp, pid_t *); > nfsdcnt = va_arg(argp, int); > va_end(argp); > return; > } > > 791,792c807,809 < void < killchildren() --- > /* we need something before the ..., better hack than globals */ > > void killchildren(int signo, ...) 795a813,826 > > va_list argp; > pid_t *children; > int nfsdcnt; > > if(signo == 0) { > va_start(argp, signo); > children = va_arg(argp, pid_t *); > nfsdcnt = va_arg(argp, int); > va_end(argp); > return; > } > > 823c854 < killchildren(); --- > killchildren(0); 842a874 >