diff options
author | ferrieux <ferrieux@noemail.net> | 2010-12-10 17:16:07 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@noemail.net> | 2010-12-10 17:16:07 (GMT) |
commit | 139e3760dcf81be80e556103c614b7a7f23bd199 (patch) | |
tree | dad1690e17a7f2c51a69e08b8ecfddbf22c07e03 /generic/tclIO.c | |
parent | f573bbdb20bfac417757eecfdec003bbaf098ef9 (diff) | |
download | tcl-139e3760dcf81be80e556103c614b7a7f23bd199.zip tcl-139e3760dcf81be80e556103c614b7a7f23bd199.tar.gz tcl-139e3760dcf81be80e556103c614b7a7f23bd199.tar.bz2 |
[backport] Make sure [fcopy -size ... -command ...] always calls the callback asynchronously, even for size zero.
FossilOrigin-Name: f1c09901d7f3068508363ece41b486049a503897
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index ebbb3d1..1bd4cdd 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.137.2.17 2010/03/20 17:53:07 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.137.2.18 2010/12/10 17:16:08 ferrieux Exp $ */ #include "tclInt.h" @@ -8467,6 +8467,33 @@ Tcl_FileEventObjCmd( /* *---------------------------------------------------------------------- * + * ZeroTransferTimerProc -- + * + * Timer handler scheduled by TclCopyChannel so that -command is + * called asynchronously even when -size is 0. + * + * Results: + * None. + * + * Side effects: + * Calls CopyData for -command invocation. + * + *---------------------------------------------------------------------- + */ + +static void +ZeroTransferTimerProc( + ClientData clientData) +{ + /* calling CopyData with mask==0 still implies immediate invocation of the + * -command callback, and completion of the fcopy. + */ + CopyData(clientData, 0); +} + +/* + *---------------------------------------------------------------------- + * * TclCopyChannel -- * * This routine copies data from one channel to another, either @@ -8573,6 +8600,16 @@ TclCopyChannel( outStatePtr->csPtrW = csPtr; /* + * Special handling of -size 0 async transfers, so that the -command is + * still called asynchronously. + */ + + if ((nonBlocking == CHANNEL_NONBLOCKING) && (toRead == 0)) { + Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr); + return 0; + } + + /* * Start copying data between the channels. */ |