🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #253

Inefficiency in serve.c

#253
From: Jerry Aguirre
Date: Fri, 28 Jul 1989 19:59
53 lines
1904 bytes
I notice that the following code in server/serve.c seems less than
optimal:

	if (space() < 0 && !canpost ) {
		printf("%d %s NNTP server out of space. Try later.\r\n",
			ERR_GOODBYE, host);
		(void) fflush(stdout);
#ifdef LOG
		syslog(LOG_INFO, "%s no space", hostname);
#endif
		exit(1);
	}

Notice that it is checking space() first and then "!canpost".  As
"canpost" is a simple variable it is going to require a lot less
overhead to test it.  If "canpost" is false then there should be no
reason to check space.

What this means is unnecessary overhead in starting up NNTP servers for
readers.  I would suggest reversing the test to:

	if (!canpost && space() < 0) {

Interestingly this doesn't test if there is space available but rather
whether the space command can find if there is space available.  Another
interesting bit of code is the "space()" command itself which returns a
long value recast to an int.  Not exactly portable to systems with 16
bit ints.

	int
	space()
	{
	    long room_for_news, dfree();

	    room_for_news = dfree(SPOOLDIR);
	    if (room_for_news < MINFREE)
		return(room_for_news);

	    return(0);
	}


I would suggest changing its code to:

	    if (room_for_news < MINFREE) {
		if (room_for_news < 0) return(-1);
		return(1);
	    }
	    return(0);

In the interests of portability.
				Jerry
Technical Details
Message-ID: <45620@oliveb.olivetti.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!purdue!ames!oliveb!olivey!jerry

Show Full Headers
Complete Article Headers
Message-ID: <45620@oliveb.olivetti.com>
Subject: Inefficiency in serve.c
Date: Fri, 28 Jul 1989 19:59:26 +0000
From: jerry@olivey.olivetti.com (Jerry Aguirre)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!purdue!ames!oliveb!olivey!jerry
Newsgroups: news.software.nntp
Sender: news@oliveb.olivetti.com
Lines: 52