[net.bugs.uucp] inefficient calloks in gnsys

henry (06/11/82)

The gnsys() routine in uucico calls callok() on every file it finds
when looking for callable systems.  Not only is it inefficient to
call callok() once per file rather than once per system, but it can
produce a revolting number of log messages from callok when a system
with a lot of traffic waiting is uncallable.  It is not hard to fix
this, by maintaining a list of unavailable systems.  Here is a diff on
gnsys.c;  beware that line numbers may not match the V7 distribution,
so don't apply this blindly.

32,33c32,36
< 	char sysname[NAMESIZE], filename[NAMESIZE];
< 	FILE *fp;
---
> 	char *unavail[LSIZE];
> 	int nunavail = 0;
> 	char sysname[NAMESIZE], filename[NAMESIZE];
> 	FILE *fp;
> 	extern char *calloc();
56,57c59,72
< 			if (callok(sysname) == 0)
< 				nitem = srchst(sysname, list, nitem);
---
> 			for (i = 0; i < nunavail; i++)
> 				if (strcmp(sysname, unavail[i]) == 0)
> 					break;
> 			if (i < nunavail)
> 				continue;
> 			if (callok(sysname) == 0)
> 				nitem = srchst(sysname, list, nitem);
> 			else if (nunavail < LSIZE) {
> 				p1 = calloc((unsigned)strlen(sysname)+1, sizeof(char));
> 				if (p1 != NULL) {
> 					strcpy(p1, sysname);
> 					unavail[nunavail++] = p1;
> 				}
> 			}
60a76,78	/* just before the fclose -- HS */
> 		for (i = 0; i < nunavail; i++)
> 			if (unavail[i] != NULL)
> 				free(unavail[i]);