diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 47 | ||||
-rw-r--r-- | generic/tclIORChan.c | 8 |
2 files changed, 12 insertions, 43 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 0910cc5..9a4735f 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -113,30 +113,11 @@ typedef struct CopyState { Tcl_WideInt total; /* Total bytes transferred (written). */ Tcl_Interp *interp; /* Interp that started the copy. */ Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */ - int refCount; /* Claim count on the struct */ - int bufInUse; /* Flag to govern access to buffer */ int bufSize; /* Size of appended buffer. */ char buffer[1]; /* Copy buffer, this must be the last * field. */ } CopyState; -static void -PreserveCopyState( - CopyState *csPtr) -{ - csPtr->refCount++; -} - -static void -ReleaseCopyState( - CopyState *csPtr) -{ - if (--csPtr->refCount) { - return; - } - ckfree((char *) csPtr); -} - /* * All static variables used in this file are collected into a single instance * of the following structure. For multi-threaded implementations, there is @@ -8668,13 +8649,9 @@ TclCopyChannel( Tcl_IncrRefCount(cmdPtr); } csPtr->cmdPtr = cmdPtr; - csPtr->refCount = 1; - csPtr->bufInUse = 0; inStatePtr->csPtrR = csPtr; - PreserveCopyState(csPtr); outStatePtr->csPtrW = csPtr; - PreserveCopyState(csPtr); /* * Special handling of -size 0 async transfers, so that the -command is @@ -8726,11 +8703,6 @@ CopyData( /* Encoding control */ int underflow; /* Input underflow */ - if (csPtr->bufInUse) { - return TCL_OK; - } - PreserveCopyState(csPtr); - inChan = (Tcl_Channel) csPtr->readPtr; outChan = (Tcl_Channel) csPtr->writePtr; inStatePtr = csPtr->readPtr->state; @@ -8792,7 +8764,6 @@ CopyData( sizeb = csPtr->toRead; } - csPtr->bufInUse = 1; if (inBinary || sameEncoding) { size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb); } else { @@ -8843,7 +8814,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } } @@ -8864,7 +8834,6 @@ CopyData( } else { sizeb = WriteChars(outStatePtr->topChanPtr, buffer, sizeb); } - csPtr->bufInUse = 0; /* * [Bug 2895565]. At this point 'size' still contains the number of @@ -8936,7 +8905,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } @@ -8959,7 +8927,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } } /* while */ @@ -8975,14 +8942,15 @@ CopyData( */ total = csPtr->total; - if (cmdPtr && interp && csPtr->cmdPtr) { + if (cmdPtr && interp) { int code; /* * Get a private copy of the command so we can mutate it by adding * arguments. Note that StopCopy frees our saved reference to the * original command obj. */ - cmdPtr = Tcl_DuplicateObj(csPtr->cmdPtr); + + cmdPtr = Tcl_DuplicateObj(cmdPtr); Tcl_IncrRefCount(cmdPtr); StopCopy(csPtr); Tcl_Preserve(interp); @@ -9010,7 +8978,6 @@ CopyData( } } } - ReleaseCopyState(csPtr); return result; } @@ -9324,16 +9291,10 @@ StopCopy( CopyEventProc, csPtr); } TclDecrRefCount(csPtr->cmdPtr); - csPtr->cmdPtr = NULL; - } - if (inStatePtr->csPtrR == NULL) { - return; } - ReleaseCopyState(inStatePtr->csPtrR); inStatePtr->csPtrR = NULL; - ReleaseCopyState(outStatePtr->csPtrW); outStatePtr->csPtrW = NULL; - ReleaseCopyState(csPtr); + ckfree((char *) csPtr); } /* diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 2e5fa45..bbb5b88 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -1508,6 +1508,14 @@ ReflectWatch( mask &= rcPtr->mode; + if (mask == rcPtr->interest) { + /* + * Same old, same old, why should we do something? + */ + + return; + } + rcPtr->interest = mask; /* |