summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authormdejong <mdejong>2003-01-26 05:59:37 (GMT)
committermdejong <mdejong>2003-01-26 05:59:37 (GMT)
commitbb7fd9a6b22b81948f940088e8e810b7d3673fd1 (patch)
tree2e93369723b56eef9c19628901fb5aea461eeb5a /unix
parent45c06028d02a86a2c5e83c43af1919b031a5e45f (diff)
downloadtcl-bb7fd9a6b22b81948f940088e8e810b7d3673fd1.zip
tcl-bb7fd9a6b22b81948f940088e8e810b7d3673fd1.tar.gz
tcl-bb7fd9a6b22b81948f940088e8e810b7d3673fd1.tar.bz2
* generic/tclIO.c (Tcl_CutChannel, Tcl_SpliceChannel):
Invoke TclpCutFileChannel and TclpSpliceFileChannel. * generic/tclInt.h: Declare TclpCutFileChannel and TclpSpliceFileChannel. * unix/tclUnixChan.c (FileCloseProc, TclpOpenFileChannel, Tcl_MakeFileChannel, TclpCutFileChannel, TclpSpliceFileChannel): Implement thread load data cut and splice for file channels. This avoids an invalid memory ref when compiled with -DDEPRECATED. * win/tclWinChan.c (FileCloseProc, TclpCutFileChannel, TclpSpliceFileChannel): Implement thread load data cut and splice for file channels. This avoids an invalid memory ref that was showing up in the thread extension.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c118
1 files changed, 104 insertions, 14 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 4838c55..79dad86 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -10,11 +10,12 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixChan.c,v 1.40 2002/11/07 02:13:37 mdejong Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.41 2003/01/26 05:59:37 mdejong Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
#include "tclPort.h" /* Portability features for Tcl. */
+#include "tclIO.h" /* To get Channel type declaration. */
/*
* sys/ioctl.h has already been included by tclPort.h. Including termios.h
@@ -555,15 +556,6 @@ FileCloseProc(instanceData, interp)
errorCode = errno;
}
}
-#ifdef DEPRECATED
- for (nextPtrPtr = &(tsdPtr->firstFilePtr); (*nextPtrPtr) != NULL;
- nextPtrPtr = &((*nextPtrPtr)->nextPtr)) {
- if ((*nextPtrPtr) == fsPtr) {
- (*nextPtrPtr) = fsPtr->nextPtr;
- break;
- }
- }
-#endif /* DEPRECATED */
ckfree((char *) fsPtr);
return errorCode;
}
@@ -1834,8 +1826,10 @@ TclpOpenFileChannel(interp, pathPtr, mode, permissions)
}
#ifdef DEPRECATED
- fsPtr->nextPtr = tsdPtr->firstFilePtr;
- tsdPtr->firstFilePtr = fsPtr;
+ if (channelTypePtr == &fileChannelType) {
+ fsPtr->nextPtr = tsdPtr->firstFilePtr;
+ tsdPtr->firstFilePtr = fsPtr;
+ }
#endif /* DEPRECATED */
fsPtr->validMask = channelPermissions | TCL_EXCEPTION;
fsPtr->fd = fd;
@@ -1933,8 +1927,10 @@ Tcl_MakeFileChannel(handle, mode)
}
#ifdef DEPRECATED
- fsPtr->nextPtr = tsdPtr->firstFilePtr;
- tsdPtr->firstFilePtr = fsPtr;
+ if (channelTypePtr == &fileChannelType) {
+ fsPtr->nextPtr = tsdPtr->firstFilePtr;
+ tsdPtr->firstFilePtr = fsPtr;
+ }
#endif /* DEPRECATED */
fsPtr->fd = fd;
fsPtr->validMask = mode | TCL_EXCEPTION;
@@ -3243,3 +3239,97 @@ TclUnixWaitForFile(fd, mask, timeout)
}
return result;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpCutFileChannel --
+ *
+ * Remove any thread local refs to this channel. See
+ * Tcl_CutChannel for more info.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Changes thread local list of valid channels.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclpCutFileChannel(chan)
+ Tcl_Channel chan; /* The channel being removed. Must
+ * not be referenced in any
+ * interpreter. */
+{
+#ifdef DEPRECATED
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+ Channel *chanPtr = (Channel *) chan;
+ FileState *fsPtr;
+ FileState **nextPtrPtr;
+ int removed = 0;
+
+ if (chanPtr->typePtr != &fileChannelType)
+ return;
+
+ fsPtr = (FileState *) chanPtr->instanceData;
+
+ for (nextPtrPtr = &(tsdPtr->firstFilePtr); (*nextPtrPtr) != NULL;
+ nextPtrPtr = &((*nextPtrPtr)->nextPtr)) {
+ if ((*nextPtrPtr) == fsPtr) {
+ (*nextPtrPtr) = fsPtr->nextPtr;
+ removed = 1;
+ break;
+ }
+ }
+
+ /*
+ * This could happen if the channel was created in one thread
+ * and then moved to another without updating the thread
+ * local data in each thread.
+ */
+
+ if (!removed)
+ panic("file info ptr not on thread channel list");
+
+#endif /* DEPRECATED */
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpSpliceFileChannel --
+ *
+ * Insert thread local ref for this channel.
+ * Tcl_SpliceChannel for more info.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Changes thread local list of valid channels.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclpSpliceFileChannel(chan)
+ Tcl_Channel chan; /* The channel being removed. Must
+ * not be referenced in any
+ * interpreter. */
+{
+#ifdef DEPRECATED
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+ Channel *chanPtr = (Channel *) chan;
+ FileState *fsPtr;
+
+ if (chanPtr->typePtr != &fileChannelType)
+ return;
+
+ fsPtr = (FileState *) chanPtr->instanceData;
+
+ fsPtr->nextPtr = tsdPtr->firstFilePtr;
+ tsdPtr->firstFilePtr = fsPtr;
+#endif /* DEPRECATED */
+}