diff options
author | joerg <joerg@FreeBSD.org> | 1997-10-14 16:01:02 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1997-10-14 16:01:02 +0000 |
commit | fef7c77457bb37b4446a11916d0e18bfbed5fca8 (patch) | |
tree | 5f0c559d9ab9b959f3e9d5b41198a5706e25b662 /usr.sbin/lpr/lpd | |
parent | eadc6c642e65bfe3b9c54fbfbe4c9a1b569663a8 (diff) | |
download | FreeBSD-src-fef7c77457bb37b4446a11916d0e18bfbed5fca8.zip FreeBSD-src-fef7c77457bb37b4446a11916d0e18bfbed5fca8.tar.gz |
Improve my hack from rev 1.6 of displayq.c, and make the TCP
connection timeout controllable by a new printcap(5) capability named
`ct' (connectiom timeout), defaulting to 120 seconds (which is the
default TCP connection timeout).
Would anybody see a problem with merging all this into RELENG_2_2?
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index b40a06d..8a2835b 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -116,6 +116,7 @@ static char width[10] = "-w"; /* page width in static characters */ static char tfile[] = TFILENAME; /* file name for filter output */ static void abortpr __P((int)); +static void alarmhandler __P((int)); static void banner __P((char *, char *)); static int dofork __P((int)); static int dropit __P((int)); @@ -1350,6 +1351,8 @@ init() sprintf(&width[2], "%ld", PW); if (cgetnum(bp, "pl", &PL) < 0) PL = DEFLENGTH; + if (cgetnum(bp, "ct", &CT) < 0) + CT = DEFTIMEOUT; sprintf(&length[2], "%ld", PL); if (cgetnum(bp,"px", &PX) < 0) PX = 0; @@ -1455,6 +1458,7 @@ opennet(cp) register int i; int resp, port; char save_ch; + void (*savealrm)(int); save_ch = *cp; *cp = '\0'; @@ -1467,7 +1471,10 @@ opennet(cp) for (i = 1; ; i = i < 256 ? i << 1 : i) { resp = -1; + savealrm = signal(SIGALRM, alarmhandler); + alarm(CT); pfd = getport(cp, port); + (void)signal(SIGALRM, savealrm); if (pfd < 0 && errno == ECONNREFUSED) resp = 1; else if (pfd >= 0) { @@ -1527,10 +1534,14 @@ openrem() { register int i, n; int resp; + void (*savealrm)(int); for (i = 1; ; i = i < 256 ? i << 1 : i) { resp = -1; + savealrm = signal(SIGALRM, alarmhandler); + alarm(CT); pfd = getport(RM, 0); + (void)signal(SIGALRM, savealrm); if (pfd >= 0) { (void) snprintf(line, sizeof(line), "\2%s\n", RP); n = strlen(line); @@ -1655,3 +1666,9 @@ pstatus(msg, va_alist) (void) write(fd, buf, strlen(buf)); (void) close(fd); } + +void +alarmhandler(signo) +{ + /* ignored */ +} |