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?
This commit is contained in:
parent
41212cf265
commit
83f31ab169
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30407
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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) {
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user