🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by Jerry Aguirre Fri, 28 Jul 1989 19:59
Inefficiency in serve.c
#253
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads