Article View: news.software.nntp
Article #35206nnrpd daemon (-D) mode fixes
From: bill davidsen
Date: Fri, 05 Feb 1999 00:00
Date: Fri, 05 Feb 1999 00:00
132 lines
4527 bytes
4527 bytes
There are performance and memory benefits from running nnrpd as a daemon
instead of letting innd start readers, particularly on machines with
moderate to heavy (1k+) readers.
This patch addresses one bug (wrong data type) and one missing feature
(nicekids). The type was a struct defined as sockaddr_in and used with a
case where sockaddr was required. Because I'm not sure all systems will
have the same size for both, and my compiler whines about the original,
I defined the value correctly and dropped the cast.
When running from innd, a nice() value is gotten from the nicekids value
in inn.conf. In daemon mode that wasn't being done, so I added the code
here. Note: you do *not* want to just start the daemon niced, as it will
then open sockets more slowly (I measured with NSLG). Nicekids is the
way to go here.
Patch against 2.2 release.
================================================================
*** nnrpd.c 1998/11/15 22:45:15 1.1
--- nnrpd.c 1999/02/01 21:29:22
***************
*** 1,6 ****
! /* $Revision: 1.1 $
**
** NNTP server for readers (NNRP) for InterNetNews.
** This server doesn't do any real load-limiting, except for what has
** proven empirically necesary (i.e., look at GRPscandir).
*/
--- 1,6 ----
! /* $Revision: 1.4 $
**
** NNTP server for readers (NNRP) for InterNetNews.
** This server doesn't do any real load-limiting, except for what has
** proven empirically necesary (i.e., look at GRPscandir).
*/
***************
*** 771,781 ****
struct timeval tv;
unsigned short ListenPort = NNTP_PORT;
unsigned long ListenAddr = htonl(INADDR_ANY);
int lfd, fd;
ARGTYPE clen;
! struct sockaddr_in ssa, csa;
struct stat Sb;
PID_T pid = -1;
GID_T NewsGID;
UID_T NewsUID;
int one = 1;
--- 771,782 ----
struct timeval tv;
unsigned short ListenPort = NNTP_PORT;
unsigned long ListenAddr = htonl(INADDR_ANY);
int lfd, fd;
ARGTYPE clen;
! struct sockaddr_in ssa;
! struct sockaddr csa;
struct stat Sb;
PID_T pid = -1;
GID_T NewsGID;
UID_T NewsUID;
int one = 1;
***************
*** 936,950 ****
(void)signal(SIGCHLD, WaitChild);
SetupDaemon();
TITLEset("nnrpd: accepting connections");
! listen(lfd, 5);
listen_loop:
clen = sizeof(csa);
! fd = accept(lfd, (struct sockaddr *) &csa, &clen);
if (fd < 0)
goto listen_loop;
for (i = 0; (pid = fork()) < 0; i++) {
if (i == MAX_FORKS) {
--- 937,951 ----
(void)signal(SIGCHLD, WaitChild);
SetupDaemon();
TITLEset("nnrpd: accepting connections");
! listen(lfd, 5);
listen_loop:
clen = sizeof(csa);
! fd = accept(lfd, &csa, &clen);
if (fd < 0)
goto listen_loop;
for (i = 0; (pid = fork()) < 0; i++) {
if (i == MAX_FORKS) {
***************
*** 966,978 ****
dup2(fd, 0);
close(fd);
dup2(0, 1);
dup2(0, 2);
/* Only automatically reap children in the listening process */
(void)signal(SIGCHLD, SIG_DFL);
-
} else {
SetupDaemon();
}/* DaemonMode */
/* Setup. */
--- 967,984 ----
dup2(fd, 0);
close(fd);
dup2(0, 1);
dup2(0, 2);
+ /* if we are a daemon innd didn't make us nice, so be nice kids */
+ if (innconf->nicekids) {
+ if (nice(innconf->nicekids) < 0)
+ syslog(L_ERROR, "Could not nice child to %d: %m", innconf->nicekids);
+ }
+
/* Only automatically reap children in the listening process */
(void)signal(SIGCHLD, SIG_DFL);
} else {
SetupDaemon();
}/* DaemonMode */
/* Setup. */
Technical Details
Message-ID:
<79eufj$7nh0$1@newssvr04-int.news.prodigy.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <79eufj$7nh0$1@newssvr04-int.news.prodigy.com> Subject: nnrpd daemon (-D) mode fixes Date: Fri, 05 Feb 1999 00:00:00 +0000 From: davidsen@tmr.com (bill davidsen) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 440998604 X-Auth-User: 000000000/92cfe4abc0810726 X-Post-Time: 5 Feb 1999 14:16:19 GMT Organization: TMR Associates, Schenectady NY X-Problems-To: abuse@prodigy.net Newsgroups: news.software.nntp Originator: davidsen@darkstar.prodigy.com