From: Paul Mackerras Date: Mon, 23 Jun 2008 11:44:06 +0000 (+0000) Subject: Flush the tty when welcomer or connector fails X-Git-Tag: ppp-2.4.7~81 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=8f09debe1ccab6c267f1d803bfa6facdd30b56e0 Flush the tty when welcomer or connector fails This avoids having the tcsetsf and the close of the tty device block for long periods waiting for output to drain, as can happen if for instance the serial port is in CRTSCTS mode and CTS is negated. --- diff --git a/pppd/tty.c b/pppd/tty.c index c356483..a9832d9 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -68,12 +68,13 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: tty.c,v 1.25 2006/06/04 07:04:57 paulus Exp $" +#define RCSID "$Id: tty.c,v 1.26 2008/06/23 11:44:06 paulus Exp $" #include #include #include #include +#include #include #include #include @@ -688,11 +689,11 @@ int connect_tty() if (device_script(initializer, ttyfd, ttyfd, 0) < 0) { error("Initializer script failed"); status = EXIT_INIT_FAILED; - goto errret; + goto errretf; } if (got_sigterm) { disconnect_tty(); - goto errret; + goto errretf; } info("Serial port initialized."); } @@ -701,11 +702,11 @@ int connect_tty() if (device_script(connector, ttyfd, ttyfd, 0) < 0) { error("Connect script failed"); status = EXIT_CONNECT_FAILED; - goto errret; + goto errretf; } if (got_sigterm) { disconnect_tty(); - goto errret; + goto errretf; } info("Serial connection established."); } @@ -754,6 +755,9 @@ int connect_tty() return ttyfd; + errretf: + if (real_ttyfd >= 0) + tcflush(real_ttyfd, TCIOFLUSH); errret: if (pty_master >= 0) { close(pty_master); @@ -941,7 +945,7 @@ start_charshunt(ifd, ofd) exit(0); } charshunt_pid = cpid; - record_child(cpid, "pppd (charshunt)", charshunt_done, NULL); + record_child(cpid, "pppd (charshunt)", charshunt_done, NULL, 1); return 1; }