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 | |
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')
-rw-r--r-- | usr.sbin/lpr/common_source/common.c | 1 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/displayq.c | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/lp.h | 1 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/lp.local.h | 1 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/rmjob.c | 15 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 17 | ||||
-rw-r--r-- | usr.sbin/lpr/lpr/printcap.5 | 3 | ||||
-rw-r--r-- | usr.sbin/lpr/runqueue/printjob.c | 17 |
8 files changed, 56 insertions, 3 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index b7960c2..7301e2b 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -64,6 +64,7 @@ static char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95"; char *AF; /* accounting file */ long BR; /* baud rate if lp is a tty */ char *CF; /* name of cifplot filter (per job) */ +long CT; /* TCP connection timeout */ char *DF; /* name of tex filter (per job) */ long DU; /* daeomon user-id */ char *FF; /* form feed string */ diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index 4e5f060..2903084 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -112,6 +112,8 @@ displayq(format) LO = DEFLOCK; if (cgetstr(bp, "st", &ST) < 0) ST = DEFSTAT; + if (cgetnum(bp, "ct", &CT) < 0) + CT = DEFTIMEOUT; cgetstr(bp, "rm", &RM); if ((cp = checkremote())) printf("Warning: %s\n", cp); @@ -237,7 +239,7 @@ displayq(format) } strcat(line, "\n"); savealrm = signal(SIGALRM, alarmhandler); - alarm(10); + alarm(CT); fd = getport(RM, 0); (void)signal(SIGALRM, savealrm); if (fd < 0) { diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index 5fdd7c5..816e652 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -41,6 +41,7 @@ extern char *AF; /* accounting file */ extern long BR; /* baud rate if lp is a tty */ extern char *CF; /* name of cifplot filter (per job) */ +extern long CT; /* TCP connection timeout */ extern char *DF; /* name of tex filter (per job) */ extern long DU; /* daeomon user-id */ extern char *FF; /* form feed string */ diff --git a/usr.sbin/lpr/common_source/lp.local.h b/usr.sbin/lpr/common_source/lp.local.h index 837fd2f..bc60549 100644 --- a/usr.sbin/lpr/common_source/lp.local.h +++ b/usr.sbin/lpr/common_source/lp.local.h @@ -49,6 +49,7 @@ #define DEFWIDTH 132 #define DEFLENGTH 66 #define DEFUID 1 +#define DEFTIMEOUT 120 /* * When files are created in the spooling area, they are normally diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index 32e13d4..256da3f 100644 --- a/usr.sbin/lpr/common_source/rmjob.c +++ b/usr.sbin/lpr/common_source/rmjob.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id$"; + "$Id: rmjob.c,v 1.9 1997/09/24 06:47:31 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -67,6 +67,7 @@ static char current[40]; /* active control file name */ extern uid_t uid, euid; /* real and effective user id's */ +static void alarmhandler __P((int)); static void do_unlink __P((char *)); void @@ -91,6 +92,8 @@ rmjob() SD = _PATH_DEFSPOOL; if (cgetstr(bp,"lo", &LO) < 0) LO = DEFLOCK; + if (cgetnum(bp, "ct", &CT) < 0) + CT = DEFTIMEOUT; cgetstr(bp, "rm", &RM); if ((cp = checkremote())) printf("Warning: %s\n", cp); @@ -317,6 +320,7 @@ rmremote() register char *cp; register int i, rem; char buf[BUFSIZ]; + void (*savealrm)(int); if (!remote) return; /* not sending to a remote machine */ @@ -339,7 +343,10 @@ rmremote() (void) sprintf(cp, " %d", requ[i]); } strcat(cp, "\n"); + savealrm = signal(SIGALRM, alarmhandler); + alarm(CT); rem = getport(RM, 0); + (void)signal(SIGALRM, savealrm); if (rem < 0) { if (from != host) printf("%s: ", host); @@ -363,3 +370,9 @@ iscf(d) { return(d->d_name[0] == 'c' && d->d_name[1] == 'f'); } + +void +alarmhandler(signo) +{ + /* ignored */ +} 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 */ +} diff --git a/usr.sbin/lpr/lpr/printcap.5 b/usr.sbin/lpr/lpr/printcap.5 index abab5bb..ee2e768 100644 --- a/usr.sbin/lpr/lpr/printcap.5 +++ b/usr.sbin/lpr/lpr/printcap.5 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)printcap.5 8.2 (Berkeley) 12/11/93 -.\" $Id: printcap.5,v 1.10 1997/04/12 04:23:02 brian Exp $ +.\" $Id: printcap.5,v 1.11 1997/05/08 15:31:39 joerg Exp $ .\" .Dd December 11, 1993 .Dt PRINTCAP 5 @@ -78,6 +78,7 @@ for a description of the file layout. .Pf ( Xr ioctl 2 call) .It "cf str" Ta Dv NULL Ta No "cifplot data filter" +.It "ct num 120 TCP connection timeout in seconds" .It "df str" Ta Dv NULL Ta No "tex data filter" .Pf ( Tn DVI format) diff --git a/usr.sbin/lpr/runqueue/printjob.c b/usr.sbin/lpr/runqueue/printjob.c index b40a06d..8a2835b 100644 --- a/usr.sbin/lpr/runqueue/printjob.c +++ b/usr.sbin/lpr/runqueue/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 */ +} |