Article View: net.bugs.2bsd
Article #199ttyslot speedup for login, wall, passwd
From: eric j. haug
Date: Thu, 07 Feb 1985 00:31
Date: Thu, 07 Feb 1985 00:31
134 lines
2835 bytes
2835 bytes
Subject: ttyslot speedup
Index: <src/lib/c/gen>/<ttyslot.c> 2.9bsd
Description:
A subfunction of ttyslot reads /etc/ttys a character at a time,
using a system call per character.
Repeat-By:
Observation.
Fix:
How about ....
Side effect -- slightly larger versions of login, wall, and passwd.
*** ttyslot.c~ Wed Feb 6 17:56:55 1985
--- ttyslot.c Wed Feb 6 16:51:57 1985
***************
*** 27,28
register char *tp, *p;
register s, tf;
--- 27,29 -----
register char *tp, *p;
+ #ifdef SLOWGETTTYS
register s, tf;
***************
*** 28,29
register s, tf;
--- 29,34 -----
register s, tf;
+ #else
+ register s;
+ FILE *tf;
+ #endif
***************
*** 35,36
p++;
if ((tf=open(ttys, 0)) < 0)
--- 40,42 -----
p++;
+ #ifdef SLOWGETTTYS
if ((tf=open(ttys, 0)) < 0)
***************
*** 36,37
if ((tf=open(ttys, 0)) < 0)
return(0);
--- 42,46 -----
if ((tf=open(ttys, 0)) < 0)
+ #else
+ if ((tf=fopen(ttys, "r")) == (FILE *)NULL)
+ #endif
return(0);
***************
*** 41,42
if (strcmp(p, tp)==0) {
close(tf);
--- 50,52 -----
if (strcmp(p, tp)==0) {
+ #ifdef SLOWGETTTYS
close(tf);
***************
*** 42,43
close(tf);
return(s);
--- 52,56 -----
close(tf);
+ #else
+ fclose(tf);
+ #endif
return(s);
***************
*** 45,46
}
close(tf);
--- 58,60 -----
}
+ #ifdef SLOWGETTTYS
close(tf);
***************
*** 46,47
close(tf);
return(0);
--- 60,64 -----
close(tf);
+ #else
+ fclose(tf);
+ #endif
return(0);
***************
*** 48,49
}
static char *
--- 65,67 -----
}
+ #ifdef SLOWGETTTYS
static char *
***************
*** 74
}
--- 92,117 -----
}
+ #else
+
+ static char *
+ getttys(f)
+ FILE *f;
+ {
+ static char line[DIRSIZ + 4];
+ register char *lp;
+ register char *lb;
+ char lbuf[132];
+
+ lp = line;
+ lb = lbuf;
+ fgets(lbuf, sizeof(lbuf), f);
+ if ( feof(f) || ferror(f) )
+ return((char *)NULL);
+ while (!(*lb=='\t'||*lb==' '||*lb=='\n'||lp >= &line[sizeof(line)]))
+ *lp++ = *lb++;
+ *lp = '\000';
+ if ( lp <= &line[2])
+ return((char *)NULL);
+ else
+ return(&line[2]);
+ }
+ #endif
Technical Details
Message-ID:
<110@slu70.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!mgnetp!we53!busch!wucs!slu70!ejhShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site slu70.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!mgnetp!we53!busch!wucs!slu70!ejh From: ejh@slu70.UUCP (eric j. haug) Newsgroups: net.bugs.2bsd Subject: ttyslot speedup for login, wall, passwd Message-ID: <110@slu70.UUCP> Date: Wed, 6-Feb-85 19:31:45 EST Article-I.D.: slu70.110 Posted: Wed Feb 6 19:31:45 1985 Date-Received: Sat, 9-Feb-85 05:50:45 EST Distribution: net Organization: Saint Louis Univ.,St. L.,MO. Lines: 134