Date: Tue Feb 26 11:21:14 PST 2008
Files: unix/tclUnixChan.c
Related: 525783
Bugid: 1901828

--- unix/tclUnixChan.c.no-bad-tip35-flush.old	2008-01-08 11:41:24.000000000 -0800
+++ unix/tclUnixChan.c	2008-02-26 10:51:43.176536344 -0800
@@ -65,22 +65,6 @@
 #   define GETCONTROL(fd, intPtr)	ioctl((fd), TIOCMGET, (intPtr))
 #   define SETCONTROL(fd, intPtr)	ioctl((fd), TIOCMSET, (intPtr))
 
-    /*
-     * TIP #35 introduced a different on exit flush/close behavior that does
-     * not work correctly with standard channels on all systems. The problem
-     * is tcflush throws away waiting channel data. This may be necessary for
-     * true serial channels that may block, but isn't correct in the standard
-     * case. This might be replaced with tcdrain instead, but that can block.
-     * For now, we revert to making this do nothing, and TtyOutputProc being
-     * the same old FileOutputProc. - hobbs [Bug #525783]
-     */
-
-#   define BAD_TIP35_FLUSH 0
-#   if BAD_TIP35_FLUSH
-#	define TTYFLUSH(fd)		tcflush((fd), TCIOFLUSH);
-#   else
-#	define TTYFLUSH(fd)
-#   endif /* BAD_TIP35_FLUSH */
 #   ifdef FIONREAD
 #	define GETREADQUEUE(fd, int)	ioctl((fd), FIONREAD, &(int))
 #   elif defined(FIORDCHK)
@@ -282,10 +266,6 @@
 #endif /* DIRECT_BAUD */
 static FileState *	TtyInit(int fd, int initialize);
 static void		TtyModemStatusStr(int status, Tcl_DString *dsPtr);
-#if BAD_TIP35_FLUSH
-static int		TtyOutputProc(ClientData instanceData,
-			    const char *buf, int toWrite, int *errorCode);
-#endif /* BAD_TIP35_FLUSH */
 static int		TtyParseMode(Tcl_Interp *interp, const char *mode,
 			    int *speedPtr, int *parityPtr, int *dataPtr,
 			    int *stopPtr);
@@ -333,11 +313,7 @@
     TCL_CHANNEL_VERSION_5,	/* v5 channel */
     TtyCloseProc,		/* Close proc. */
     FileInputProc,		/* Input proc. */
-#if BAD_TIP35_FLUSH
-    TtyOutputProc,		/* Output proc. */
-#else /* !BAD_TIP35_FLUSH */
     FileOutputProc,		/* Output proc. */
-#endif /* BAD_TIP35_FLUSH */
     NULL,			/* Seek proc. */
     TtySetOptionProc,		/* Set option proc. */
     TtyGetOptionProc,		/* Get option proc. */
@@ -760,14 +736,6 @@
     ClientData instanceData,	/* Tty state. */
     Tcl_Interp *interp)		/* For error reporting - unused. */
 {
-#if BAD_TIP35_FLUSH
-    TtyState *ttyPtr = (TtyState *) instanceData;
-#endif /* BAD_TIP35_FLUSH */
-
-#ifdef TTYFLUSH
-    TTYFLUSH(ttyPtr->fs.fd);
-#endif /* TTYFLUSH */
-
 #if 0
     /*
      * TIP#35 agreed to remove the unsave so that TCL could be used as a
@@ -786,46 +754,6 @@
     return FileCloseProc(instanceData, interp);
 }
 
-/*
- *----------------------------------------------------------------------
- *
- * TtyOutputProc--
- *
- *	This function is invoked from the generic IO level to write output to
- *	a TTY channel.
- *
- * Results:
- *	The number of bytes written is returned or -1 on error. An output
- *	argument contains a POSIX error code if an error occurred, or zero.
- *
- * Side effects:
- *	Writes output on the output device of the channel if the channel is
- *	not designated to be closed.
- *
- *----------------------------------------------------------------------
- */
-
-#if BAD_TIP35_FLUSH
-static int
-TtyOutputProc(
-    ClientData instanceData,	/* File state. */
-    const char *buf,		/* The data buffer. */
-    int toWrite,		/* How many bytes to write? */
-    int *errorCodePtr)		/* Where to store error code. */
-{
-    if (TclInExit()) {
-	/*
-	 * Do not write data during Tcl exit. Serial port may block preventing
-	 * Tcl from exit.
-	 */
-
-	return toWrite;
-    }
-
-    return FileOutputProc(instanceData, buf, toWrite, errorCodePtr);
-}
-#endif /* BAD_TIP35_FLUSH */
-
 #ifdef USE_TERMIOS
 /*
  *----------------------------------------------------------------------
