diff options
author | peter <peter@FreeBSD.org> | 1997-10-10 09:28:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-10-10 09:28:38 +0000 |
commit | 017c612e631166a1e7846b1bc4c174f13782bf45 (patch) | |
tree | 2e3475fe6b045cf1062757888ca973650e04f0a8 /usr.sbin/pppd/main.c | |
parent | 5f527a96c0db9dd8711084ae6f1c1f3dc18456bf (diff) | |
download | FreeBSD-src-017c612e631166a1e7846b1bc4c174f13782bf45.zip FreeBSD-src-017c612e631166a1e7846b1bc4c174f13782bf45.tar.gz |
Revive the connect-max-attempts option. When running in persist mode,
this limits the number of retries before aborting. This can save
expensive phone bills. :-) See rev 1.6 of main.c for original.
Diffstat (limited to 'usr.sbin/pppd/main.c')
-rw-r--r-- | usr.sbin/pppd/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c index 916bd24..a54c22e 100644 --- a/usr.sbin/pppd/main.c +++ b/usr.sbin/pppd/main.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.13 1997/08/19 17:52:43 peter Exp $"; +static char rcsid[] = "$Id: main.c,v 1.14 1997/08/22 12:03:55 peter Exp $"; #endif #include <stdio.h> @@ -175,6 +175,7 @@ main(argc, argv) sigset_t mask; struct protent *protp; struct stat statbuf; + int connect_attempts = 0; phase = PHASE_INITIALIZE; p = ttyname(0); @@ -472,6 +473,7 @@ main(argc, argv) if (device_script(connector, ttyfd, ttyfd) < 0) { syslog(LOG_ERR, "Connect script failed"); setdtr(ttyfd, FALSE); + connect_attempts++; goto fail; } @@ -479,6 +481,8 @@ main(argc, argv) sleep(1); /* give it time to set up its terminal */ } + connect_attempts = 0; /* we made it through ok */ + /* set line speed, flow control, etc.; clear CLOCAL if modem option */ set_up_tty(ttyfd, 0); @@ -487,7 +491,8 @@ main(argc, argv) while ((i = open(devnam, O_RDWR)) < 0) { if (errno != EINTR) syslog(LOG_ERR, "Failed to reopen %s: %m", devnam); - if (!persist || errno != EINTR || hungup || kill_link) + if (!persist || errno != EINTR || + hungup || kill_link) goto fail; } close(i); @@ -602,6 +607,11 @@ main(argc, argv) iffilename[0] = 0; } + /* limit to retries? */ + if (max_con_attempts) + if (connect_attempts >= max_con_attempts) + break; + if (!persist) break; |